Skip to content

refactor: split test suites and the scan runner - #51

Merged
WhiteMuush merged 8 commits into
developfrom
refactor/split-test-suites
Oct 13, 2026
Merged

WhiteMuush merged 8 commits into
developfrom
refactor/split-test-suites

Conversation

@WhiteMuush

Copy link
Copy Markdown
Owner

Part of #30. Five oversized test suites (auth bootstrap, invitation integration and routes, SSO user creation, SSO integration) are split by theme, with the same tests.

The scan runner moves its severity rules into their own module, and the dashboard drawer detail builders move to lib with new unit tests. No behaviour change.

The detail route goes from 209 to 17 lines: employee, breach and alert builders move to src/lib/entity-detail, with the MFA label and remediation group shared. The kind lookup uses Object.hasOwn so inherited names such as constructor still get a 400. All 60 entities of the demo data, the 400, 404 and 401 cases return byte-identical responses.
263 lines become bootstrap.itest.ts (94, the start-up entry point), bootstrap-admin.itest.ts (141, state and first-admin creation) and bootstrap.fixtures.ts (the rolled-back empty database). Same 16 tests, all passing.
242 lines become invitation.itest.ts (issuing, 96), invitation-consume.itest.ts (redeeming, 114) and invitation.fixtures.ts, which gives each suite its own company so they can run in parallel. Same 14 tests, all passing.
400 lines become invitation-routes.itest.ts (invite route, rate ceiling, rotation gate, 147), invitation-rotation.itest.ts (forced rotation, acceptance, password change, 181) and a fixture giving each suite its own companies and mocks. Same 21 tests, all passing.
311 lines become user-create.itest.ts (156), user-create-escalation.itest.ts (50) and a fixture with a post() helper replacing the repeated six-line request literal. Comments become one sentence each. Same 8 tests, all passing.
runner.ts goes from 394 to 123 lines: severity and confidence move to severity.ts, finding persistence and corroboration to findings.ts, the retried lookup and check recording to lookup.ts. Its tests split the same way (severity, findings, checks), same 20 tests. No logic change.
Moving the builders into src/lib brought them under the coverage floor untested, and the new integration fixtures were counted as uncovered app code. The builders now have unit tests, fixtures are excluded like test files, and the floor rises to 57% of statements.
708 lines become five suites (model and helpers, permission gate, provider routes, domain verification, resolve and mandatory policy) and sso.fixtures.ts. Each suite now cleans only its own providers instead of every itest- one, so parallel suites cannot delete each other's rows. Comments become one sentence each. Same 21 tests; the full integration run passes twice in a row (110 tests).
export async function stubProviderRegistration(ownerId: string) {
return vi.spyOn(auth.api, "registerSSOProvider").mockImplementation(async (args) => {
if (!args) throw new Error("registerSSOProvider stub called without args")
if (!args) throw new Error("registerSSOProvider stub called without args")
@WhiteMuush
WhiteMuush merged commit 1feb561 into develop Oct 13, 2026
14 checks passed
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