Skip to content

test(e2e), fix(upload): network-fault tests, part 1 of 3 (#71) - #104

Merged
Hiczownik merged 1 commit into
mainfrom
test/fault-interception
Oct 22, 2026
Merged

Hiczownik merged 1 commit into
mainfrom
test/fault-interception

Conversation

@Hiczownik

Copy link
Copy Markdown
Owner

Part 1 of 3 for #71. This is Layer 1: Playwright breaks the browser's own requests, then each test checks that the app fails safely.

What's in it

  • e2e/faults/:

    • faults.ts: fault helpers (failRequests, failNthRequest, holdRequests, delayRequests, cutResponseAfter, failServiceWorkerRegistration, goOfflineFor).
    • checks.ts: after-test checks through docker exec, so no test-only API endpoints:
      • Postgres rows;
      • unfinished multipart uploads in storage, via mc;
      • ERR/FTL lines in the API log.
    • flows.ts: shared steps.
    • README.md: how to run them, plus the browser quirks below.
  • Scenarios, numbered as in the issue:

    # Fault Checked
    1 3-file upload, one file's 3rd part always fails Others stop; all 3 multipart uploads aborted, nothing left in storage, no confirm, clear message
    2 A part fails twice, then succeeds Retried with freshly signed URLs; download is byte-identical
    7 Encrypted download cut off half way (once) @cross-browser No download finishes, error shown; retry works without counting another download
    8 Service worker fails to register once @cross-browser First download falls back; the next registers the worker and uses it (Service worker registration failure is cached for the whole page life #41)
    11 Browser goes offline as part 2 goes out Clear message, no confirm; the same form uploads once back online
    12 503 SlowDown on every part's first attempt Each part retried once; upload completes
  • Playwright projects: faults, faults-firefox and faults-webkit, one worker each. The existing projects skip e2e/faults. CI's existing npx playwright test runs them, so ci.yml is unchanged.

  • fix(upload): scenarios 1 and 11 found that a failed part or a lost connection showed Client Error: Request failed with status code 500 / Client Error: Network Error. The new describeUploadError (with unit tests) says what happened and that nothing was shared. The API's own JSON errors and the empty 429 keep their current wording.

Browser quirks found on the way (in e2e/faults/README.md)

  • Playwright's request interception switches off service workers in Chromium. With a context route set, the worker never served a download, even after unrouteAll. So the download cut and the registration failure are done inside the page instead, with init scripts. Scenario 7 asserts that Chromium's retry really went through the worker.
  • Headless Chromium cancels the "Save as" dialog at once, and the app correctly treats that as the user cancelling. Scenario 8 removes showSaveFilePicker, as Firefox lacks it.
  • Firefox leaves a failed worker download pending (30 s and more) instead of failing it. No file is kept, so the test accepts "failed" or "pending", never "completed". After that, Playwright's Firefox drops mouse clicks on the page, so the retry click is dispatched instead. With a dispatched click the app behaves correctly: same session, saved via the worker.
    • ⚠️ To check by hand: whether real Firefox shows a stuck entry in its download panel after a cut-off encrypted download.

Not in this PR

Checked locally

  • CI=1 npx playwright test: every fault scenario passes in all three projects; scenario 8 is skipped on WebKit by design. The one failure is the existing photoMetadata test 9 on WebKit, because Playwright's WebKit on Windows has no OffscreenCanvas. That's unrelated to this PR, and CI runs on Linux.
  • vitest: 42 files, 381 passed. npm run build and npm run lint are clean.

🤖 Generated with Claude Code

Layer 1 of #71: Playwright breaks the browser's own requests, then checks
that the app fails safely: nothing left in storage, nothing counted twice,
a clear message, and recovery once the network is back.

- e2e/faults: fault helpers (fail, hold, delay, cut, offline, service
  worker registration), checks through docker exec (Postgres rows, storage
  multipart uploads via mc, ERR/FTL lines in the API log), shared steps
- Scenarios 1, 2, 11, 12 (uploads) and 7, 8 (downloads); 7 and 8 also run
  in Firefox and WebKit
- New faults, faults-firefox and faults-webkit projects (one worker each);
  the other projects skip e2e/faults, and CI's existing run picks them up
- fix(upload): a failed part or a lost connection showed "Client Error:
  Request failed with status code 500" or "Client Error: Network Error".
  Uploads now say what happened and that nothing was shared

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Hiczownik
Hiczownik marked this pull request as ready for review October 22, 2026 15:00
@Hiczownik
Hiczownik merged commit e7c076a into main Oct 22, 2026
2 checks passed
@Hiczownik
Hiczownik deleted the test/fault-interception branch October 22, 2026 15:11
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