Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(accordion): add darkmode and lightmode screenshot tests #895

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/accordion/test/basic/primary/darkmode/index.html';
const accordionSelector = 'tds-accordion';

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

test('renders basic accordion correctly with primary mode variant and darkmode', async ({
page,
}) => {
// Define selector for accordion
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
await expect(accordion).toContainText('First item');
await expect(accordion).toContainText('Second item');

// Check screenshot diff to make sure the accordion is rendered correctly
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});

test('second accordion item opens on click', async ({ page }) => {
// Define selector for second accordion item
const accordionSecondItem = page.getByText('Second item');

// Hover second accordion item
await accordionSecondItem.click();

// Check screenshot diff to make sure the second accordion item is open
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,28 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Accordion - Basic</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-accordion>
<tds-accordion-item header="First item">
This is the panel, which contains associated information with the header. Usually it
contains text, set in the same size as the header. Lorem ipsum doler sit amet.
</tds-accordion-item>
<tds-accordion-item>
<div slot="header">Second item</div>
This is the panel, which contains associated information with the header. Usually it
contains text, set in the same size as the header. Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Duis laoreet vestibulum fermentum.
</tds-accordion-item>
</tds-accordion>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/accordion/test/basic/primary/lightmode/index.html';
const accordionSelector = 'tds-accordion';

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

test('renders basic accordion correctly with primary mode variant and lightmode', async ({
page,
}) => {
// Define selector for accordion
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
await expect(accordion).toContainText('First item');
await expect(accordion).toContainText('Second item');

// Check screenshot diff to make sure the accordion is rendered correctly
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});

test('second accordion item opens on click', async ({ page }) => {
// Define selector for second accordion item
const accordionSecondItem = page.getByText('Second item');

// Hover second accordion item
await accordionSecondItem.click();

// Check screenshot diff to make sure the second accordion item is open
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Accordion - Basic</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>
<tds-accordion>
<tds-accordion-item header="First item">
This is the panel, which contains associated information with the header. Usually it
contains text, set in the same size as the header. Lorem ipsum doler sit amet.
</tds-accordion-item>
<tds-accordion-item>
<div slot="header">Second item</div>
This is the panel, which contains associated information with the header. Usually it
contains text, set in the same size as the header. Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Duis laoreet vestibulum fermentum.
</tds-accordion-item>
</tds-accordion>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/accordion/test/basic/secondary/darkmode/index.html';
const accordionSelector = 'tds-accordion';

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

test('renders basic accordion correctly with secondary mode variant and darkmode', async ({
page,
}) => {
// Define selector for accordion
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
await expect(accordion).toContainText('First item');
await expect(accordion).toContainText('Second item');

// Check screenshot diff to make sure the accordion is rendered correctly
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});

test('second accordion item opens on click', async ({ page }) => {
// Define selector for second accordion item
const accordionSecondItem = page.getByText('Second item');

// Hover second accordion item
await accordionSecondItem.click();

// Check screenshot diff to make sure the second accordion item is open
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,28 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Accordion - Basic</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-accordion mode-variant="secondary">
<tds-accordion-item header="First item">
This is the panel, which contains associated information with the header. Usually it
contains text, set in the same size as the header. Lorem ipsum doler sit amet.
</tds-accordion-item>
<tds-accordion-item>
<div slot="header">Second item</div>
This is the panel, which contains associated information with the header. Usually it
contains text, set in the same size as the header. Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Duis laoreet vestibulum fermentum.
</tds-accordion-item>
</tds-accordion>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/accordion/test/basic/secondary/lightmode/index.html';
const accordionSelector = 'tds-accordion';

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

test('renders basic accordion correctly with secondary mode variant and lightmode', async ({
page,
}) => {
// Define selector for accordion
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
await expect(accordion).toContainText('First item');
await expect(accordion).toContainText('Second item');

// Check screenshot diff to make sure the accordion is rendered correctly
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});

test('second accordion item opens on click', async ({ page }) => {
// Define selector for second accordion item
const accordionSecondItem = page.getByText('Second item');

// Hover second accordion item
await accordionSecondItem.click();

// Check screenshot diff to make sure the second accordion item is open
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,28 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Accordion - Basic</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-accordion mode-variant="secondary">
<tds-accordion-item header="First item">
This is the panel, which contains associated information with the header. Usually it
contains text, set in the same size as the header. Lorem ipsum doler sit amet.
</tds-accordion-item>
<tds-accordion-item>
<div slot="header">Second item</div>
This is the panel, which contains associated information with the header. Usually it
contains text, set in the same size as the header. Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Duis laoreet vestibulum fermentum.
</tds-accordion-item>
</tds-accordion>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/accordion/test/basic/index.html';
const componentTestPath = 'src/components/accordion/test/basic/unspecified/index.html';
const accordionSelector = 'tds-accordion';

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

test('renders basic accordion correctly', async ({ page }) => {
// Define selector for accordion
await page.goto(componentTestPath);
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
Expand All @@ -20,7 +23,6 @@ test.describe.parallel('tds-accordion', () => {

test('should handle hover on accordion items', async ({ page }) => {
// Define selector for first accordion item
await page.goto(componentTestPath);
const accordionFirstItem = page.getByText('First item');

// Hover first accordion item
Expand All @@ -42,7 +44,6 @@ test.describe.parallel('tds-accordion', () => {

test('second accordion item opens on click', async ({ page }) => {
// Define selector for second accordion item
await page.goto(componentTestPath);
const accordionSecondItem = page.getByText('Second item');

// Hover second accordion item
Expand All @@ -54,7 +55,6 @@ test.describe.parallel('tds-accordion', () => {

test('fires tdsToggle event on click', async ({ page }) => {
// Define selector for first accordion item
await page.goto(componentTestPath);
const accordionFirstItem = page.getByText('First item');

// Define selector for second accordion item
Expand Down
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
Expand Up @@ -5,9 +5,12 @@ const componentTestPath = 'src/components/accordion/test/disabled/index.html';
const accordionSelector = 'tds-accordion';

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

test('renders disabled accordion correctly', async ({ page }) => {
// Define selector for accordion
await page.goto(componentTestPath);
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
Expand All @@ -20,7 +23,6 @@ test.describe.parallel('tds-accordion', () => {

test('disabled accordion items should be displayed', async ({ page }) => {
// Define selector for first accordion item
await page.goto(componentTestPath);
const accordionFirstItem = page.locator(accordionSelector + '>> text=First item');

// Expect first accordion item to be disabled
Expand All @@ -40,7 +42,6 @@ test.describe.parallel('tds-accordion', () => {

test('cursor should be not-allowed on disabled accordion items', async ({ page }) => {
// Define selector for first accordion item
await page.goto(componentTestPath);
const accordionFirstItem = page.getByTestId('first-item');
const accordionFirstItemButton = accordionFirstItem.getByRole('button');

Expand Down Expand Up @@ -68,7 +69,6 @@ test.describe.parallel('tds-accordion', () => {

test('does not fire tdsToggle event on click on disabled accordion', async ({ page }) => {
// Define selector for first accordion item
await page.goto(componentTestPath);
const accordionFirstItem = page.getByText('First item');

// Click first accordion item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ const componentTestPath = 'src/components/accordion/test/hide-last-border/index.
const accordionSelector = 'tds-accordion';

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

test('renders accordion with hidden last border correctly', async ({ page }) => {
// Define selector for accordion
await page.goto(componentTestPath);
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
Expand Down
Loading