Skip to content

test: backfill regression coverage for #1158, #1184, #1192 and #1207 - #1220

Merged
renemadsen merged 1 commit into
stablefrom
test/regression-coverage-backfill
Sep 8, 2026
Merged

test: backfill regression coverage for #1158, #1184, #1192 and #1207#1220
renemadsen merged 1 commit into
stablefrom
test/regression-coverage-backfill

Conversation

@renemadsen

Copy link
Copy Markdown
Member

Test-only. No production file is toucheddiff -rq over 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:

PR Verdict
#1177 adhoc photos, #1197 worker grouping, #1198/#1199 export, #1203 backend Genuinely well covered — nothing added
#1200 chips-as-pills Pure CSS; an assertion would re-encode the stylesheet and protect nothing. Deliberately no test
#1158, #1184 (resolver half), #1192/#1204 (images), #1207 (end to end) Covered here

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.CreatedAt and Compliance.StartDate land on the backfill day — so FirstOrDefaultAsync returned the same row for every completion and the Status != 100 guard 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-identical UpdateFromCalendar twin, because the two methods are copy-paste and a fix applied to one would be invisible to a single test. Plus the new CaseNotFound branch, 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 no SiteWorker passes the Any predicate and is returned, which would have made a naive exclusion assertion nearly vacuous. Also covers AdhocService.ListWorkers.

#1192/#1204 — Rapport image appendix. Nothing asserted 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 asserting the ImagePart exists, its Blip resolves 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 real Core.

#1207 — monthly anchor. 22 pure enumerator tests existed; 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 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:

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 >= todayUtc filter and mass-deploying history on upgrade. Its doc says so.

Found while writing these — filed, not fixed

Cost

+2 TestBaseSetup fixtures (+2 MariaDb containers), 844 → 858 tests, ~+10-15s on a 470s 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

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
Copilot AI lite review requested due to automatic review settings September 8, 2026 14:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment on lines +317 to +319
var core = await GetCore();
var sdkDbContext = core.DbContextHelper.GetDbContext();

@renemadsen
renemadsen merged commit 4ecb807 into stable Sep 8, 2026
32 checks passed
@renemadsen
renemadsen deleted the test/regression-coverage-backfill branch September 8, 2026 14:54
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.

2 participants