test: backfill regression coverage for #1158, #1184, #1192 and #1207 - #1220
Conversation
An audit of the fixes merged over the last few days asked one question of each: would its tests fail if the fix were reverted? Several would not. This adds the missing coverage. Test-only — no production file is touched. #1158 (SDK-case-id occurrence lookup) shipped with NO test that changes behaviour on revert; the only test-file change in that commit was two doc comments. Adds a two-backfilled-occurrences-on-one-day pair — the shape that broke the old date heuristic — asserting BOTH completions promote their own PlanningCase, plus the byte-identical UpdateFromCalendar twin, because the two methods are copy-paste and a fix applied to one would be invisible to a single test. Also pins the new CaseNotFound branch, including its partial write. #1184 (resigned workers) covered its assignee pickers well but left the highest-stakes site untested: CalendarAssignmentResolver, which decides who actually RECEIVES deployed eForm cases. Nothing anywhere seeded a resigned worker there, so reverting that filter broke no assertion. Adds that test — both sites carry a real SiteWorker so the only difference is the flag, with an un-resign round-trip as the positive control, since a site with no SiteWorker passes the predicate and would have made the exclusion nearly vacuous. Also covers AdhocService.ListWorkers. #1192/#1204 (Rapport image appendix): nothing asserted that a photograph is ever embedded. Every writer test passes core: null, so InsertImage returned early and the grid cells were emitted empty. Adds a fixture with a real Core and a local picture store that asserts the ImagePart exists, that its Blip resolves inside the grid cell, and that the bytes were resized — plus the missing-file case, so one broken photograph cannot fail a 200-page report. Note this was a coverage gap, not a live defect: production always passes a real Core. #1207 (monthly anchor) had 22 pure enumerator tests but nothing end to end. Adds the relocation two-tile scenario through UpdateTask scope-"all" (the regression a late reviewer caught, previously pinned only by a reflection test on a static mapper), the past-dated anchor render/no-back-deploy pair, after-N through the real render path, and the 28-cap cohort — every wizard monthly series started on the 29th-31st, which the issue's own sizing query could not see. Tests are labelled for what they actually prove. Two are deliberately not regression tests and say so in their names and docs: a Characterisation_ test documenting the dropped planning-ownership check (#1218) without asserting it is correct, and a Tripwire_ test that passes pre- and post-fix but turns red if the start-month duplicate decision is ever switched. Found while writing these, filed rather than fixed: #1217 (yearly rules render a pre-start occurrence and double-render the start week), #1218, and #1219 (export image data URI declares image/png while carrying JPEG bytes, and the declared width attribute is inert). Adds two TestBaseSetup fixtures (+2 MariaDb containers, ~+2.5% on the integration-test step) and 14 tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018qJL2WhHwhZ5CGZehZF2ro
There was a problem hiding this comment.
🟡 Changes recommended
New tests create SDK DbContexts via core.DbContextHelper.GetDbContext() without disposing them, which can leak resources and destabilize the integration suite.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds integration-level regression coverage across the Backend Configuration plugin’s test suite, specifically backfilling assertions for several recently-fixed calendar/worker/export behaviors so those fixes would fail if reverted.
Changes:
- Added new integration fixtures to assert image embedding in compliance report exports and end-to-end monthly-anchor calendar write-path behavior.
- Expanded calendar and compliance legacy-path tests to cover multi-occurrence backfill scenarios, new failure branches, and additional recurrence-bound cases.
- Added resigned-worker exclusion coverage in both worker-tag assignment resolution and adhoc worker listing.
File summaries
| File | Description |
|---|---|
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn.Integration.Test/WorkerTagAssignmentTest.cs | Adds resigned-worker filtering coverage for tag-based recipient resolution. |
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn.Integration.Test/ComplianceExportImageEmbeddingTests.cs | New fixture asserting that images are actually embedded (and resilient to missing files) in generated .docx. |
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn.Integration.Test/ComplianceCompletionLegacyPathsTests.cs | Adds regression assertions for SDK-case-id occurrence lookup and related characterization coverage. |
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn.Integration.Test/CalendarMonthlyAnchorWritePathTests.cs | New fixture driving monthly-anchor scenarios through real write paths and deploy behavior. |
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn.Integration.Test/CalendarMonthlyAnchorOccurrenceTests.cs | Extends seeded series shape and adds render-path coverage for after-N and 28-cap cohorts. |
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn.Integration.Test/AdhocServiceReferenceDataTests.cs | Adds resigned-worker exclusion tests for ListWorkers and supporting SDK seeding helper. |
Review details
Suppressed comments (1)
eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn.Integration.Test/AdhocServiceReferenceDataTests.cs:359
- The SDK DbContext created via core.DbContextHelper.GetDbContext() isn't disposed. Using 'await using' here matches the pattern used in production code (and other tests) and avoids leaking connections/resources during the suite.
var core = await GetCore();
var sdkDbContext = core.DbContextHelper.GetDbContext();
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| var core = await GetCore(); | ||
| var sdkDbContext = core.DbContextHelper.GetDbContext(); | ||
|
|
Test-only. No production file is touched —
diff -rqover the whole plugin production tree is empty, and the diff contains no non-test path.Why
We audited every fix merged in the last few days and asked one question of each: would its tests fail if the fix were reverted? For several the answer was no. Two shipped with tests that could not go red at all. This backfills that.
The audit's summary, so the scope is legible:
What each test pins
#1158 — SDK-case-id occurrence lookup. Shipped with no test that changes behaviour on revert; the only test-file change in that commit was two doc comments. The old date heuristic collapsed for back-filled series, where every sibling
PlanningCaseSite.CreatedAtandCompliance.StartDateland on the backfill day — soFirstOrDefaultAsyncreturned the same row for every completion and theStatus != 100guard silently swallowed the rest. Symptom: green calendar, one row in Logbøger.Adds that exact shape — two occurrences of one planning sharing a day, each with its own SDK case — asserting both promote their own
PlanningCase, and that the first is not overwritten (so "always take the last row" cannot pass). Plus the byte-identicalUpdateFromCalendartwin, because the two methods are copy-paste and a fix applied to one would be invisible to a single test. Plus the newCaseNotFoundbranch, pinning its partial write as-is rather than as it ought to be.#1184 — resigned workers. The assignee pickers were covered well.
CalendarAssignmentResolver— which decides who actually receives deployed eForm cases — was not, and nothing anywhere seeded a resigned worker there, so reverting that filter broke no assertion. The silent regression is a resigned employee still getting real work pushed to their device.Both sites carry a real
SiteWorker, so the only difference is the flag, with an un-resign round-trip as the positive control — a site with noSiteWorkerpasses theAnypredicate and is returned, which would have made a naive exclusion assertion nearly vacuous. Also coversAdhocService.ListWorkers.#1192/#1204 — Rapport image appendix. Nothing asserted a photograph is ever embedded: every writer test passes
core: null, soInsertImagereturned early and the grid cells were emitted empty. Adds a fixture with a realCoreand a local picture store asserting theImagePartexists, itsBlipresolves inside the grid cell (not floating elsewhere), and the bytes were resized — plus the missing-file case, so one broken photograph cannot fail a 200-page report.To be clear: this was a coverage gap, not a live defect. An earlier read of ours concluded the appendix might be rendering blank in production. That was wrong — the early return is gated on
core == null, only true in tests; the service always passes a realCore.#1207 — monthly anchor. 22 pure enumerator tests existed; nothing end to end. Adds the relocation two-tile scenario through
UpdateTaskscope-"all" (the regression a late reviewer caught, previously pinned only by a reflection test on a static mapper), the past-dated anchor render/no-back-deploy pair, after-N through the real render path, and the 28-cap cohort — every wizard monthly series started on the 29th-31st, which the issue's own sizing query structurally could not see.Tests are labelled for what they prove
That is the main thing to review here. Two are deliberately not regression tests and say so in their names and docs:
Characterisation_Update_MismatchedCaseAndCompliance_...documents the dropped planning-ownership check (fix(compliance): Update/UpdateFromCalendar no longer check that the quoted case and compliance belong to the same planning #1218) without asserting it is correct, and tells a future reader to rewrite rather than "fix" it if a guard is added.Tripwire_GetTasksForWeek_CompletedAnchorInStartMonth_...passes pre- and post-fix; it turns red only if the start-month duplicate decision is switched.One more is honestly split: the past-anchor test's render half is a genuine regression assertion, its no-back-deploy half passed vacuously pre-fix and is kept as a guard against someone deleting the
RotationDate >= todayUtcfilter and mass-deploying history on upgrade. Its doc says so.Found while writing these — filed, not fixed
Monthand leftYearout of scope by explicit decision.image/pngwhile carrying JPEG bytes, and itswidth="300px"attribute is inert (HTMLwidthmust be a bare integer). Both latent.Cost
+2
TestBaseSetupfixtures (+2 MariaDb containers), 844 → 858 tests, ~+10-15s on a470s step (**+2.5%**). CI runs the project unfiltered, so no allowlist change is needed.A merge of the new write-path fixture into an existing one was attempted to save a container and abandoned: the result measured 1619 lines against a ~1100 threshold, and the helper duplication it targeted would have survived anyway.
Not verified
No test was executed locally — tests run in CI only. Everything here is compile-checked (
0 Error(s)) and hand-derived; CI is the first real run.🤖 Generated with Claude Code
https://claude.ai/code/session_018qJL2WhHwhZ5CGZehZF2ro