Files
LivingDexTracker/tests/bdd/features/account-access.feature
T
Josh Creek 4af33709a3 test: make the suite's assertions falsifiable and its state isolated
Several assertions could not fail:

- "the catch update remains saved" was `caught.isChecked() || notes.includes(...)`
  shared by two scenarios, so either half satisfied both. Split into two steps
  that each assert the outcome their own scenario is about.
- The token-refresh check read a global counter with `> 0` and asserted an upload
  had happened `some(...)`, both already satisfied by the preceding scenario. It
  now asserts exactly one refresh, ordered before the upload.
- The box step ignored its box argument and asserted on the first N entries on
  the page; it now scopes to that box and checks its full contents.
- The filter step asserted on whichever entry was first after filtering; it now
  records the caught entry beforehand and names it, and checks the filter did not
  exclude everything.
- The empty-state precondition asserted emptiness instead of establishing it,
  which a fresh user satisfies for free.
- Offline coverage was `caches.keys().length > 0`. It now checks the precache
  contract: one workbox cache holding the shell and a revisioned web manifest,
  with _app/immutable assets cached without a revision query. The scenario that
  claimed to test a trailing slash did not; it is replaced with real offline
  client-side navigation.

The mock provider kept recorded requests, its refresh counter and the
fail-uploads switch in one process-wide object that only one step reset, so
scenario order was load-bearing and the failing-upload scenario poisoned
everything after it. An auto fixture now resets it per scenario, and the mock no
longer records its own control-plane calls. That reset is why the suite stays on
a single worker, which is now documented.

Coverage was gated at 90% per file over an allowlist of exactly the five files
that had tests, so new code was invisible to it permanently. It now measures all
of src/lib with global thresholds at the measured baseline, and no longer runs
the unit tests twice.

Also: a global teardown removes the users each run creates, the Supabase wrapper
distinguishes a stopped stack from a broken CLI call and detects an unseeded
database, the sign-in rate limit is raised above what one serial run needs, and
the integration suite no longer falls back to a hard-coded anon key that would
mask a misconfigured run.

The password-reset scenarios are renamed to what they actually cover: following a
real recovery link bounces to /signin, because the browser client persists no
cookies and so cannot keep the session it parses out of the URL. The helper for
the real flow is left in place and the gap is documented.
2026-09-13 17:38:42 +01:00

48 lines
1.4 KiB
Gherkin

Feature: Account access
As a trainer
I want secure access to my account
So that only I can update my collection
Scenario: Register a new account
Given I am a new visitor
When I register with valid account details
Then I am told to confirm my email
And a confirmation email is captured locally
Scenario: Sign in with valid credentials
Given I have a confirmed account
When I sign in with my credentials
Then I arrive at my Pokédex list
Scenario: Reject invalid credentials
Given I have a confirmed account
When I sign in with an incorrect password
Then I see a sign-in error
Scenario: Redirect an authenticated visitor
Given I am signed in
When I visit the public home page
Then I arrive at my Pokédex list
Scenario: Sign out
Given I am signed in
When I sign out
Then I return to the public home page
Scenario: Request a password reset
Given I have a confirmed account
When I request a password reset
Then a password reset email is captured locally
@product-review
Scenario: Reject mismatched replacement passwords
Given I am signed in on the password reset page
When I enter two different replacement passwords
Then I am told that the passwords do not match
Scenario: Complete a password reset
Given I am signed in on the password reset page
When I enter a valid replacement password
Then I am told that my password was updated