diff --git a/e2e/chunks.spec.ts b/e2e/chunks.spec.ts index fb1984fd..490f3da8 100644 --- a/e2e/chunks.spec.ts +++ b/e2e/chunks.spec.ts @@ -135,6 +135,32 @@ for (const chunk of ['Policies', 'AreaChart', 'Sparkline', 'Donut']) { }); } +test('a rejected showcase import leaves its panel empty and the sign-in form working', async ({browser}) => { + const context = await browser.newContext({serviceWorkers: 'block', viewport: {width: 1280, height: 800}}); + const page = await context.newPage(); + const uncaught: string[] = []; + page.on('pageerror', error => uncaught.push(error.message)); + await page.addInitScript(() => { + localStorage.setItem('doona-profiles', JSON.stringify([{id: 'demo', name: 'Demo', api: 'mock', token: ''}])); + localStorage.setItem('doona-profile', 'demo'); + localStorage.setItem('doona-lang', 'en'); + }); + const rejected = page.waitForRequest(/\/LoginShowcase-[^/]+\.js$/); + await page.route('**/assets/LoginShowcase-*.js', route => route.abort()); + try { + await page.goto('/#/activity'); + await rejected; + const login = page.locator('.rp-login-page'); + await expect(login.locator('.rp-login-showcase[aria-hidden="true"]')).toBeVisible(); + await expect(login.locator('.rp-alert')).toHaveCount(0); + await Promise.all([page.waitForEvent('load'), login.getByRole('button', {name: 'Sign in', exact: true}).click()]); + await expect(page.locator('.rp-nav[href="#/activity"]')).toHaveAttribute('aria-current', 'page'); + expect(uncaught).toEqual([]); + } finally { + await context.close(); + } +}); + test('the idle warm-up loads the search dialog before any interaction', async ({page}) => { const requested = page.waitForRequest(/\/SearchDialog-[^/]+\.js$/); await page.goto('/#/activity'); diff --git a/src/shell/Login.tsx b/src/shell/Login.tsx index 4d1e73b1..5c7a1e64 100644 --- a/src/shell/Login.tsx +++ b/src/shell/Login.tsx @@ -3,13 +3,16 @@ import {useT, type Lang} from '../i18n'; import {useLogin} from './useLogin'; import {Button, ErrorMessage, InlineAlert, Link, Loading, TextField} from '../ui/ui'; import {useMediaQuery} from '../ui/hooks'; +import {LoadBoundary} from '../ui/LoadBoundary'; import LinkOut from '../ui/icons/LinkOut'; import logo from '../logo.svg'; import {href} from './route'; import {LanguageMenu, SchemeToggle} from './AppearanceControls'; -// The panel beside the form loads only where it is shown, so the sign-in chunk stays the same size on a phone. +// The panel beside the form loads only where it is shown, so the sign-in chunk stays the same size on a phone. Until it +// arrives, or if it never does, the panel stays empty and the form works as before. const LoginShowcase = lazy(() => import('./LoginShowcase')); +const emptyShowcase =
; type LoginProps = { profileId: string; @@ -149,9 +152,11 @@ export function Login({profileId, api, backend, rejected, lang, pickLang, dark, {wide && ( - }> -