Skip to content

test(slider): add darkmode screenshot tests and refactor folder structure #923

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

Closed
wants to merge 2 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,17 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Slider 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); padding: 20px">
<tds-slider min="0" max="100" value="50" tooltip thumb-size="lg"></tds-slider>
</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/slider/test/default/darkmode/index.html';

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

test('renders default slider correctly', async ({ page }) => {
const slider = page.locator('tds-slider');
await expect(slider).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
Expand Up @@ -4,9 +4,9 @@
<meta charset="UTF-8" />
<title>Slider 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" />
<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>
Expand Down
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/slider/test/default/index.html';
const componentTestPath = 'src/components/slider/test/default/lightmode/index.html';

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

test('renders default slider correctly', async ({ page }) => {
const slider = page.locator('tds-slider');
await expect(slider).toHaveCount(1);

Expand All @@ -14,13 +17,11 @@ test.describe.parallel('tds-slider-default', () => {
});

test('value is set to 50', async ({ page }) => {
await page.goto(componentTestPath);
const sliderValue = page.locator('.tds-slider__value');
await expect(sliderValue).toHaveText('50');
});

test('min value is set to 0', async ({ page }) => {
await page.goto(componentTestPath);
/* Find thumb and pull it towards a left and check if min value is 0 */
await page.locator('.tds-slider__thumb-inner').hover();
await page.mouse.down();
Expand All @@ -33,7 +34,6 @@ test.describe.parallel('tds-slider-default', () => {
});

test('max value is set to 100', async ({ page }) => {
await page.goto(componentTestPath);
/* Find thumb and pull it towards a right and check if min value is 0 */
await page.locator('.tds-slider__thumb-inner').hover();
await page.mouse.down();
Expand All @@ -46,15 +46,12 @@ test.describe.parallel('tds-slider-default', () => {
});

test('label is hidden', async ({ page }) => {
await page.goto(componentTestPath);
const slider = page.locator('tds-slider');
const sliderLabel = slider.locator('label');
await expect(sliderLabel).toHaveText('');
});

test('slider is not read only or disabled', async ({ page }) => {
await page.goto(componentTestPath);

/* Find thumb and pull it towards a left and check if value in thumb is changing */
await page.locator('.tds-slider__thumb-inner').hover();
await page.mouse.down();
Expand All @@ -67,7 +64,6 @@ test.describe.parallel('tds-slider-default', () => {
});

test('thumb is size large', async ({ page }) => {
await page.goto(componentTestPath);
const sliderThumb = page.locator('.tds-slider__thumb-inner');
const sliderThumbWidth = await sliderThumb.evaluate((style) => getComputedStyle(style).width);
const sliderThumbHeight = await sliderThumb.evaluate((style) => getComputedStyle(style).height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/slider/test/disabled/index.html';

test.describe.parallel('tds-slider-disabled', () => {
test('read-only is false', async ({ page }) => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('read-only is false', async ({ page }) => {
const slider = page.locator('tds-slider');
await expect(slider).not.toHaveAttribute('read-only');
});

test('slider is disabled', async ({ page }) => {
await page.goto(componentTestPath);
const slider = page.locator('tds-slider input');
const sliderThumb = page.locator('.tds-slider__thumb');
const sliderCursorStyle = await sliderThumb.evaluate((style) => getComputedStyle(style).cursor);
Expand All @@ -21,7 +24,6 @@ test.describe.parallel('tds-slider-disabled', () => {
});

test('slider can not be clicked on', async ({ page }) => {
await page.goto(componentTestPath);
const sliderThumb = page.locator('.tds-slider__thumb-inner');
const sliderPointerEvents = await sliderThumb.evaluate(
(style) => getComputedStyle(style).pointerEvents,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';

const componentTestPath = 'src/components/slider/test/read-only/index.html';

test.describe.parallel('tds-slider-read-only', () => {
test('read-only is true', async ({ page }) => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('read-only is true', async ({ page }) => {
const slider = page.locator('tds-slider');
await expect(slider).toHaveAttribute('read-only');
});

test('is not disabled', async ({ page }) => {
await page.goto(componentTestPath);
const sliderThumb = page.locator('.tds-slider__thumb-inner');
const sliderCursorStyle = await sliderThumb.evaluate((style) => getComputedStyle(style).cursor);
expect(sliderCursorStyle).toBe('pointer');
Expand All @@ -19,7 +22,6 @@ test.describe.parallel('tds-slider-read-only', () => {
});

test('slider can not be clicked on', async ({ page }) => {
await page.goto(componentTestPath);
const sliderThumb = page.locator('.tds-slider__thumb-inner');
const sliderThumbStyle = await sliderThumb.evaluate(
(style) => getComputedStyle(style).pointerEvents,
Expand Down
Loading