Router: use memory history in tests; finalize HouseholdSettings UI; update spec and add cleanup tasks

This commit is contained in:
jableader 2025-11-01 15:05:41 +11:00
parent 6d95764516
commit f78cc31479
2 changed files with 14 additions and 2 deletions

View file

@ -166,6 +166,8 @@ Progress Log (Nov 1, 2025)
- Implemented Invitation Accept flow: added `src/api/invitations.ts` with `acceptInvitation` (temporary raw fetch), `InvitationAccept.vue` reads token and redirects to household; added `tests/invitations.api.test.ts`.
- Next: Implement Household Settings (invite members form), then remove legacy Person UI.
- Added a Settings link to `HouseholdSwitcher.vue` to surface the `household-settings` route for easier discovery.
- Implemented Household Settings invite form and members list UI. `src/views/HouseholdSettings.vue` now loads members via a temporary `listMembers()` in `src/api/households.ts` using the raw fetch helper. When the backend exposes a typed endpoint, we will swap to the generated client.
- Fixed router tests by using memory history in non-browser environments to avoid relying on `window.location` during unit tests.
---
@ -197,6 +199,7 @@ API client
- `src/api/client.ts`:
- Add header injection (`X-Household-Slug`) from a configurable getter to scope requests.
- Keep `paths` typing intact; no path string mutations.
- Cleanup task: Once OpenAPI exposes `householdSlug` as a path parameter, remove the `X-Household-Slug` header injection and switch calls to use typed params.
SDK
- `src/api/sdk.ts`:
@ -206,10 +209,12 @@ UI
- Login Page: Refactored to show email/password form when multitenant flag is enabled; legacy person list retained otherwise. Link to Create Account added.
- Add `HouseholdSwitcher.vue` to app chrome and wire with router.
- Update components that navigate using string paths to use named routes with slug.
- `src/views/HouseholdSettings.vue`: Invite members form wired to `sendInvitation(email)`. Members list rendered from `listMembers()`; guarded for backends that dont yet support the endpoint.
Tests
- Update MSW handlers/tests to assume JWT auth and household header.
- Add tests for router guards, invitation acceptance, and household switching.
- Add API tests for invitations (accept/send) and members listing header behavior. Router tests run under memory history in tests.
---
@ -217,6 +222,10 @@ Tests
- Avoid `any`/`unknown` in app code; keep all API calls typed via `openapi-fetch`.
- If backend adds header parameter to OpenAPI, regenerate and remove any client-specific header wiring.
- Cleanup tasks:
1) Remove X-Household-Slug header injection when `openapi.json` includes `householdSlug` path params; adopt typed client params.
2) Replace temporary raw fetch for invitations (`acceptInvitation`, `sendInvitation`) and members listing (`listMembers`) with generated typed endpoints.
3) Remove legacy `Person` model usages and the `currentUser()` adaptation shim once all flows use the `User` shape.
---

View file

@ -1,4 +1,4 @@
import { createRouter, createWebHashHistory, Router } from 'vue-router'
import { createRouter, createWebHashHistory, createMemoryHistory, Router } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
// Lazy-loaded route components
@ -61,8 +61,11 @@ export function createAppRouter(getCurrentUser: () => Promise<unknown> | unknown
)
}
const isBrowser = typeof window !== 'undefined' && typeof window.location !== 'undefined'
const history = isBrowser ? createWebHashHistory() : createMemoryHistory()
const router = createRouter({
history: createWebHashHistory(),
history,
routes,
})