From 47061765184aec05c5c1f7d0eb5f440320202a81 Mon Sep 17 00:00:00 2001 From: Max Skanvik <179694889+max-umain@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:41:19 +0100 Subject: [PATCH] test(breadcrumbs): refactor tests to use beforeEach for page navigation --- .../breadcrumbs/test/default/darkmode/breadcrumbs.e2e.ts | 6 +++--- .../breadcrumbs/test/default/lightmode/breadcrumbs.e2e.ts | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/core/src/components/breadcrumbs/test/default/darkmode/breadcrumbs.e2e.ts b/packages/core/src/components/breadcrumbs/test/default/darkmode/breadcrumbs.e2e.ts index d93b0db46..858fb1f6f 100644 --- a/packages/core/src/components/breadcrumbs/test/default/darkmode/breadcrumbs.e2e.ts +++ b/packages/core/src/components/breadcrumbs/test/default/darkmode/breadcrumbs.e2e.ts @@ -4,16 +4,16 @@ import { expect } from '@playwright/test'; const componentTestPath = 'src/components/breadcrumbs/test/default/darkmode/index.html'; test.describe.parallel('tds-breadcrumbs-default-darkmode', () => { - test('renders default breadcrumbs correctly', async ({ page }) => { + test.beforeEach(async ({ page }) => { await page.goto(componentTestPath); + }); + test('renders default breadcrumbs correctly', async ({ page }) => { /* Check diff on screenshot */ await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); }); test('page 3 item should be able to become focused', async ({ page }) => { - await page.goto(componentTestPath); - const pageThree = page.getByText(/Page 3/); await pageThree.focus(); diff --git a/packages/core/src/components/breadcrumbs/test/default/lightmode/breadcrumbs.e2e.ts b/packages/core/src/components/breadcrumbs/test/default/lightmode/breadcrumbs.e2e.ts index a3631736d..667c6101d 100644 --- a/packages/core/src/components/breadcrumbs/test/default/lightmode/breadcrumbs.e2e.ts +++ b/packages/core/src/components/breadcrumbs/test/default/lightmode/breadcrumbs.e2e.ts @@ -4,15 +4,16 @@ import { expect } from '@playwright/test'; const componentTestPath = 'src/components/breadcrumbs/test/default/lightmode/index.html'; test.describe.parallel('tds-breadcrumbs-default-lightmode', () => { - test('renders default breadcrumbs correctly', async ({ page }) => { + test.beforeEach(async ({ page }) => { await page.goto(componentTestPath); + }); + test('renders default breadcrumbs correctly', async ({ page }) => { /* Check diff on screenshot */ await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); }); test('items Page 1, Page 2, Page 3 exist on the page', async ({ page }) => { - await page.goto(componentTestPath); const navigation = page.getByRole('navigation'); await expect(navigation).toHaveCount(1); const listItems = page.getByRole('listitem'); @@ -32,8 +33,6 @@ test.describe.parallel('tds-breadcrumbs-default-lightmode', () => { }); test('page 3 item should be able to become focused', async ({ page }) => { - await page.goto(componentTestPath); - const pageThree = page.getByText(/Page 3/); await pageThree.focus();