From 9679b561179ded645f9508669bc62d8a40ec9aa5 Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev Date: Mon, 7 Sep 2026 23:41:57 +0300 Subject: [PATCH] chore: add test to check each admin screen doesn't skip heading levels --- tests/e2e/admin-screen-headings.spec.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/e2e/admin-screen-headings.spec.ts b/tests/e2e/admin-screen-headings.spec.ts index b658b18f9..f0031607b 100644 --- a/tests/e2e/admin-screen-headings.spec.ts +++ b/tests/e2e/admin-screen-headings.spec.ts @@ -16,12 +16,27 @@ const SCREENS = [ { name: 'Welcome', url: URLS.WELCOME_SCREEN_ADMIN } ] -test.describe('Admin screen h1 headings', () => { +test.describe('Admin screen headings', () => { for (const screen of SCREENS) { - test(`${screen.name} renders one page heading`, async ({ page }) => { + test(`${screen.name} renders one h1 heading`, async ({ page }) => { await page.goto(screen.url) await expect(page.getByRole('heading', { level: 1 })).toHaveCount(EXPECTED_H1_HEADING_COUNT) }) + + test(`${screen.name} does not skip heading levels`, async ({ page }) => { + await page.goto(screen.url) + + const headingLevels = await page.getByRole('heading').evaluateAll(headings => + headings.map(heading => Number(heading.getAttribute('aria-level') ?? heading.tagName.slice(1))) + ) + + for (let index = 1; index < headingLevels.length; index++) { + expect( + headingLevels[index], + `${screen.name} skips from h${headingLevels[index - 1]} to h${headingLevels[index]}` + ).toBeLessThanOrEqual(headingLevels[index - 1] + 1) + } + }) } })