Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions crates/ui/assets/style/narrow.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@
.status {
padding-inline: 1rem;
}
.topbar .search {
width: auto;
flex: 1 1 6rem;
max-width: 50%;
}
.crumb {
flex: 1 1 auto;
}
Expand All @@ -141,7 +136,6 @@
.topbar .search {
order: 10;
flex: 1 1 100%;
max-width: none;
}
}
@media (max-width: 520px) {
Expand Down
2 changes: 2 additions & 0 deletions crates/ui/assets/style/shell.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion tests/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions tests/browser/admin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import {
consent,
mailed,
mailUrl,
scrollsSideways,
serveClient,
signedUp,
signUp,
viewports,
withPasskeys
} from './helpers';

Expand Down Expand Up @@ -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
}) => {
Expand Down
19 changes: 19 additions & 0 deletions tests/browser/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
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.
Expand Down
23 changes: 2 additions & 21 deletions tests/browser/layout.spec.ts
Original file line number Diff line number Diff line change
@@ -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<boolean> {
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
Expand Down
Loading