fix(e2e): onboard the E2E fixture account so specs are not bounced to onboarding (PMS-641) #436

Merged
nrupard merged 1 commit from fix/PMS-641-onboard-e2e-account into main 2026-07-09 17:14:58 +02:00
Owner

What

Onboard the E2E fixture account in global.setup.ts so specs stop being bounced to /onboarding/profile.

Why

The E2E bunyip account's userinfo carries no given_name/family_name, so mokosh's JIT provisioning (auth::service upsert_user_from_oidc, src/modules/auth/service.rs:1819-1823) leaves profile_completed_at NULL. profile_completed is profile_completed_at.is_some(), and the mokosh-apps AuthGuard (mokosh-apps/src/lib.rs:96,101) redirects any incomplete user to /onboarding/profile. So on firefox/webkit the form-validation spec logged in, navigated toward /tickets/new, and landed on /onboarding/profile - the ticket form never rendered (PMS-641). Login itself succeeded; the block was the onboarding gate.

Change

After the setup captures + persists the bearer, it now PUTs /api/v1/auth/me with a first/last name. update_user stamps profile_completed_at = COALESCE(profile_completed_at, NOW()) when both names are present (service.rs:1174-1176), so the call is idempotent (only the first run sets it) and the account stays onboarded. Uses env.apiBaseURL + the just-captured bearer via request.newContext (mirroring the shared request fixture, which can't be reused here because it reads token.txt, written on the line above).

Validation

The onboarding PUT hits the existing staging PUT /me (not a new endpoint) and persists before any spec runs, so this PR's own E2E run should go green (form-validation reaches the ticket form). Local TS typecheck was not possible (no package-lock.json, no offline typescript), but the added code is a faithful copy of e2e/lib/fixtures.ts (request.newContext({baseURL, extraHTTPHeaders})) and e2e/tests/settings.spec.ts (request.put(route, {data})).

Fixes PMS-641.

## What Onboard the E2E fixture account in `global.setup.ts` so specs stop being bounced to `/onboarding/profile`. ## Why The E2E bunyip account's userinfo carries no `given_name`/`family_name`, so mokosh's JIT provisioning (`auth::service upsert_user_from_oidc`, `src/modules/auth/service.rs:1819-1823`) leaves `profile_completed_at` NULL. `profile_completed` is `profile_completed_at.is_some()`, and the mokosh-apps AuthGuard (`mokosh-apps/src/lib.rs:96,101`) redirects any incomplete user to `/onboarding/profile`. So on firefox/webkit the form-validation spec logged in, navigated toward `/tickets/new`, and landed on `/onboarding/profile` - the ticket form never rendered (PMS-641). Login itself succeeded; the block was the onboarding gate. ## Change After the setup captures + persists the bearer, it now PUTs `/api/v1/auth/me` with a first/last name. `update_user` stamps `profile_completed_at = COALESCE(profile_completed_at, NOW())` when both names are present (`service.rs:1174-1176`), so the call is idempotent (only the first run sets it) and the account stays onboarded. Uses `env.apiBaseURL` + the just-captured bearer via `request.newContext` (mirroring the shared `request` fixture, which can't be reused here because it reads `token.txt`, written on the line above). ## Validation The onboarding PUT hits the existing staging `PUT /me` (not a new endpoint) and persists before any spec runs, so this PR's own E2E run should go green (form-validation reaches the ticket form). Local TS typecheck was not possible (no `package-lock.json`, no offline typescript), but the added code is a faithful copy of `e2e/lib/fixtures.ts` (`request.newContext({baseURL, extraHTTPHeaders})`) and `e2e/tests/settings.spec.ts` (`request.put(route, {data})`). Fixes PMS-641.
fix(e2e): onboard the E2E fixture account so specs are not bounced to onboarding
All checks were successful
E2E / Playwright against staging (pull_request) Successful in 37s
Check / fmt + clippy + build + tests (pull_request) Successful in 1m20s
Create release / Gate (release-branch merges only) (pull_request) Successful in 1s
Create release / Create release from merged PR (pull_request) Has been skipped
Integration / integration tests (pull_request) Successful in 12m45s
b777e4109e
The E2E bunyip account's userinfo carries no given_name/family_name, so mokosh's JIT provisioning (upsert_user_from_oidc) leaves profile_completed_at NULL. The mokosh-apps AuthGuard then bounces every login to /onboarding/profile before a deep link can render, which broke the form-validation spec on firefox/webkit: it navigated toward /tickets/new and landed on /onboarding/profile instead.

Onboard the fixture once in global.setup.ts: after capturing the bearer, PUT /me with a first/last name. The server COALESCEs profile_completed_at, so the call is idempotent (only the first run stamps it) and every subsequent spec sees profile_completed=true. Uses the API host + the just-captured bearer directly, since the shared authed request fixture reads the token file written on the preceding line.

#PMS-641
nrupard scheduled this pull request to auto merge when all checks succeed 2026-07-09 17:14:25 +02:00
nrupard deleted branch fix/PMS-641-onboard-e2e-account 2026-07-09 17:14:58 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!436
No description provided.