2026-04-07 18:31:09 +08:00
|
|
|
import { useAuthStore } from '../../src/store/authStore';
|
|
|
|
|
import { useTripStore } from '../../src/store/tripStore';
|
|
|
|
|
import { useSettingsStore } from '../../src/store/settingsStore';
|
|
|
|
|
import { useVacayStore } from '../../src/store/vacayStore';
|
|
|
|
|
import { useAddonStore } from '../../src/store/addonStore';
|
|
|
|
|
import { useInAppNotificationStore } from '../../src/store/inAppNotificationStore';
|
|
|
|
|
import { usePermissionsStore } from '../../src/store/permissionsStore';
|
test: comprehensive Journey test suite — 89.5% new code coverage
Server (172 tests):
- journeyService unit tests (87 tests): CRUD, access control, sync, photos, contributors
- journeyShareService unit tests (20 tests): share links, token validation, public access
- journey integration tests (45 tests): all API routes, auth, permissions, edge cases
- Test helpers: journey factories, RESET_TABLES updated
Client (340+ tests):
- journeyStore tests (15 tests): all store actions and state management
- JourneyPage tests (20 tests): frontpage, create flow, suggestions, navigation
- JourneyDetailPage tests (94 tests): all sub-components, entry editor, settings,
share links, contributors, gallery, map, trip linking
- JourneyPublicPage tests (18 tests): public view, tabs, restricted access
- JourneyBookPDF tests (6 tests): PDF generation
- BottomNav tests (9 tests): profile sheet, navigation
- PhotoLightbox tests (8 tests): keyboard nav, counter
- JourneyMap tests (12 tests): markers, polylines, zoom
- Component tests: moodConfig, stripMarkdown, MarkdownToolbar, JournalBody, MobileTopHeader
- DashboardPage tests (32 tests): spotlight card, quick actions, widget settings
SonarQube: exclude unused MemoriesPanel from coverage (dead code, moved to Journey)
2026-04-12 07:19:53 +08:00
|
|
|
// Journey store is reset individually in journey tests to avoid circular import issues
|
2026-04-07 18:31:09 +08:00
|
|
|
|
|
|
|
|
// Capture initial states at import time (before any test modifies them)
|
|
|
|
|
const initialAuthState = useAuthStore.getState();
|
|
|
|
|
const initialTripState = useTripStore.getState();
|
|
|
|
|
const initialSettingsState = useSettingsStore.getState();
|
|
|
|
|
const initialVacayState = useVacayStore.getState();
|
|
|
|
|
const initialAddonState = useAddonStore.getState();
|
|
|
|
|
const initialNotifState = useInAppNotificationStore.getState();
|
|
|
|
|
const initialPermsState = usePermissionsStore.getState();
|
|
|
|
|
export function resetAllStores(): void {
|
|
|
|
|
useAuthStore.setState(initialAuthState, true);
|
|
|
|
|
useTripStore.setState(initialTripState, true);
|
|
|
|
|
useSettingsStore.setState(initialSettingsState, true);
|
|
|
|
|
useVacayStore.setState(initialVacayState, true);
|
|
|
|
|
useAddonStore.setState(initialAddonState, true);
|
|
|
|
|
useInAppNotificationStore.setState(initialNotifState, true);
|
|
|
|
|
usePermissionsStore.setState(initialPermsState, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function seedStore<T extends object>(
|
|
|
|
|
store: { setState: (partial: Partial<T>, replace?: boolean) => void },
|
|
|
|
|
state: Partial<T>,
|
|
|
|
|
): void {
|
|
|
|
|
store.setState(state);
|
|
|
|
|
}
|