Skip to content

Test/firebase coverage#19

Merged
AlpNuhoglu merged 2 commits into
mainfrom
test/firebase-coverage
May 22, 2026
Merged

Test/firebase coverage#19
AlpNuhoglu merged 2 commits into
mainfrom
test/firebase-coverage

Conversation

@AlpNuhoglu

Copy link
Copy Markdown
Collaborator

Summary

Add comprehensive unit test suites for editorServices.ts and services.ts, covering all previously uncovered functions (lines 67–699 and 28–181 respectively)
Add missing isDbAvailable() coverage in getDefaultDb.test.ts (lines 27–28)
Fix a race condition in integration tests that caused 6 intermittent failures when running the full suite
Changes
New / expanded unit tests

editorServices.test.ts — 162 tests, 100% statement/function/line coverage across all CRUD operations for blogs, events, media, announcements, notifications, campaigns, categories, and tags; covers all partial-update field branches, status mappings, Timestamp conversion paths, and unauthenticated uid fallbacks
services.test.ts — rewrote the partial file (was only covering submitContactMessage + submitVolunteerApplication) to cover all 12 exported functions; 61 tests total including ?? default branches for getPublicIbanEntries / getPublicSupporters, navigator undefined path for userAgent, and fromDoc id injection
getDefaultDb.test.ts — added two tests for isDbAvailable() covering the truthy and falsy env var branches

Integration test isolation fix

All 5 integration test files shared the same emulator PROJECT_ID, so parallel clearFirestore() calls in beforeEach would wipe staff documents seeded by a concurrently running file; isEditor() then called get(staff/uid) on a missing document, .data.role threw Null value error inside the rules evaluator, and legitimate editor writes were denied
newEnv() in helpers/emulator.ts now accepts an optional suite string appended to the project ID, giving each file its own isolated namespace

Test plan

npm run test:unit — 458 tests, all pass
npm run test:integration — 27 tests, all pass
npm test — 464 tests, 18 test files, all pass

…ation

Unit tests:
- Add full test suite for editorServices.ts (162 tests, 100% coverage)
- Expand services.test.ts to cover all read functions — getSiteSettings,
  getPublishedContentByType, getContentBySlug, getPublishedEvents,
  getCategories, getTags, getPublicMediaAssets, getActiveCampaigns,
  getPublicIbanEntries, getPublicSupporters (61 tests total)
- Add isDbAvailable() tests to getDefaultDb.test.ts to cover lines 27-28

Integration tests:
- Fix concurrent clearFirestore() race condition by giving each test file
  its own emulator namespace via a suite suffix in newEnv(); prevents one
  file's beforeEach from wiping staff docs seeded by a parallel file,
  which caused Null value error in isEditor() security rule evaluation
@AlpNuhoglu AlpNuhoglu merged commit d1d9ad9 into main May 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant