Commit Graph

44 Commits

Author SHA1 Message Date
Edouard Vanbelle 947d2c6e20 fix(e2e): wait for the Service Worker to control the page before API calls
`apiAdminCreateUser` intermittently failed with
`401 {"error":"DPoP nonce required","error_type":"DpopVerificationFailed"}`,
most visibly in admin.spec.ts's pagination test.

Not a nonce-rotation race — the nonce pool keeps a 3-minute overlap
window precisely so in-flight requests survive rotation. It is a
service-worker-control race.

`browserFetch` issues a raw page-context `fetch`, and the DPoP proof is
attached by the Service Worker intercepting it — the helper's own doc
comment says so. The SPA's proof-and-retry logic lives in `client.ts`'s
`dpopFetch`, which this helper deliberately bypasses. So when the SW is
not yet controlling the page, the request goes out unsigned, the
middleware sees a bound session with no proof (`dpop.rs`, the
`expected_jkt` match), and answers with a nonce challenge. Nothing
retries it: the SW that would have signed it is what is missing, and
`dpopFetch` was never in the path.

The window is real on every fresh browser context. `service-worker.ts`
does `skipWaiting()` + `clients.claim()`, which is correct, but claiming
is asynchronous — the first navigation loads uncontrolled, then
install → activate → claim. `waitForLoadState('networkidle')` says
nothing about SW control, so a helper called a few lines after
`apiLogin` can land inside it. Slower CI widens it, which is why this
showed up there and not locally.

The fix waits inside the same `page.evaluate` as the fetch, so it costs
one property check once the page is controlled and needs no per-page
bookkeeping. It is bounded at 10s: if the SW never claims, the request
goes out as before and the resulting 401 stays the clear signal it is
today rather than becoming an unexplained Playwright timeout.

Worth stating because it is easy to get wrong: **`ready` is not
`controlling`.** `navigator.serviceWorker.ready` resolves once a
registration is active, while `controller` stays null until that worker
has claimed THIS page. Awaiting only `ready` looks correct and still
flakes.

This is a test bug, not a product one. Real paths go through `apiFetch`,
which signs in page JS; the SW is the safety net for requests that
bypass it (`<img src>`, downloads). This helper is the only caller
relying on the SW as its primary signer.

Not verified by running the suite: a flake reproduces on CI timing, so
one green local run would prove nothing. The mechanism is confirmed from
the code path — SW-signed proof, no fallback retry, asynchronous claim.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-05 00:29:37 +02:00
Edouard Vanbelle 06e4df5318 fix(upload): fix race condition in front-end 2026-08-22 08:09:21 +02:00
Edouard Vanbelle f4e923e381 fix(test): fix CRC error in png samples 2026-08-09 13:26:40 +02:00
Edouard Vanbelle a9eaa3fd74 fix(test): fix playwright to suport OPAQUE+DPOP 2026-08-09 13:10:09 +02:00
Edouard Vanbelle 9e94cb398c test(dpop): OPAQUE + DPOP required for e2e tests 2026-08-09 12:31:39 +02:00
Edouard Vanbelle 11c7f9440e chore(e2e): remove old playwright test (wired to vanilla JS) 2026-08-09 12:27:31 +02:00
Edouard Vanbelle df9a6babbb fix(tests): prevent playwrigt test to load default .env 2026-08-09 11:46:53 +02:00
Edouard Vanbelle 15da1a50bd fix(dpop): fix issue with sveltekit and playwright
await page.waitForLoadState('networkidle') is the key before starting
2026-08-09 01:56:08 +02:00
Edouard Vanbelle ed99b08e62 feat(DPoP): UI: bcast events to support multi tab
add also playwright test with the multi tab
2026-08-09 01:56:07 +02:00
Edouard Vanbelle 6965855388 reactor(opaque): normalize to OXICLOUD_AUTH_OPAQUE_* variables 2026-08-04 07:31:32 +02:00
Edouard Vanbelle 92254ef894 feat(opaque): diasable OPAQUE in e2e front test for now 2026-08-04 07:03:08 +02:00
Edouard Vanbelle f1c72f8837 test(storage): adapt playwright admin tests 2026-08-01 20:35:04 +02:00
Edouard Vanbelle 5a87999949 fix(integration test): fix drive test used bytes with grace period 2026-07-30 01:29:09 +02:00
Edouard Vanbelle c14efc1184 fix(test): fix breadcrumb test 2026-07-27 01:33:09 +02:00
Edouard Vanbelle 67579932c7 feat(ui): action bar is contextualizez accross sections
- [download] + [remove from recent] for recent section
  - [download] + [remove from favorite] for favorite section
  - [restore] + [permanent delete] for trash section
