fix(app): dashboard cards keep the screen width with a long e-mail

The card grid had no explicit column below md: its implicit auto track
took the cards' min-content, so the account e-mail never truncated and
pushed the page sideways. One minmax(0,1fr) column; the e-mail wraps.
e2e/shell/responsive.spec.ts sweeps 320-430 px and desktop (RESP-01).
This commit is contained in:
bchanot committed 2026-10-27 19:37:54 +01:00
1 parent dd5a23c39d
commit a70166ea11
4 files changed
+179 -7

No files matched your search

+162
View File
@@ -0,0 +1,162 @@
import { en } from '@/i18n/en'
import { fr } from '@/i18n/fr'
import type { Dict } from '@/i18n/types'
import type { Page, TestInfo } from '@playwright/test'
import {
expect,
expectNoHorizontalOverflow,
focusOwner,
test,
} from '../support/browser'
import {
createAccount,
dropLateReplays,
routeToSandbox,
} from '../support/sandbox'
import { seedAnimal, seedClient, seedRelation } from '../support/records'
import { signIn } from '../support/shell'
// RESP-01 (V1-1 DEV acceptance): no page of the shell scrolls sideways, from
// 320 to 430 px on the phone project and at the desktop width, with long
// realistic values in both languages; the dashboard shows the whole e-mail of
// the account (a long one used to widen the cards past the screen).
const LANGUAGES = [
['fr', fr],
['en', en],
] as const
const PHONE_WIDTHS = [320, 360, 375, 390, 430]
const LONG = {
localPart: 'prenom.nom-compose.praticienne-fictive',
client: 'Recette Client Au Nom Particulièrement Long Pour Les Petits Écrans',
clientEmail: 'prenom.nom-compose.recette@cabinet-veterinaire-exemple.example.org',
address: 'Chemin de la Recette Responsive, Lieu-dit Les Petits Écrans',
city: 'Saint-Rémy-de-Provence-sur-Recette',
structure: 'Écurie Recette Structure Responsive Organisation',
animal: 'Recette Animal Au Nom Très Long Pour Les Écrans Étroits',
}
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
/** Opens a page and waits for its heading and its reads. */
async function open(page: Page, path: string) {
await page.goto(path)
await expect(page.locator('main h1').first()).toBeVisible()
await page.waitForLoadState('networkidle')
}
/** The account e-mail of the dashboard is shown whole: not clipped, not cut. */
async function expectWholeEmail(page: Page, email: string, state: string) {
const value = page.locator('main dd', { hasText: email })
await expect(value).toHaveText(email)
const clipped = await value.evaluate((dd) => dd.scrollWidth > dd.clientWidth)
expect(clipped, `e-mail clipped on ${state}`).toBe(false)
}
/** A confirmation opened with Enter keeps the focus, fits, and Escape gives it back. */
async function checkConfirmation(
page: Page,
action: string,
title: string,
state: string,
) {
const button = page.getByRole('button', { name: action, exact: true })
await button.focus()
await page.keyboard.press('Enter')
const dialog = page.getByRole('dialog', { name: title })
await expect(dialog).toBeVisible()
expect(await focusOwner(page)).toBe('dialog')
await expectNoHorizontalOverflow(page, state)
await page.keyboard.press('Escape')
await expect(dialog).toBeHidden()
await expect(button).toBeFocused()
}
async function checkDrawer(page: Page, dict: Dict, state: string) {
const menu = page.getByRole('button', { name: dict['shell.open_menu'] })
await menu.focus()
await page.keyboard.press('Enter')
const drawer = page.getByRole('dialog', { name: dict['shell.nav_label'] })
await expect(drawer).toBeVisible()
await expectNoHorizontalOverflow(page, state)
await page.keyboard.press('Escape')
await expect(drawer).toBeHidden()
await expect(menu).toBeFocused()
}
for (const [locale, dict] of LANGUAGES) {
test.describe(`responsive (${locale})`, () => {
test.use({ locale: locale === 'fr' ? 'fr-FR' : 'en-GB' })
test.beforeEach(async ({ context }) => {
await routeToSandbox(context)
})
test.afterEach(async ({ context }) => {
await dropLateReplays(context)
})
test('no sideways scroll on the shell pages, dialogs and drawer, long values', async ({
page,
requests,
}, info) => {
test.setTimeout(240_000)
const account = await createAccount(locale, true, LONG.localPart)
requests.forbid(account.email, account.password, account.displayName)
const client = await seedClient(account, LONG.client, {
email: LONG.clientEmail,
addressLine1: LONG.address,
city: LONG.city,
phone: '+33639980001',
})
const structure = await seedClient(account, LONG.structure, {
kind: 'organization',
city: LONG.city,
})
const animal = await seedAnimal(account, LONG.animal)
await seedRelation(account, animal, client, 'owner', '2024-01-01')
await seedRelation(account, animal, structure, 'keeper', '2024-02-01')
await signIn(page, account, dict)
const pages = [
'/app',
'/app/clients',
'/app/clients/new',
`/app/clients/${client}`,
`/app/clients/${client}/edit`,
'/app/animals',
'/app/animals/new',
`/app/animals/${animal}`,
`/app/animals/${animal}/edit`,
]
const widths = isPhone(info) ? PHONE_WIDTHS : [page.viewportSize()!.width]
for (const width of widths) {
await page.setViewportSize({ width, height: 667 })
for (const path of pages) {
await open(page, path)
const state = `${path.replace(/[0-9a-f-]{36}/, ':id')} at ${width} px`
await expectNoHorizontalOverflow(page, state)
if (path === '/app') await expectWholeEmail(page, account.email, state)
if (path === `/app/clients/${client}`)
await checkConfirmation(
page,
dict['clients.detail.archive'],
dict['clients.archive.title'],
`the client archive confirmation at ${width} px`,
)
if (path === `/app/animals/${animal}`)
await checkConfirmation(
page,
dict['animals.detail.archive'],
dict['animals.archive.title'],
`the animal archive confirmation at ${width} px`,
)
}
if (isPhone(info)) {
await open(page, '/app/clients')
await checkDrawer(page, dict, `the open drawer at ${width} px`)
}
}
})
})
}
+6 -2
View File
@@ -15,6 +15,8 @@ export interface ClientSeed {
kind?: 'person' | 'organization'
city?: string | null
phone?: string | null
email?: string | null
addressLine1?: string | null
}
export async function seedClient(
@@ -23,9 +25,11 @@ export async function seedClient(
seed: ClientSeed = {},
): Promise<string> {
const ws = await workspaceOf(account)
return sql(`insert into public.clients (workspace_id, kind, display_name, city, phone, create_request_id, create_request_digest)
return sql(`insert into public.clients (workspace_id, kind, display_name, city, phone, email, address_line1,
create_request_id, create_request_digest)
values (${literal(ws)}, ${literal(seed.kind ?? 'person')}, ${literal(displayName)}, ${literal(seed.city ?? null)},
${literal(seed.phone ?? null)}, gen_random_uuid(), '\\x00') returning id`)
${literal(seed.phone ?? null)}, ${literal(seed.email ?? null)}, ${literal(seed.addressLine1 ?? null)},
gen_random_uuid(), '\\x00') returning id`)
}
export async function seedAnimal(
+6 -2
View File
@@ -96,14 +96,18 @@ async function seedAvatar(ownerId: string): Promise<void> {
'image/webp', ${AVATAR_WEBP.length}, ${AVATAR_WEBP.length}, '${sha256}')`)
}
/** A confirmed fictitious account, its profile in `locale`, with or without a photo. */
/**
* A confirmed fictitious account, its profile in `locale`, with or without a
* photo; `localPart` starts the address (a long one tests narrow screens).
*/
export async function createAccount(
locale: 'fr' | 'en',
withAvatar: boolean,
localPart = 'e2e-shell',
): Promise<SandboxAccount> {
const tag = randomUUID().slice(0, 8)
const account = {
email: `e2e-shell-${tag}@sandbox.local`,
email: `${localPart}-${tag}@sandbox.local`,
password: randomBytes(18).toString('base64url'),
displayName: `Praticienne Fictive ${tag}`,
}
@@ -87,8 +87,9 @@ function AccountCard() {
<h2 className="font-serif text-xl">{t('dashboard.account.title')}</h2>
<dl className="grid gap-2 text-sm">
<div className="flex justify-between gap-4">
<dt className="text-[var(--color-ink-muted)]">{t('dashboard.account.email')}</dt>
<dd className="truncate">{user?.email}</dd>
<dt className="shrink-0 text-[var(--color-ink-muted)]">{t('dashboard.account.email')}</dt>
{/* An address longer than the card wraps: never cut, never wider than the screen. */}
<dd className="min-w-0 text-right [overflow-wrap:anywhere]">{user?.email}</dd>
</div>
<div className="flex items-center justify-end gap-1.5 text-[var(--color-ink-muted)]">
<Icon name={verified ? 'check' : 'alert'} size={16} />
@@ -126,7 +127,8 @@ export default function DashboardRoute() {
{t('dashboard.intro')}
</p>
</header>
<div className="grid gap-4 md:grid-cols-2">
{/* One explicit column below md: an implicit track would grow to the cards' content. */}
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
<ProfileCard missing={missing} />
<ToolCard />
<AccountCard />