diff --git a/web/src/settings/SettingsPage.test.tsx b/web/src/settings/SettingsPage.test.tsx index c520ecd..afb28dd 100644 --- a/web/src/settings/SettingsPage.test.tsx +++ b/web/src/settings/SettingsPage.test.tsx @@ -1,11 +1,12 @@ import { QueryClientProvider } from '@tanstack/react-query' import { fireEvent, render, screen, within } from '@testing-library/react' -import { MemoryRouter, Route, Routes, useLocation } from 'react-router' +import { Route, Routes, useLocation } from 'react-router' import { afterEach, describe, expect, it, vi } from 'vitest' import { ApiProvider, createApiClient, createQueryClient, createVerifiedSession } from '../api/index.ts' import { createNetworkStatus } from '../pwa/networkStatus.ts' import { AI_SETTINGS, HOUSEHOLD_SETTINGS, SETTINGS_API } from '../test/ApiProviders.tsx' import { declaredStyle } from '../test/cssRules.ts' +import { InDataRouter } from '../test/dataRouter.tsx' import { errorResponse, fakeLocation, jsonResponse, stubFetchByPath } from '../test/fetchStub.ts' import { expectMinHitArea } from '../test/hitArea.ts' import { mockViewport } from '../test/matchMedia.ts' @@ -39,7 +40,8 @@ function CurrentPath() { return

{useLocation().pathname}

} -// renderSettings renders the settings home on a 390 px phone (mock 1p); +// renderSettings renders the settings home on a 390 px phone (mock 1p) in a +// data router (the hidden sub-tabs' leave guard needs one); // SettingsTabs.test.tsx covers 768 px and up. function renderSettings() { mockViewport(390) @@ -47,12 +49,12 @@ function renderSettings() { return render( - + } /> } /> - + , ) @@ -95,9 +97,11 @@ describe('SettingsPage', () => { expect(fetchMock.mock.calls.map(([input]) => String(input)).sort()).toEqual([ REGULARS_PATH, '/api/v1/settings/ai', + '/api/v1/settings/ai/models', CALENDAR_PATH, '/api/v1/settings/household', NOTIFICATIONS_PATH, + '/api/v1/settings/recipe-search', ]) }) diff --git a/web/src/settings/SettingsPage.tsx b/web/src/settings/SettingsPage.tsx index 7d5f066..e96881e 100644 --- a/web/src/settings/SettingsPage.tsx +++ b/web/src/settings/SettingsPage.tsx @@ -25,9 +25,17 @@ import styles from './SettingsPage.module.css' import { SettingsTabs } from './SettingsTabs.tsx' // Settings home: the list of settings pages on mobile (mock 1p), one page -// with sub-tabs from 768 px (mock 2e). +// with sub-tabs from 768 px (mock 2e). The sub-tabs stay mounted, hidden, on +// mobile, so an unsaved draft survives the viewport crossing 768 px and its +// leave guard keeps asking before the list navigates away. export function SettingsPage() { - return useBreakpoint() === 'mobile' ? : + const mobile = useBreakpoint() === 'mobile' + return ( + <> + {mobile && } +