2026-07-20 19:15:41 +02:00
Edouard Vanbelle 4f3309e087 test(front): correct frontend test + end2end tests 2026-07-20 18:46:45 +02:00
Edouard Vanbelle 75a347205e test(admin): update playwright test to fit recent changes 2026-07-19 18:08:07 +02:00
Dionisio Pozo 5ae551a93d Merge pull request #577 from EdouardVanbelle/feat/users-perfs-and-filter-dotfiles
feat: users prefs server side + filter dotfiles + filter shares by resource type
2026-07-14 09:07:09 +02:00
Edouard Vanbelle 341e354162 test(frontend): correct test to fit sign up/in 2026-07-14 03:27:28 +02:00
Edouard Vanbelle b18f0dc74a test(front): isolate dotfile e2e fixtures under scratch parents 2026-07-13 22:00:53 +02:00
Edouard Vanbelle 063382ad60 test(front): test dotfile view/hidden 2026-07-13 21:21:26 +02:00
Bradley Nelson 02335c0680 test(e2e): run the SvelteKit SPA Playwright suite in CI
The e2e CI job ran the legacy `scenarios/*` specs against the vanilla `static/`
frontend that upstream has since removed, so it could never pass. Point CI at
this repo's SvelteKit SPA suite (tests/e2e/spa) and wire up what it needs:

- CI: build the release binary with `--features plugins` (the admin Plugins-tab
  specs exercise the WASM runtime) and run `npm run test:coverage`, building the
  instrumented SPA with COVERAGE=1 VITE_E2E=1 so the server serves the
  data-testid-instrumented build the specs drive.
- Coverage harness: target 127.0.0.1 instead of `localhost` (which resolves to
  ::1 first on CI runners while the server binds IPv4, so readiness never
  connected) and poll `/ready` for webServer readiness; tee start-server-spa.sh
  output to a log surfaced by an always-run CI step for diagnostics.
- Files page: restore a persistent breadcrumb home link (buildCrumbs returns
  only the path folders, so there was no "go home" affordance), and fix the
  `?file=` deep-link race where the viewer→URL effect stripped the param before
  the listing loaded — a bookmarked preview link now opens the viewer.

All 101 spa specs pass locally.
2026-06-22 10:34:47 -06:00
Bradley Nelson e3823ce470 test(e2e): Playwright + Vitest coverage harness and test instrumentation
Add an end-to-end and unit test suite for the SvelteKit frontend:

- Playwright e2e specs (tests/e2e/spa) with a throwaway container stack,
  codegen scenarios, and an Istanbul-based coverage report pipeline.
- Vitest unit tests across API endpoints, components, stores and composables.
- `data-testid` hooks on interactive elements (AppShell, FileViewer,
  ShareDialog, search, photos, files breadcrumbs, login/Nextcloud flows,
  public share pages) so the e2e suite can target them deterministically.
- Serve the SPA app-shell CSP from a <meta> policy (svelte.config.js) plus a
  middleware that skips the CSP header on HTML; move the Nextcloud Login Flow
  v2 grant page to the SvelteKit /nextcloud/login route.
- `just front-codegen` recipe and start-server-spa.sh harness.

