Skip to content

Commit

Permalink
test(divider): refactor and update horizontal screenshot tests (#912)
Browse files Browse the repository at this point in the history
* test(divider): refactor and update existing horizontal lightmode and darkmode tests

* test(divider): refactor tests to use beforeEach for page navigation
  • Loading branch information
max-umain authored Dec 16, 2024
1 parent 5968ca7 commit e5cef39
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/divider/test/darkmode/index.html';
const componentTestPath = 'src/components/divider/test/horizontal/darkmode/index.html';

test.describe.parallel('tds-divider', () => {
test('expect to render a divider in darkmode', async ({ page }) => {
test.describe.parallel('tds-divider-darkmode', () => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('expect to render a divider in darkmode', async ({ page }) => {
/* Check diff on screenshot */
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});
Expand Down
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
Expand Up @@ -2,16 +2,16 @@
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Divider - Horizontal, dark mode</title>
<title>Divider - Horizontal, darkmode</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
<link rel="stylesheet" href="../../../../../dist/tegel/tegel.css" />
<link rel="stylesheet" href="../../../../../../dist/tegel/tegel.css" />
<script type="module">
import { defineCustomElements } from '../../../../../loader/index.es2017.js';
import { defineCustomElements } from '../../../../../../loader/index.es2017.js';
defineCustomElements();
</script>
</head>

<body class="tds-mode-dark" style="padding: 20px; height: 300px;">
<body class="tds-mode-dark" style="background-color: var(--tds-grey-958); padding: 20px">
<tds-divider data-testid="divider"></tds-divider>
</body>
</html>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/divider/test/horizontal/lightmode/index.html';

test.describe.parallel('tds-divider-lightmode', () => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('expect to render a divider in lightmode', async ({ page }) => {
/* 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.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Divider - Horizontal</title>
<title>Divider - Horizontal, lightmode</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
<link rel="stylesheet" href="../../../../../dist/tegel/tegel.css" />
<link rel="stylesheet" href="../../../../../../dist/tegel/tegel.css" />
<script type="module">
import { defineCustomElements } from '../../../../../loader/index.es2017.js';
import { defineCustomElements } from '../../../../../../loader/index.es2017.js';
defineCustomElements();
</script>
</head>

<body style="padding: 20px; width: 300px;">
<body style="padding: 20px">
<tds-divider data-testid="divider"></tds-divider>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { expect } from '@playwright/test';
const componentTestPath = 'src/components/divider/test/vertical/index.html';

test.describe.parallel('tds-divider', () => {
test('expect to render a vertical divider', async ({ page }) => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('expect to render a vertical divider', async ({ page }) => {
// expect height to be greater than width
const divider = page.getByTestId('divider').locator('div.divider').first();
const box = await divider.boundingBox();
Expand Down

0 comments on commit e5cef39

Please sign in to comment.