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:
1 parent
dd5a23c39d
commit
a70166ea11
4 files changed
+179
-7
No files matched your search
@@ -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`)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user