✅ Tests: AdminTechnical + DeckShow PDF + mosaic handler branches#513
Merged
✅ Tests: AdminTechnical + DeckShow PDF + mosaic handler branches#513
Conversation
…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).
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three of the seven medium-tier targets from the codecov report.
Controller/AdminTechnicalControllerController/DeckShowController(PDF + re-enrich routes)MessageHandler/GenerateMinifiedMosaicHandlerStacked 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-reenrichauth + invalid-CSRF.mosaic-generateinvalid-CSRF + happy path (handles both 0-pending and N-dispatched flashes).sprite-mapping-rebuildinvalid-CSRF.tcgdex-sync-insert/tcgdex-sync-updateinvalid-CSRF.banned-cards-syncinvalid-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.pdfreturnsapplication/pdfwith%PDF-…body for the owner; 403 for a non-owner./deck/{tag}/label-foldable.pdfsame access pattern + valid PDF body./deck/{tag}/decklist.pdfpersonal mode for owner;?anonymous=1variant; 403 for non-owner./deck/{tag}/re-enrichrequiresROLE_TECHNICAL_ADMIN; invalid CSRF → 403.GenerateMinifiedMosaicHandlerTestextensions (4 tests)errorlevel and rethrown.resolveMinifiedImage(GEN|73→ XY 129 with noCardPrintingreference attached to the tile).buildMergedTileskeyed onname|imageUrl, with summed quantity.pokemon → trainer → energywith qty-desc + name-asc inside each type.Test totals
Test plan
make cs-fix— cleanmake phpstan— level 10, no errorsmake test.unit— 1133 / 1133make test.functional— 1065 / 1065 (2 skipped, intentional)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