-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(dropdown): add darkmode and lightmode screenshot tests (#913)
* test(dropdown): move existing default test to unspecified * test(dropdown): add lightmode and darkmode tests for mode variants * test(dropdown): refactor tests to use beforeEach for page navigation
- Loading branch information
Showing
40 changed files
with
470 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/core/src/components/dropdown/test/default/primary/darkmode/dropdown.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { test } from 'stencil-playwright'; | ||
import { expect } from '@playwright/test'; | ||
|
||
const componentTestPath = 'src/components/dropdown/test/default/primary/darkmode/index.html'; | ||
|
||
test.describe.parallel('tds-dropdown-default-primary-darkmode', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(componentTestPath); | ||
}); | ||
|
||
test('renders default dropdown correctly', async ({ page }) => { | ||
const dropdown = page.getByTestId('tds-dropdown-testid'); | ||
await expect(dropdown).toHaveCount(1); | ||
|
||
/* check diff in screenshot */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
|
||
test('clicking the dropdown button opens the dropdown-list', async ({ page }) => { | ||
const dropdownButton = page.getByRole('button', { name: 'Placeholder' }); | ||
const dropdownListElementOne = page | ||
.locator('tds-dropdown-option') | ||
.filter({ hasText: 'Option 1' }); | ||
await expect(dropdownListElementOne).toBeHidden(); | ||
await dropdownButton.click(); | ||
|
||
/* before clicking dropdownlist should not be visible, the button should be */ | ||
await expect(dropdownButton).toBeVisible(); | ||
await expect(dropdownListElementOne).toBeVisible(); | ||
|
||
/* checks diff on screenshot */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
|
||
test('clicking the dropdown opens the dropdown-list, then click Option 1', async ({ page }) => { | ||
/* click the dropdown button */ | ||
const dropdownButton = page.getByRole('button', { name: 'Placeholder' }); | ||
await dropdownButton.click(); | ||
|
||
/* Click the Option 1 button */ | ||
const dropdownListElementOneButton = page | ||
.locator('tds-dropdown-option') | ||
.filter({ hasText: /Option 1/ }) | ||
.getByRole('button'); | ||
await dropdownListElementOneButton.click(); | ||
|
||
await expect(dropdownListElementOneButton).toBeHidden(); | ||
const dropdownButtonWithOption1 = page.getByRole('button', { name: 'Option 1' }); | ||
await expect(dropdownButtonWithOption1.first()).toBeVisible(); | ||
|
||
/* also check screenshot diff to make sure it says Option 1 */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
|
||
test('focusElement() method focus and opens the dropdown-list', async ({ page }) => { | ||
const dropdownButton = page.getByRole('button').first(); | ||
const dropdownListElementOne = page | ||
.locator('tds-dropdown-option') | ||
.filter({ hasText: 'Option 1' }); | ||
await expect(dropdownListElementOne).toBeHidden(); | ||
|
||
await page.evaluate(() => { | ||
const dropdownnew = document.querySelector('tds-dropdown'); | ||
dropdownnew.focusElement(); | ||
}); | ||
|
||
/* before clicking dropdownlist should not be visible, the button should be */ | ||
await expect(dropdownButton).toBeVisible(); | ||
await expect(dropdownListElementOne).toBeVisible(); | ||
|
||
/* checks diff on screenshot */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
}); |
Binary file added
BIN
+7.02 KB
...arkmode-clicking-e1a7e--opens-the-dropdown-list-then-click-Option-1-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11 KB
...imary-darkmode-clicking-the-dropdown-button-opens-the-dropdown-list-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11 KB
...mary-darkmode-focusElement-method-focus-and-opens-the-dropdown-list-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.27 KB
...ropdown-default-primary-darkmode-renders-default-dropdown-correctly-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions
32
packages/core/src/components/dropdown/test/default/primary/darkmode/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Dropdown - 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-dropdown | ||
name="dropdown" | ||
label="Label text" | ||
label-position="outside" | ||
placeholder="Placeholder" | ||
helper="Helper text" | ||
size="lg" | ||
open-direction="auto" | ||
data-testid="tds-dropdown-testid" | ||
mode-variant="primary" | ||
> | ||
<tds-dropdown-option value="option-1">Option 1</tds-dropdown-option> | ||
<tds-dropdown-option disabled value="option-2">Option 2</tds-dropdown-option> | ||
<tds-dropdown-option value="option-3">Option 3</tds-dropdown-option> | ||
<tds-dropdown-option value="option-4">Option 4</tds-dropdown-option> | ||
</tds-dropdown> | ||
</body> | ||
</html> |
74 changes: 74 additions & 0 deletions
74
packages/core/src/components/dropdown/test/default/primary/lightmode/dropdown.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { test } from 'stencil-playwright'; | ||
import { expect } from '@playwright/test'; | ||
|
||
const componentTestPath = 'src/components/dropdown/test/default/primary/lightmode/index.html'; | ||
|
||
test.describe.parallel('tds-dropdown-default-primary-lightmode', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(componentTestPath); | ||
}); | ||
|
||
test('renders default dropdown correctly', async ({ page }) => { | ||
const dropdown = page.getByTestId('tds-dropdown-testid'); | ||
await expect(dropdown).toHaveCount(1); | ||
|
||
/* check diff in screenshot */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
|
||
test('clicking the dropdown button opens the dropdown-list', async ({ page }) => { | ||
const dropdownButton = page.getByRole('button', { name: 'Placeholder' }); | ||
const dropdownListElementOne = page | ||
.locator('tds-dropdown-option') | ||
.filter({ hasText: 'Option 1' }); | ||
await expect(dropdownListElementOne).toBeHidden(); | ||
await dropdownButton.click(); | ||
|
||
/* before clicking dropdownlist should not be visible, the button should be */ | ||
await expect(dropdownButton).toBeVisible(); | ||
await expect(dropdownListElementOne).toBeVisible(); | ||
|
||
/* checks diff on screenshot */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
|
||
test('clicking the dropdown opens the dropdown-list, then click Option 1', async ({ page }) => { | ||
/* click the dropdown button */ | ||
const dropdownButton = page.getByRole('button', { name: 'Placeholder' }); | ||
await dropdownButton.click(); | ||
|
||
/* Click the Option 1 button */ | ||
const dropdownListElementOneButton = page | ||
.locator('tds-dropdown-option') | ||
.filter({ hasText: /Option 1/ }) | ||
.getByRole('button'); | ||
await dropdownListElementOneButton.click(); | ||
|
||
await expect(dropdownListElementOneButton).toBeHidden(); | ||
const dropdownButtonWithOption1 = page.getByRole('button', { name: 'Option 1' }); | ||
await expect(dropdownButtonWithOption1.first()).toBeVisible(); | ||
|
||
/* also check screenshot diff to make sure it says Option 1 */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
|
||
test('focusElement() method focus and opens the dropdown-list', async ({ page }) => { | ||
const dropdownButton = page.getByRole('button').first(); | ||
const dropdownListElementOne = page | ||
.locator('tds-dropdown-option') | ||
.filter({ hasText: 'Option 1' }); | ||
await expect(dropdownListElementOne).toBeHidden(); | ||
|
||
await page.evaluate(() => { | ||
const dropdownnew = document.querySelector('tds-dropdown'); | ||
dropdownnew.focusElement(); | ||
}); | ||
|
||
/* before clicking dropdownlist should not be visible, the button should be */ | ||
await expect(dropdownButton).toBeVisible(); | ||
await expect(dropdownListElementOne).toBeVisible(); | ||
|
||
/* checks diff on screenshot */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
}); |
Binary file added
BIN
+7.06 KB
...ightmode-clickin-65615--opens-the-dropdown-list-then-click-Option-1-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11 KB
...mary-lightmode-clicking-the-dropdown-button-opens-the-dropdown-list-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11 KB
...ary-lightmode-focusElement-method-focus-and-opens-the-dropdown-list-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.18 KB
...opdown-default-primary-lightmode-renders-default-dropdown-correctly-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions
32
packages/core/src/components/dropdown/test/default/primary/lightmode/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Dropdown - 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 style="padding: 20px"> | ||
<tds-dropdown | ||
name="dropdown" | ||
label="Label text" | ||
label-position="outside" | ||
placeholder="Placeholder" | ||
helper="Helper text" | ||
size="lg" | ||
open-direction="auto" | ||
data-testid="tds-dropdown-testid" | ||
mode-variant="primary" | ||
> | ||
<tds-dropdown-option value="option-1">Option 1</tds-dropdown-option> | ||
<tds-dropdown-option disabled value="option-2">Option 2</tds-dropdown-option> | ||
<tds-dropdown-option value="option-3">Option 3</tds-dropdown-option> | ||
<tds-dropdown-option value="option-4">Option 4</tds-dropdown-option> | ||
</tds-dropdown> | ||
</body> | ||
</html> |
74 changes: 74 additions & 0 deletions
74
packages/core/src/components/dropdown/test/default/secondary/darkmode/dropdown.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { test } from 'stencil-playwright'; | ||
import { expect } from '@playwright/test'; | ||
|
||
const componentTestPath = 'src/components/dropdown/test/default/secondary/darkmode/index.html'; | ||
|
||
test.describe.parallel('tds-dropdown-default-secondary-darkmode', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(componentTestPath); | ||
}); | ||
|
||
test('renders default dropdown correctly', async ({ page }) => { | ||
const dropdown = page.getByTestId('tds-dropdown-testid'); | ||
await expect(dropdown).toHaveCount(1); | ||
|
||
/* check diff in screenshot */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
|
||
test('clicking the dropdown button opens the dropdown-list', async ({ page }) => { | ||
const dropdownButton = page.getByRole('button', { name: 'Placeholder' }); | ||
const dropdownListElementOne = page | ||
.locator('tds-dropdown-option') | ||
.filter({ hasText: 'Option 1' }); | ||
await expect(dropdownListElementOne).toBeHidden(); | ||
await dropdownButton.click(); | ||
|
||
/* before clicking dropdownlist should not be visible, the button should be */ | ||
await expect(dropdownButton).toBeVisible(); | ||
await expect(dropdownListElementOne).toBeVisible(); | ||
|
||
/* checks diff on screenshot */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
|
||
test('clicking the dropdown opens the dropdown-list, then click Option 1', async ({ page }) => { | ||
/* click the dropdown button */ | ||
const dropdownButton = page.getByRole('button', { name: 'Placeholder' }); | ||
await dropdownButton.click(); | ||
|
||
/* Click the Option 1 button */ | ||
const dropdownListElementOneButton = page | ||
.locator('tds-dropdown-option') | ||
.filter({ hasText: /Option 1/ }) | ||
.getByRole('button'); | ||
await dropdownListElementOneButton.click(); | ||
|
||
await expect(dropdownListElementOneButton).toBeHidden(); | ||
const dropdownButtonWithOption1 = page.getByRole('button', { name: 'Option 1' }); | ||
await expect(dropdownButtonWithOption1.first()).toBeVisible(); | ||
|
||
/* also check screenshot diff to make sure it says Option 1 */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
|
||
test('focusElement() method focus and opens the dropdown-list', async ({ page }) => { | ||
const dropdownButton = page.getByRole('button').first(); | ||
const dropdownListElementOne = page | ||
.locator('tds-dropdown-option') | ||
.filter({ hasText: 'Option 1' }); | ||
await expect(dropdownListElementOne).toBeHidden(); | ||
|
||
await page.evaluate(() => { | ||
const dropdownnew = document.querySelector('tds-dropdown'); | ||
dropdownnew.focusElement(); | ||
}); | ||
|
||
/* before clicking dropdownlist should not be visible, the button should be */ | ||
await expect(dropdownButton).toBeVisible(); | ||
await expect(dropdownListElementOne).toBeVisible(); | ||
|
||
/* checks diff on screenshot */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
}); |
Binary file added
BIN
+6.99 KB
...-darkmode-clicki-e1e41--opens-the-dropdown-list-then-click-Option-1-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11 KB
...ndary-darkmode-clicking-the-dropdown-button-opens-the-dropdown-list-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11 KB
...dary-darkmode-focusElement-method-focus-and-opens-the-dropdown-list-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.23 KB
...pdown-default-secondary-darkmode-renders-default-dropdown-correctly-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions
32
packages/core/src/components/dropdown/test/default/secondary/darkmode/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Dropdown - 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-900); padding: 20px"> | ||
<tds-dropdown | ||
name="dropdown" | ||
label="Label text" | ||
label-position="outside" | ||
placeholder="Placeholder" | ||
helper="Helper text" | ||
size="lg" | ||
open-direction="auto" | ||
data-testid="tds-dropdown-testid" | ||
mode-variant="secondary" | ||
> | ||
<tds-dropdown-option value="option-1">Option 1</tds-dropdown-option> | ||
<tds-dropdown-option disabled value="option-2">Option 2</tds-dropdown-option> | ||
<tds-dropdown-option value="option-3">Option 3</tds-dropdown-option> | ||
<tds-dropdown-option value="option-4">Option 4</tds-dropdown-option> | ||
</tds-dropdown> | ||
</body> | ||
</html> |
Oops, something went wrong.