diff --git a/crates/ui/assets/style/narrow.css b/crates/ui/assets/style/narrow.css index 271a265d9..22db329b3 100644 --- a/crates/ui/assets/style/narrow.css +++ b/crates/ui/assets/style/narrow.css @@ -114,11 +114,6 @@ .status { padding-inline: 1rem; } - .topbar .search { - width: auto; - flex: 1 1 6rem; - max-width: 50%; - } .crumb { flex: 1 1 auto; } @@ -141,7 +136,6 @@ .topbar .search { order: 10; flex: 1 1 100%; - max-width: none; } } @media (max-width: 520px) { diff --git a/crates/ui/assets/style/shell.css b/crates/ui/assets/style/shell.css index 44fa48957..dbfec1699 100644 --- a/crates/ui/assets/style/shell.css +++ b/crates/ui/assets/style/shell.css @@ -330,6 +330,8 @@ body.admin .main::before { border-color: var(--focus); } .search-box input { + /* Shrinks with the form, so the box never runs under the avatar beside it. */ + min-width: 0; min-height: 30px; padding: 0.2rem 0; border: 0; diff --git a/tests/browser/README.md b/tests/browser/README.md index 5e84e7cce..991362390 100644 --- a/tests/browser/README.md +++ b/tests/browser/README.md @@ -126,7 +126,8 @@ reason, and start a recovery whose link is mailed, then undo it. Support also renames a handle, which an owner may change only 30 days after signup: the new one signs in at once, and the old one no longer does. Another reads an account's security history, rotates a signing key and revokes it again, filters the -delivery queue, and reserves a handle and removes the reservation again. Set +delivery queue, and reserves a handle and removes the reservation again. The +top bar keeps its crumb, search box and avatar apart at every window size. Set `E2E_ADMIN_URL` to the dashboard's origin and `E2E_GRANT_ADMIN` to a command that grants administrator rights to the handle appended to it, e.g. `just auth admin grant` with the deployment's configuration. Without them, the tests are diff --git a/tests/browser/admin.spec.ts b/tests/browser/admin.spec.ts index 4f3356db6..e25d8fd44 100644 --- a/tests/browser/admin.spec.ts +++ b/tests/browser/admin.spec.ts @@ -8,9 +8,11 @@ import { consent, mailed, mailUrl, + scrollsSideways, serveClient, signedUp, signUp, + viewports, withPasskeys } from './helpers'; @@ -71,6 +73,43 @@ function entry(page: Page, change: string, reason: string) { .first(); } +/** + * The top bar at every size: the crumb, the search box and the avatar each keep + * their own room. The search box has run under the avatar on tablets before, as + * its input refused to shrink with the form. + */ +test("the dashboard's top bar fits every window size", async ({ browser }) => { + const admin = await administrator(browser, `bar-${Date.now().toString(36)}`); + await admin.goto(`${adminUrl}/users`); + const bar = admin.locator('.topbar'); + const parts = { + crumb: bar.locator('.crumb'), + search: bar.locator('.search-box'), + avatar: bar.getByRole('link', { name: 'Your account', exact: true }) + }; + for (const viewport of viewports) { + await admin.setViewportSize(viewport); + expect(await scrollsSideways(admin), viewport.name).toBe(false); + const boxes = await Promise.all( + Object.entries(parts).map(async ([name, part]) => { + const box = await part.boundingBox(); + if (!box) throw new Error(`${viewport.name}: the ${name} is not shown`); + return { name, ...box }; + }) + ); + for (const [i, a] of boxes.entries()) { + for (const b of boxes.slice(i + 1)) { + const crosses = + a.x < b.x + b.width && + b.x < a.x + a.width && + a.y < b.y + b.height && + b.y < a.y + a.height; + expect(crosses, `${viewport.name}: ${a.name} crosses ${b.name}`).toBe(false); + } + } + } +}); + test('an administrator disables a user from the dashboard, and the user is signed out', async ({ browser }) => { diff --git a/tests/browser/helpers.ts b/tests/browser/helpers.ts index 362cf5221..d30b1f007 100644 --- a/tests/browser/helpers.ts +++ b/tests/browser/helpers.ts @@ -12,6 +12,25 @@ import { /** Auth's origin, which the suite's `baseURL` also names. */ export const authUrl = process.env.E2E_AUTH_URL ?? 'http://localhost:3000'; +/** + * The window sizes the pages must work at, the smallest phone to a wide desktop, + * either side of the drawer's breakpoint. Few, and few pages each: auth's pages + * share one request budget a minute, which the whole suite spends. + */ +export const viewports = [ + { name: 'small phone', width: 320, height: 568 }, + { name: 'tablet', width: 768, height: 1024 }, + { name: 'laptop', width: 1280, height: 800 }, + { name: 'desktop', width: 1920, height: 1080 } +]; + +/** Whether the page body scrolls sideways, which no page may. */ +export async function scrollsSideways(page: Page): Promise { + return page.evaluate( + () => document.documentElement.scrollWidth > document.documentElement.clientWidth + ); +} + /** * A virtual platform authenticator on `page`, which verifies its user without * asking. A `synced` one backs its credentials up, like a synced passkey. diff --git a/tests/browser/layout.spec.ts b/tests/browser/layout.spec.ts index 46f26928f..2dc062479 100644 --- a/tests/browser/layout.spec.ts +++ b/tests/browser/layout.spec.ts @@ -1,24 +1,5 @@ -import { expect, test, type Page } from '@playwright/test'; -import { signUp, withPasskeys } from './helpers'; - -/** - * The window sizes the pages must work at, the smallest phone to a wide desktop, - * either side of the drawer's breakpoint. Few, and few pages each: auth's pages - * share one request budget a minute, which the whole suite spends. - */ -const viewports = [ - { name: 'small phone', width: 320, height: 568 }, - { name: 'tablet', width: 768, height: 1024 }, - { name: 'laptop', width: 1280, height: 800 }, - { name: 'desktop', width: 1920, height: 1080 } -]; - -/** Whether the page body scrolls sideways, which no page may. */ -async function scrollsSideways(page: Page): Promise { - return page.evaluate( - () => document.documentElement.scrollWidth > document.documentElement.clientWidth - ); -} +import { expect, test } from '@playwright/test'; +import { scrollsSideways, signUp, viewports, withPasskeys } from './helpers'; /** * The shell at every size: the sidebar beside the page on wide windows, a drawer