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(dark-light-modes): reusable test code #934

Merged
merged 37 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4ff76ba
test: add testConfiguration file with reusable test code
max-umain Dec 18, 2024
d4867a6
test: change testConfiguration function parameter name
max-umain Dec 18, 2024
600156d
test: remove undefined test configuration from testConfiguration.ts
max-umain Jan 14, 2025
c9bb524
test: improve setupPage and getTestDescribeText
max-umain Jan 14, 2025
ad0d938
test(tooltip): add screenshot tests using reusable test code (#960)
max-umain Jan 15, 2025
50b63d3
test(toggle): add screenshot tests using reusable test code (#959)
max-umain Jan 15, 2025
f9b0a26
test(slider): add screenshot tests using reusable test code (#953)
max-umain Jan 15, 2025
d47951b
test(toast): add screenshot tests using reusable test code (#958)
max-umain Jan 15, 2025
e3b69e6
test(textarea): add screenshot tests using reusable test code (#957)
max-umain Jan 15, 2025
e1152b3
test(text-field): add screenshot tests using reusable test code (#956)
max-umain Jan 15, 2025
243c433
test(side-menu): add screenshot tests using reusable test code (#952)
max-umain Jan 15, 2025
ef7fe4f
test(radio-button): add screenshot tests using reusable test code (#951)
max-umain Jan 15, 2025
93b2eb4
test(popover menu): add screenshot tests using reusable test code (#950)
max-umain Jan 15, 2025
576a95d
test(popover-canvas): add screenshot tests using reusable test code (…
max-umain Jan 15, 2025
155cab8
test(message): add screenshot tests using reusable test code (#948)
max-umain Jan 15, 2025
94c199a
test(chip): add screenshot tests using reusable test code (#947)
max-umain Jan 15, 2025
3a8a595
test(link): add screenshot tests using reusable test code (#946)
max-umain Jan 15, 2025
a53bb28
test(header): add screenshot tests using reusable test code (#945)
max-umain Jan 15, 2025
9acfb01
test(footer): add screenshot tests using reusable test code (#944)
max-umain Jan 15, 2025
9449046
test(dropdown): improved and added more screenshot tests with reusabl…
max-umain Jan 15, 2025
982add2
test(datetime): update and improve lightmode and darkmode screenshot …
max-umain Jan 15, 2025
668410f
test(checkbox): more and improved screenshot tests using reusable tes…
max-umain Jan 15, 2025
ee076ff
test(card): use reusable test code for lightmode and darkmode screens…
max-umain Jan 15, 2025
762e650
test(button): new and improved screenshot tests with reusable test co…
max-umain Jan 15, 2025
eb22ec7
test(breadcrumbs): improved screenshot tests with reusable code (#937)
max-umain Jan 15, 2025
6dad389
test(banner): improved and more screenshot tests with reusable code (…
max-umain Jan 15, 2025
8291c37
test(accordion): more screenshot tests with reusable code (#935)
max-umain Jan 15, 2025
bf6a5c2
test(tabs): add screenshot tests using reusable test code (#955)
max-umain Jan 15, 2025
3852406
test(table): add screenshot tests using reusable test code (#954)
max-umain Jan 15, 2025
5dd86ed
test: make testConfiguration.ts more general
max-umain Jan 20, 2025
7456df0
test(stepper): add screenshot tests using reusable test code (#971)
max-umain Jan 21, 2025
e01d186
test(modal): add screenshot tests using reusable test code (#970)
max-umain Jan 21, 2025
5be94f0
test(divider): add screenshot tests using reusable test code (#969)
max-umain Jan 21, 2025
74e30b7
test(block): add screenshot tests using reusable test code (#968)
max-umain Jan 22, 2025
a7d5087
test(spinner): add screenshot tests using reusable test code (#972)
max-umain Jan 27, 2025
05701fc
Merge branch 'develop' into test/reusable-code-for-tests
max-umain Jan 27, 2025
c25c1a5
test(dropdown): update screenshots
max-umain Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,26 +1,53 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import {
getTestDescribeText,
setupPage,
testConfigurations,
} from '../../../../utils/testConfiguration';

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

test.describe.parallel('tds-accordion', () => {
test('renders basic accordion correctly', async ({ page }) => {
// Define selector for accordion
await page.goto(componentTestPath);
const accordion = page.locator(accordionSelector);
testConfigurations.withModeVariants.forEach((config) => {
test.describe.parallel(getTestDescribeText(config, componentName), () => {
test.beforeEach(async ({ page }) => {
await setupPage(page, config, componentTestPath, componentName);
});

test('renders basic accordion correctly', 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 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 });
});

// 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 });
});
});
});

test.describe.parallel(componentName, () => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

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 @@ -40,25 +67,11 @@ test.describe.parallel('tds-accordion', () => {
await expect(accordionSecondItem).toHaveCSS('cursor', 'pointer');
});

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
await accordionSecondItem.click();

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

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
await page.goto(componentTestPath);
const accordionSecondItem = page.getByText('Second item');

// Click first 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.
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.
Binary file not shown.
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.
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
@@ -1,33 +1,48 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import {
getTestDescribeText,
setupPage,
testConfigurations,
} from '../../../../utils/testConfiguration';

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

test.describe.parallel('tds-accordion', () => {
test('renders disabled accordion correctly', async ({ page }) => {
// Define selector for accordion
await page.goto(componentTestPath);
const accordion = page.locator(accordionSelector);
testConfigurations.withModeVariants.forEach((config) => {
test.describe.parallel(getTestDescribeText(config, componentName), () => {
test.beforeEach(async ({ page }) => {
await setupPage(page, config, componentTestPath, componentName);
});

test('renders disabled accordion correctly', 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 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 });
});
});
});

// Check screenshot diff to make sure the accordion is rendered correctly
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
test.describe.parallel(componentName, () => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

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
await expect(accordionFirstItem).toBeDisabled();

// Define selector for second accordion item
await page.goto(componentTestPath);
const accordionSecondItem = page.getByTestId('second-item');

// Define selector for second accordion item button since
Expand All @@ -40,7 +55,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 All @@ -53,7 +67,6 @@ test.describe.parallel('tds-accordion', () => {
await expect(accordionCursorFirstItem).toBe('not-allowed');

// Define selector for second accordion item
await page.goto(componentTestPath);
const accordionSecondItem = page.getByTestId('second-item');
const accordionSecondItemButton = accordionSecondItem.getByRole('button');

Expand All @@ -68,7 +81,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
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.
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
@@ -1,20 +1,31 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import {
getTestDescribeText,
setupPage,
testConfigurations,
} from '../../../../utils/testConfiguration';

const componentTestPath = 'src/components/accordion/test/hide-last-border/index.html';
const accordionSelector = 'tds-accordion';
const componentName = 'tds-accordion';

test.describe.parallel('tds-accordion', () => {
test('renders accordion with hidden last border correctly', async ({ page }) => {
// Define selector for accordion
await page.goto(componentTestPath);
const accordion = page.locator(accordionSelector);
testConfigurations.withModeVariants.forEach((config) => {
test.describe.parallel(getTestDescribeText(config, componentName), () => {
test.beforeEach(async ({ page }) => {
await setupPage(page, config, componentTestPath, componentName);
});

// Check if accordion contains the correct text
await expect(accordion).toContainText('First item');
await expect(accordion).toContainText('Second item');
test('renders accordion with hidden last border correctly', async ({ page }) => {
// Define selector for accordion
const accordion = page.locator(accordionSelector);

// Check screenshot diff to make sure the accordion is rendered correctly
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
// 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 });
});
});
});
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.
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
@@ -1,18 +1,33 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import {
getTestDescribeText,
setupPage,
testConfigurations,
} from '../../../../utils/testConfiguration';

const componentTestPath = 'src/components/banner/test/default/index.html';
const componentName = 'tds-banner';
const testDescription = 'tds-banner-default';

testConfigurations.basic.forEach((config) => {
test.describe.parallel(getTestDescribeText(config, testDescription), () => {
test.beforeEach(async ({ page }) => {
await setupPage(page, config, componentTestPath, componentName);
});

test('renders default banner correctly', async ({ page }) => {
/* Check diff on screenshot */
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});
});
});

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

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

test('renders default banner correctly', async ({ page }) => {
/* Check diff on screenshot */
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});

test('header exists', async ({ page }) => {
const bannerHeader = page.getByText('This is a header text area', { exact: true });
await expect(bannerHeader).toBeVisible();
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.

This file was deleted.

Binary file not shown.
Binary file not shown.
35 changes: 35 additions & 0 deletions packages/core/src/components/banner/test/error/banner.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import {
getTestDescribeText,
setupPage,
testConfigurations,
} from '../../../../utils/testConfiguration';

const componentTestPath = 'src/components/banner/test/error/index.html';
const componentName = 'tds-banner';
const testDescription = 'tds-banner-error';

testConfigurations.basic.forEach((config) => {
test.describe.parallel(getTestDescribeText(config, testDescription), () => {
test.beforeEach(async ({ page }) => {
await setupPage(page, config, componentTestPath, componentName);
});

test('renders error banner correctly', async ({ page }) => {
/* Check diff on screenshot */
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});
});
});

test.describe.parallel(componentName, () => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('icons exists', async ({ page }) => {
const images = page.getByRole('img');
await expect(images).toHaveCount(2);
});
});
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.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import {
getTestDescribeText,
setupPage,
testConfigurations,
} from '../../../../utils/testConfiguration';

const componentTestPath = 'src/components/banner/test/information/index.html';
const componentName = 'tds-banner';
const testDescription = 'tds-banner-information';

testConfigurations.basic.forEach((config) => {
test.describe.parallel(getTestDescribeText(config, testDescription), () => {
test.beforeEach(async ({ page }) => {
await setupPage(page, config, componentTestPath, componentName);
});

test('renders information banner correctly', async ({ page }) => {
/* Check diff on screenshot */
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});

test('icons exists', async ({ page }) => {
const images = page.getByRole('img');
await expect(images).toHaveCount(2);
});
});
});

This file was deleted.

Diff not rendered.
Loading