Skip to content

Commit

Permalink
test(breadcrumbs): refactor tests to use beforeEach for page navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
max-umain committed Dec 12, 2024
1 parent 07183c4 commit 4706176
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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();

Expand Down

0 comments on commit 4706176

Please sign in to comment.