diff --git a/src/components/SettingsModal.tsx b/src/components/SettingsModal.tsx index 4b29354..4a7a7f7 100644 --- a/src/components/SettingsModal.tsx +++ b/src/components/SettingsModal.tsx @@ -175,7 +175,7 @@ export function SettingsModal({ className = '' }: { className?: string }) { const checkFirstVist = useCallback(async () => { const appConfig = await getAppConfig(); - if (!appConfig?.privacyAccepted) { + if (authEnabled && !appConfig?.privacyAccepted) { return; } const firstVisit = await getFirstVisit(); @@ -183,7 +183,7 @@ export function SettingsModal({ className = '' }: { className?: string }) { await setFirstVisit(true); setIsOpen(true); } - }, [setIsOpen]); + }, [authEnabled, setIsOpen]); useEffect(() => { checkFirstVist().catch((err) => { @@ -197,6 +197,9 @@ export function SettingsModal({ className = '' }: { className?: string }) { }, [apiKey, baseUrl, ttsProvider, ttsModel, ttsInstructions, checkFirstVist]); useEffect(() => { + if (!authEnabled) { + return; + } const onPrivacyAccepted = () => { checkFirstVist().catch((err) => { console.error('First visit check after privacy acceptance failed:', err); @@ -206,7 +209,7 @@ export function SettingsModal({ className = '' }: { className?: string }) { return () => { window.removeEventListener('openreader:privacyAccepted', onPrivacyAccepted); }; - }, [checkFirstVist]); + }, [authEnabled, checkFirstVist]); useEffect(() => { if (!ttsModels.some(m => m.id === modelValue) && modelValue !== '') { diff --git a/tests/helpers.ts b/tests/helpers.ts index 8cdba36..e3085e6 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -225,8 +225,16 @@ export async function setupTest(page: Page, testInfo?: TestInfo) { await cookieAcceptBtn.click(); } - // Settings modal should appear after privacy acceptance on first visit. - const saveBtn = page.getByRole('button', { name: 'Save' }); + // Settings modal should appear on first visit. In non-auth mode there is no + // privacy modal, so open Settings explicitly if onboarding did not auto-open. + const settingsDialog = page.getByRole('dialog', { name: 'Settings' }); + const saveBtn = settingsDialog.getByRole('button', { name: 'Save' }); + if (!(await saveBtn.isVisible().catch(() => false))) { + const settingsBtn = page.getByRole('button', { name: 'Settings' }); + if (await settingsBtn.isVisible().catch(() => false)) { + await settingsBtn.click(); + } + } await expect(saveBtn).toBeVisible({ timeout: 10000 }); // SettingsModal can briefly disable Save while it mirrors a custom model into the input field. await expect(saveBtn).toBeEnabled({ timeout: 15000 }); @@ -239,7 +247,7 @@ export async function setupTest(page: Page, testInfo?: TestInfo) { // Click the "done" button to dismiss the welcome message await saveBtn.click(); - await page.getByRole('dialog', { name: 'Settings' }).waitFor({ state: 'hidden', timeout: 15000 }); + await settingsDialog.waitFor({ state: 'hidden', timeout: 15000 }); } /**