Skip to content

Commit

Permalink
test(breadcrumbs): add darkmode screenshot test and refactor folder s…
Browse files Browse the repository at this point in the history
…tructure (#890)

* test(breadcrumbs): add lightmode and darkmode tests

* test(breadcrumbs): refactor tests to use beforeEach for page navigation

* test(breadcrumbs): fix import of css variables
  • Loading branch information
max-umain authored Dec 16, 2024
1 parent fafe9c7 commit 4b988e3
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/breadcrumbs/test/default/darkmode/index.html';

test.describe.parallel('tds-breadcrumbs-default-darkmode', () => {
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 }) => {
const pageThree = page.getByText(/Page 3/);
await pageThree.focus();

/* Check diff on screenshot */
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Breadcrumbs - Default</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
<link rel="stylesheet" href="../../../../../dist/tegel/tegel.css" />
<script type="module">
import { defineCustomElements } from '../../../../../loader/index.es2017.js';
defineCustomElements();
</script>
</head>

<body class="tds-mode-dark" style="background-color: var(--tds-grey-958)">
<tds-breadcrumbs>
<tds-breadcrumb>
<a href="#">Page 1</a>
</tds-breadcrumb>
<tds-breadcrumb>
<a href="#">Page 2</a>
</tds-breadcrumb>
<tds-breadcrumb current>
<a href="#">Page 3</a>
</tds-breadcrumb>
</tds-breadcrumbs>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/breadcrumbs/test/default/index.html';
const componentTestPath = 'src/components/breadcrumbs/test/default/lightmode/index.html';

test.describe.parallel('tds-breadcrumbs-default', () => {
test('renders default breadcrumbs correctly', async ({ page }) => {
test.describe.parallel('tds-breadcrumbs-default-lightmode', () => {
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', () => {
});

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 4b988e3

Please sign in to comment.