Make the test environment robust and consistent:
- Install a deterministic in-memory localStorage/sessionStorage in the Vitest
  setup so storage behaves identically across Node versions (Node 26 ships a
  native Web Storage global that otherwise shadows jsdom's).
- Pin devenv to Node 26 + PostgreSQL 18 and pin every CI job to Node 26.3.0
  so the dev shell and CI run the same toolchain versions.

Repair the API/WebDAV (hurl) suite, which had drifted from the backend:
- Migrate the removed `/api/folders/{id}/listing` endpoint to `/resources`
  (cursor-paginated `{items:[{resource_type,resource}]}` shape) across the
  batch-copy, grants, nested-group, and WebDAV NC tests + the dav_helpers
  wipe routine.
- Stop photos_etag from uploading the dedup-tracked fixture so the dedup
  blob-lifecycle test can own its content-addressed blob exclusively.
- dedup_create now asserts the idempotent same-content re-upload (201 +
  existing file id) instead of the stale 409 expectation.

Generated coverage reports, nyc output and the e2e server runtime data dir
are gitignored rather than committed.
2026-06-22 00:05:06 -06:00
Edouard Vanbelle b5b252ba19 test(e2e): update playwright chrome snapshots 2026-06-16 15:36:43 +02:00
EdouardVanbelle 6bb154aaf6 test(e2e): update playwright linux snapshots 2026-06-16 13:28:29 +00:00
EdouardVanbelle 7788f59efe test(e2e): update playwright linux snapshots 2026-06-15 16:30:38 +02:00
Edouard Vanbelle e2c5336581 chore(test): update screenshots 2026-06-15 16:30:38 +02:00
EdouardVanbelle b25d1593d3 test(e2e): update playwright snapshots
- due to change one91d4dbab9f644feaa6216bb6bd697156272f07e
2026-06-07 19:46:42 +02:00
Edouard Vanbelle 45ba118c35 test(front): update screenshots 2026-06-03 00:35:25 +02:00
EdouardVanbelle 54c1989b44 test(e2e): update playwright linux snapshots 2026-06-03 00:32:00 +02:00
Edouard Vanbelle f4362a4832 test(end to end): update tests (login page has now login via email) 2026-06-03 00:32:00 +02:00
Edouard Vanbelle ca1a2bb649 feat(light-dark): normalize light/dark/like-os mode
permits user to define light, dark or like the desktop
2026-05-30 09:36:15 +02:00
Edouard Vanbelle ec43c4f9c9 fix(playwright): raise any pageerror, purpose is to stops immediatly on a bundle issue 2026-05-28 01:54:48 +02:00
Edouard Vanbelle 7a849be3d8 chore(playwright): upgrade to version 1.60.0 2026-05-27 11:50:02 +02:00
EdouardVanbelle 2dc2b0876d test(e2e): update playwright linux snapshots 2026-05-27 09:48:25 +00:00
Edouard Vanbelle 7ddbbc94cc test(e2e): update all images and grow snapshot comparaison sensitivity 2026-05-27 11:35:42 +02:00
Edouard Vanbelle 891ff89a5d test(playwright): add playwright report to track changes + correct playwright parameters
ci: fix actions/checkout@v6 → @v4 (v6 does not exist)

GitHub started rejecting invalid action versions at parse time,
causing every CI run to fail with 0s / 'workflow file issue'
before any jobs could start.

 * test(e2e): only no retry
 * test(e2e): use static name in tests to facilitate screenshot comparaison
 * test(e2e): update linux screenshots
 * test(e2e): adapt test due to user-vignette generation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 11:29:58 +02:00
Edouard Vanbelle 872abd4d27 test: add front end folder management test (creation, renaming, etc)
note: firefox test remove due to idempotence issue
2026-05-19 13:31:20 +02:00
Edouard Vanbelle edbfe2848c fix(front): fix issue with already declared constants on release mode
- ensure not loading twice the same variables, namespace to ensure it in the future
 - end to end tests where successfull, need to check it is not reusing a previous release (in cache from build CI)
 - fix: #377 #378
2026-05-19 09:36:24 +02:00
Edouard Vanbelle d8625b9f39 ci: merge end-to-end workflow into ci, permits to reduce amount of built 2026-05-11 12:10:15 +02:00
Edouard Vanbelle 8ab537797a test(api): add API test on contacts
next will be to add CI on it
2026-05-11 00:53:29 +02:00
Edouard Vanbelle ddf6104749 chore(e2e-test): fix snapshot pixel ratio + try to reuse cargo build to reduce cpu consumption 2026-05-08 21:41:28 +02:00
EdouardVanbelle b550a5def9 test(e2e): update playwright linux snapshots 2026-05-08 21:41:28 +02:00
Edouard Vanbelle 3c3d24ac72 test: initial end to end test with playwright 2026-05-08 21:41:28 +02:00