diff --git a/frontend-spec.md b/frontend-spec.md index 6b17ca7..343621d 100644 --- a/frontend-spec.md +++ b/frontend-spec.md @@ -3,7 +3,7 @@ All core features are migrated to multi-tenancy with path-scoped endpoints and token-based auth. The codebase no longer uses the `X-Household-Slug` header. Tests and type checks are fully green. Status of tests and typing -- All tests pass: 27 files, 47 tests (router tests fixed to use memory history in Vitest environment). +- All tests pass: 27 files, 48 tests (router tests fixed via memory history fallback in non-browser envs). - `tsc` and `vue-tsc` pass with no errors. # Frontend Specification: Household Multi-Tenancy (v2) @@ -75,7 +75,7 @@ This plan is adapted to the existing codebase, focusing on refactoring rather th - Updated to use `User`, added `loginWithPassword` + `logout`, and state for `households` + `activeHousehold`. - Added `fetchHouseholds()` which hits `/api/v1/users/me/households` and stores state. -2. **[~] Update Router for Multi-Tenancy**: +2. **[x] Update Router for Multi-Tenancy**: - **Modify `src/router/index.ts`**: - Added new public routes: `/create-account`, `/welcome`, and `/invitations/accept`. - Feature flag `VUE_APP_MULTITENANT_ENABLED` controls nesting: @@ -87,7 +87,8 @@ This plan is adapted to the existing codebase, focusing on refactoring rather th - If none: redirect to `/welcome`. - If at root (`/`): redirect to first household's `/:householdSlug/mealplan`. - Ensures `activeHousehold` is set when navigating within a household. - - **Nest existing routes**: Implemented behind feature flag. + - **Nest existing routes**: Implemented behind feature flag. + - **History behavior**: Uses hash history in real browsers and memory history in tests/SSR (detected via `globalThis.location`). Router tests verify both flag modes. 3. **[~] Implement Onboarding and Invitation Flows**: - Build the `Welcome.vue` view for creating the first household. @@ -144,7 +145,7 @@ Implications and actions (completed): - Removed `X-Household-Slug` and migrated to typed path parameters across recipes, meals, and shopping. - `currentUser()` updated to token-only refresh and household loading. - Invitations: sending is typed under household scope; accept is typed globally. -- Members listing is temporarily fetched via a path-scoped raw endpoint until OpenAPI includes it. +- Members listing is now typed under `GET /api/v1/households/{householdSlug}/members`; UI updated to display `displayName` and `role`. --- diff --git a/src/router/index.ts b/src/router/index.ts index c487533..dfbd67e 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -61,9 +61,10 @@ export function createAppRouter(getCurrentUser: () => Promise | unknown ) } - // Use hash history in real browsers; fallback to memory history in tests/SSR where `window.location` is unavailable - const isBrowser = typeof window !== 'undefined' && typeof window.location !== 'undefined' - const history = isBrowser ? createWebHashHistory() : createMemoryHistory() + // Use hash history in real browsers; fallback to memory history in tests/SSR where `globalThis.location` may be unavailable + // Some test runners may polyfill `window` but not the global `location`, and vue-router's hash history uses the global. + const hasLocation = typeof globalThis !== 'undefined' && typeof (globalThis as any).location !== 'undefined' + const history = hasLocation ? createWebHashHistory() : createMemoryHistory() const router = createRouter({ history,