fix(ui): update SettingsModal and test helpers for improved onboarding flow in non-auth mode
This commit is contained in:
parent
b6852da2a2
commit
df0e4341ff
2 changed files with 17 additions and 6 deletions
|
|
@ -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 !== '') {
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue