fix(router): use memory history in test/SSR to avoid global location access; update spec and test counts
This commit is contained in:
parent
05e8dba8c8
commit
710f9ccf9b
2 changed files with 9 additions and 7 deletions
|
|
@ -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:
|
||||
|
|
@ -88,6 +88,7 @@ This plan is adapted to the existing codebase, focusing on refactoring rather th
|
|||
- 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.
|
||||
- **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`.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -61,9 +61,10 @@ export function createAppRouter(getCurrentUser: () => Promise<unknown> | 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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue