Skip to content

✅ Tests: AdminTechnical + DeckShow PDF + mosaic handler branches#513

Merged
jbourdin merged 1 commit intodevelopfrom
test/medium-coverage-batch
May 3, 2026
Merged

✅ Tests: AdminTechnical + DeckShow PDF + mosaic handler branches#513
jbourdin merged 1 commit intodevelopfrom
test/medium-coverage-batch

Conversation

@jbourdin
Copy link
Copy Markdown
Owner

@jbourdin jbourdin commented May 3, 2026

Summary

Three of the seven medium-tier targets from the codecov report.

Target Before New tests
Controller/AdminTechnicalController 27 % 16
Controller/DeckShowController (PDF + re-enrich routes) 57.6 % 9
MessageHandler/GenerateMinifiedMosaicHandler 72.3 % 4

Stacked on top of #512 (which is also waiting in green CI). Per your nudge — focus on real branches and skip simple-line tedium.

AdminTechnicalControllerCoverageTest (16 tests)

  • enrich-retry / flush-reenrich auth + invalid-CSRF.
  • mosaic-generate invalid-CSRF + happy path (handles both 0-pending and N-dispatched flashes).
  • sprite-mapping-rebuild invalid-CSRF.
  • tcgdex-sync-insert / tcgdex-sync-update invalid-CSRF.
  • banned-cards-sync invalid-CSRF.
  • clear-cache (MenuRuntime invalidation), clear-app-cache ($cache->clear()), clear-cache-key (empty-input warning + named-key delete) — invalid-CSRF + happy path each.

Out of scope: dispatch happy paths for Messenger-backed actions whose handlers run sync in the test env and reach external services (TCGdex, PokeAPI, pokemon.com) without try/catch in the controller. The dispatch lines themselves are one-liners; everything else around them is covered.

DeckShowPdfRoutesTest (9 tests)

  • /deck/{tag}/label.pdf returns application/pdf with %PDF-… body for the owner; 403 for a non-owner.
  • /deck/{tag}/label-foldable.pdf same access pattern + valid PDF body.
  • /deck/{tag}/decklist.pdf personal mode for owner; ?anonymous=1 variant; 403 for non-owner.
  • /deck/{tag}/re-enrich requires ROLE_TECHNICAL_ADMIN; invalid CSRF → 403.

GenerateMinifiedMosaicHandlerTest extensions (4 tests)

  • Catch branch: exception inside the pipeline is logged at error level and rethrown.
  • MINIFIED_PRINTING_OVERRIDES static map short-circuits resolveMinifiedImage (GEN|73 → XY 129 with no CardPrinting reference attached to the tile).
  • Tile dedup: two cards with the same name + image collapse into one tile via buildMergedTiles keyed on name|imageUrl, with summed quantity.
  • Tile sort order: pokemon → trainer → energy with qty-desc + name-asc inside each type.

Test totals

Pre-branch After
Unit 1129 1133 (+4)
Functional 1040 1065 (+25)

Test plan

  • make cs-fix — clean
  • make phpstan — level 10, no errors
  • make test.unit — 1133 / 1133
  • make test.functional — 1065 / 1065 (2 skipped, intentional)
  • CI green
  • Codecov bumps the three targeted files

Branched off develop pre-#512; will need a rebase if #512 lands first, but no file overlap so it'll be clean.

🤖 Generated with Claude Code

…handler branches

Three coverage targets from the medium-tier list:

AdminTechnicalControllerCoverageTest (16 tests):
- enrich-retry / flush-reenrich auth + CSRF reject branches
- mosaic-generate CSRF reject + happy path (info/success flash)
- sprite-mapping-rebuild CSRF reject branch
- tcgdex-sync-insert / tcgdex-sync-update CSRF reject branches
- banned-cards-sync CSRF reject branch
- clear-cache CSRF reject + happy path
- clear-app-cache CSRF reject + happy path (cache->clear)
- clear-cache-key CSRF reject + empty-key warning + valid delete

Note: dispatch happy paths for Messenger-backed actions (set-mappings,
tcgdex-sync, flush-reenrich, banned-cards-sync, sprite-mapping-rebuild)
are not asserted because the test env runs sync transports and the
handlers reach external services (TCGdex / pokemon.com / PokeAPI)
without try/catch in the controller. The CSRF + auth branches are the
testable surface; the controller code beyond them is one-line dispatch.

DeckShowPdfRoutesTest (9 tests):
- /deck/{tag}/label.pdf returns application/pdf for owner; 403 otherwise
- /deck/{tag}/label-foldable.pdf same access pattern + valid PDF body
- /deck/{tag}/decklist.pdf personal mode for owner, ?anonymous=1 variant,
  403 for non-owner
- /deck/{tag}/re-enrich requires ROLE_TECHNICAL_ADMIN; invalid CSRF -> 403

GenerateMinifiedMosaicHandlerTest extensions (4 tests):
- Catch branch: exception inside the pipeline is logged at error level
  and rethrown
- MINIFIED_PRINTING_OVERRIDES static map short-circuits resolveMinifiedImage
  (GEN|73 -> XY 129 with no CardPrinting reference)
- Two cards with the same name + image collapse into one tile via the
  buildMergedTiles dedup keyed on `name|imageUrl`
- Tile sort order pokemon -> trainer -> energy with qty-desc + name-asc
  within each type

Test totals: 1133 unit (+4) / 1065 functional (+25).
@sentry
Copy link
Copy Markdown

sentry Bot commented May 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jbourdin jbourdin merged commit a25fec1 into develop May 3, 2026
6 checks passed
@jbourdin jbourdin deleted the test/medium-coverage-batch branch May 3, 2026 20:47
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