Close test-coverage gaps and enforce a coverage threshold #62
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Close the identified unit-coverage gaps (back + front) and add a coverage threshold to lock the line, so coverage can't silently regress as the app grows. Framed as "close real gaps + enforce a floor" rather than a blunt "100%" — the point is meaningful coverage of real logic, not line-hitting framework boilerplate.
Backend gaps (PHPUnit, from
dev-coverage)The validator family has its
validate()exercised only via functional/integration paths, so isolated-unit coverage shows 0–50% methods. Add direct unit tests (mirroringUniquePriorityPerScenarioValidatorTest, which is the 100% reference) covering each validator's full logic matrix:App\Validator\BufferOnlyForFixedLimitValidator— 0% methods / 81.82% linesApp\Validator\CompatibleAllocationTypeValidator— 0% methods / 81.82% linesApp\Validator\SingleOverflowPerScenarioValidator— 50% methods / 87.5% lines (itsUnexpectedTypeException/ non-Bucket-ignored branches aren't unit-hit)App\Doctrine\AbstractOwnerScopeExtension— 75% methods / 92.86% lines (one uncovered branch — identify and cover or document why it's unreachable)Boilerplate to EXCLUDE (not worth testing):
App\Repository\UserRepository::upgradePassword— Symfony maker-generatedPasswordUpgraderInterfaceimpl; framework boilerplate, no app logic. Either add a coverage@codeCoverageIgnore(or phpunit<exclude>) so the report is honest, or document the exclusion. Do NOT write a contrived test for it.Frontend gaps (Vitest)
The frontend has no coverage gate yet (test harness landed in #52). Establish one:
@vitest/coverage-v8), atest:coveragescript, and adev-fe-coverageshell.nix helper.src/logic (components, the api client, auth provider/guards) that the existing tests miss.main.tsx(the mount point), generated/config files.Threshold enforcement
<report>min threshold (or a CI step that fails under the floor).coverage.thresholdsin config.Notes
App\Validator\UniquePriorityPerScenarioValidator+ its test are the model for the validator unit tests (constraint-type guard, non-entity ignored, repo-count delegation, violation-at-path).Add: enable TypeScript
strictmode (frontend)Discovered during #52 review: the frontend
tsconfigdoes NOT set"strict": true— onlyerasableSyntaxOnly,noUnusedLocals,noUnusedParameters,noFallthroughCasesInSwitch. Soascasts and implicit-any have no safety net (e.g. aas FieldErrorscast in the register form is unchecked by the compiler).As part of the quality-hardening here:
"strict": trueinfrontend/tsconfig.app.json(and node config as appropriate).ascasts, possibly-undefined access, implicit anys).Isolated here rather than enabling mid-#52 (it could surface many errors at once).
Resolved on
release/v0.3.0(commit196cbfb). code-reviewer: clean, no blockers.Coverage — backend now 100% real, frontend ~98.5%
UniquePriorityPerScenarioValidatorTest.AbstractOwnerScopeExtensionanon-branch covered via a newtests/Doctrine/ScenarioOwnerExtensionTest.php(tests the base through its simplest concrete subclass + a Security stub).@codeCoverageIgnore'd rather than contrived-tested:UserRepository::upgradePasswordandKernel::getAllowedEnvs(the latter was the stubborn 99.74% holdout — already PHPStan-ignored for the same reflection reason). Backend is now an honest 100% (Classes/Methods/Lines 32/32, 124/124, 380/380).@vitest/coverage-v8set up; covered api.ts (get/post/patch/delete + path guard), useAuth out-of-provider throw, AuthProvider non-401 probe branch, Login/Register generic-error fallback, DigitalProgressBar zones → 98.58% stmts / 100% lines.TS strict — enabled
strict: true+noUncheckedIndexedAccesson both tsconfigs (done now while the code is minimal — blast radius was just 2 errors inDigitalProgressBar.getZone, fixed with a typed non-optional fallback). strict-null core surfaced zero issues.Threshold enforcement
coverage.thresholdsin vite.config (statements/functions/lines 95, branches 90).dev-coverage-checkshell helper (PHPUnit 13 has no native fail-under-N%, so it parses the Lines % against a 95 floor).dev-check-allenforces both locally.dev-fe-coverage,dev-coverage-check.coverage/git+prettier-ignored.CI wiring of these gates → tracked on #35.