mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 21:31:46 +00:00
fc7d8b5d12
Brownfield strangler migration of the backend onto NestJS modules (auth, trips, days, places, assignments, packing, todo, budget, reservations, collab, files, photos, journey, share, settings, backup, oidc, oauth, admin, atlas, vacay, weather, airports, maps, categories, tags, notifications, system-notices) served through a per-prefix dispatcher, keeping the existing SQLite/better-sqlite3 DB and JWT httpOnly cookie auth, with behavioural parity for every route. Client: React 19 upgrade, "page = wiring container + data hook" pattern across all pages, per-domain Zustand stores bound to @trek/shared contracts, and decomposition of the large components (DayPlanSidebar, PackingListPanel, CollabNotes, FileManager, MemoriesPanel, PlacesSidebar, CollabChat, SystemNoticeModal, BudgetPanel, PlaceFormModal, ...) into focused render units backed by in-file hooks. Apply the shared global request pipeline (helmet/CSP, CORS, HSTS, forced HTTPS, the global MFA policy and request logging) to the NestJS instance as well, so a migrated route is protected identically to the legacy fallback rather than bypassing it.
43 lines
1.9 KiB
TypeScript
43 lines
1.9 KiB
TypeScript
import { test as setup, expect } from '@playwright/test'
|
|
|
|
// Relative to the config dir (client/), matching `storageState` in
|
|
// playwright.config.ts. Playwright runs from the client workspace root.
|
|
const stateFile = 'e2e/.tmp/state.json'
|
|
|
|
// Credentials match e2e/server-launch.mjs (ADMIN_EMAIL/ADMIN_PASSWORD). The
|
|
// seeded admin is created with must_change_password=1, so the first login goes
|
|
// through the forced change-password step before reaching the dashboard.
|
|
const EMAIL = 'e2e@trek.local'
|
|
const SEED_PW = 'E2eTest12345!'
|
|
const NEW_PW = 'E2eChanged12345!'
|
|
|
|
setup('authenticate the seeded admin (incl. forced password change)', async ({ page }) => {
|
|
await page.goto('/login')
|
|
await page.locator('input[type="email"]').fill(EMAIL)
|
|
await page.locator('input[type="password"]').fill(SEED_PW)
|
|
await page.locator('button[type="submit"]').click()
|
|
|
|
// must_change_password=1 → the change-password step renders two password
|
|
// fields (new + confirm). Selector-agnostic of the UI language.
|
|
const pw = page.locator('input[type="password"]')
|
|
await expect(pw).toHaveCount(2)
|
|
await pw.nth(0).fill(NEW_PW)
|
|
await pw.nth(1).fill(NEW_PW)
|
|
await page.locator('button[type="submit"]').click()
|
|
|
|
await page.waitForURL('**/dashboard', { timeout: 30_000 })
|
|
|
|
// Dismiss the first-run "Welcome to TREK" system-notice modal(s). It renders
|
|
// asynchronously (after the notices fetch), so wait for it before clicking.
|
|
// Dismissal is recorded server-side against this user, so clearing it here
|
|
// keeps it cleared for every authenticated flow in the run (shared test DB).
|
|
const ok = page.getByRole('button', { name: 'OK', exact: true })
|
|
await ok.waitFor({ state: 'visible', timeout: 10_000 }).catch(() => {})
|
|
for (let i = 0; i < 8 && (await ok.isVisible().catch(() => false)); i++) {
|
|
await ok.click()
|
|
await page.waitForTimeout(400)
|
|
}
|
|
|
|
await page.context().storageState({ path: stateFile })
|
|
})
|