Skip to content

test(browser): cover the full ceremony flows (correcting a PR #40 oversight)#41

Merged
wolpert merged 1 commit into
mainfrom
test/ceremonies-mutation-coverage
Jun 8, 2026
Merged

test(browser): cover the full ceremony flows (correcting a PR #40 oversight)#41
wolpert merged 1 commit into
mainfrom
test/ceremonies-mutation-coverage

Conversation

@wolpert

@wolpert wolpert commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #40. Adds the ceremony-flow tests that #40 should have included.

Correcting my mistake in #40

In #40 I characterised ceremonies.ts's no-coverage mutants as effectively e2e-only — covered by the Playwright virtual-authenticator suite in the demos and therefore not worth unit-testing. That was wrong. CeremonyOptions.credentials injects a fake CredentialsContainer, so authenticate(), the credential create/get helpers, the cancellation branches, and the navigator.credentials guard are all fully unit-testable in jsdom. Because I skipped them, #40 left ceremonies.ts at 43.2% while every other SDK file climbed into the 94–100% range — the one remaining drag on the overall score, and avoidably so. This PR fixes that.

What this adds (+10 tests; 77/77 pass; tsc --noEmit clean)

  • authenticate() end-to-end — start → credentials.get → finish, token returned, POST verbs asserted, username ?? null default on the start body
  • conditional mediationmediation: "conditional" set only when conditional: true, and absent otherwise
  • register() body contractdisplayName ?? username, label ?? null, challenge: null, both ceremony steps POSTed
  • create/get cancellation — a null credential rejects with the cancelled error
  • navigator guard — throws its clear message when no credentials are injected (jsdom has none)
  • base64url — a DataView/subarray case covering the toUint8Array ArrayBufferView dispatch

On the remaining survivors — intentionally left honest

A handful of mutants remain undetected: equivalent mutants in base64url (lenient atob, ignored out-of-bounds typed-array writes, the padding-regex anchor that's moot for btoa output), the navigator typeof-flips that only differ in a non-browser runtime, and the index.ts barrel.

I am deliberately not adding // Stryker disable comments or trimming the mutate glob to hide these. At this stage the mutation score should reflect what the tests actually exercised, not what the tooling is configured to overlook. The number stays honest, and these survivors stand as a visible, accurate record.

🤖 Generated with Claude Code

The updated StrykerJS report (PR #39, @bernata) lifted the SDK from 65.1% to
79.3% after the first hardening pass, leaving ceremonies.ts at 43.2% as the
dominant gap: 36 of its mutants were no-coverage. The existing suite drove only
the register() happy path, so authenticate(), the credential create/get
helpers, the cancellation branches, and the navigator.credentials guard were
never executed.

These flows ARE unit-testable — CeremonyOptions.credentials injects a fake
CredentialsContainer — so this drives them end to end:
- authenticate(): start -> get -> finish, token returned, POST verbs, and the
  start-body username ?? null default;
- conditional mediation set only when conditional=true (and absent otherwise);
- register() start/finish body contract: displayName ?? username, label ?? null,
  challenge null, and both steps POSTed (kills the surviving "POST"/default and
  logical-operator mutants);
- create/get cancellation: a null credential rejects with the cancelled error;
- the navigator.credentials guard throws its clear message (jsdom has no
  navigator.credentials), killing the guard's conditional/string mutants.

Also adds a base64url DataView/subarray case that kills the toUint8Array
ArrayBufferView dispatch mutant. The few remaining base64url survivors are
equivalent mutants (lenient atob, ignored out-of-bounds writes, the padding
regex anchor) and are left as-is, as are the navigator typeof-flips that only
differ in a non-browser environment.

All 77 browser-SDK tests pass; tsc --noEmit clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wolpert wolpert enabled auto-merge June 8, 2026 14:46
@wolpert wolpert merged commit 4dce3a5 into main Jun 8, 2026
3 checks passed
@wolpert wolpert deleted the test/ceremonies-mutation-coverage branch June 8, 2026 14:49
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