Skip to content

Commit

Permalink
test(button): add secondary variant darkmode and lightmode screenshot…
Browse files Browse the repository at this point in the history
… tests (#900)

* test(button): move existing secondary test to unspecified

* test(button): add primary and secondary mode variant tests for secondary variant

* test(button): refactor secondary variant tests to use beforeEach for page navigation

* test(button): add padding for new secondary variant tests

* test(button): fix imports of css variables for secondary variant

* test(button): improve structure for secondary variant
  • Loading branch information
max-umain authored Dec 16, 2024
1 parent e5cef39 commit 34583ce
Show file tree
Hide file tree
Showing 15 changed files with 169 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/button/test/secondary/primary/darkmode/index.html';

test.describe.parallel('tds-button-secondary-primary-darkmode', () => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('renders secondary button correctly', async ({ page }) => {
const button = page.getByTestId('tds-button-testid');
await expect(button).toHaveCount(1);

/* 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
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Button - Secondary</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); padding: 20px">
<tds-button
text="Button"
variant="secondary"
mode-variant="primary"
size="md"
data-testid="tds-button-testid"
></tds-button>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/button/test/secondary/primary/lightmode/index.html';

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

test('renders secondary button correctly', async ({ page }) => {
const button = page.getByTestId('tds-button-testid');
await expect(button).toHaveCount(1);

/* 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
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Button - Secondary</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 style="padding: 20px">
<tds-button
text="Button"
variant="secondary"
mode-variant="primary"
size="md"
data-testid="tds-button-testid"
></tds-button>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/button/test/secondary/secondary/darkmode/index.html';

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

test('renders secondary button correctly', async ({ page }) => {
const button = page.getByTestId('tds-button-testid');
await expect(button).toHaveCount(1);

/* 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
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Button - Secondary</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-900); padding: 20px">
<tds-button
text="Button"
variant="secondary"
mode-variant="secondary"
size="md"
data-testid="tds-button-testid"
></tds-button>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/button/test/secondary/secondary/lightmode/index.html';

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

test('renders secondary button correctly', async ({ page }) => {
const button = page.getByTestId('tds-button-testid');
await expect(button).toHaveCount(1);

/* 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
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Button - Secondary</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 style="background-color: var(--tds-grey-50); padding: 20px">
<tds-button
text="Button"
variant="secondary"
mode-variant="secondary"
size="md"
data-testid="tds-button-testid"
></tds-button>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/button/test/secondary/index.html';
const componentTestPath = 'src/components/button/test/secondary/unspecified/index.html';

test.describe.parallel('tds-button-secondary', () => {
test('renders secondary button correctly', async ({ page }) => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('renders secondary button correctly', async ({ page }) => {
const button = page.getByTestId('tds-button-testid');
await expect(button).toHaveCount(1);

Expand All @@ -14,7 +17,6 @@ test.describe.parallel('tds-button-secondary', () => {
});

test('Check so that height is correct to md measurements', async ({ page }) => {
await page.goto(componentTestPath);
const button = page.getByText('Button', { exact: true });
const buttonHeight = await button.evaluate((style) => getComputedStyle(style).height);
expect(buttonHeight).toBe('48px');
Expand Down

0 comments on commit 34583ce

Please sign in to comment.