-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add screenshot tests for banner in light and dark modes
- Loading branch information
Showing
8 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
packages/core/src/components/banner/test/_screenshot_tests/banner.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,39 @@ | ||
import { test } from 'stencil-playwright'; | ||
import { expect } from '@playwright/test'; | ||
|
||
const colorModes = ['lightmode', 'darkmode']; | ||
const bannerTypes = ['default', 'error', 'information']; | ||
|
||
colorModes.forEach((colorMode) => { | ||
bannerTypes.forEach((bannerType) => { | ||
const componentTestPath = 'src/components/banner/test/_screenshot_tests/index.html'; | ||
|
||
test.describe.parallel(`tds-banner-${bannerType}-${colorMode}`, () => { | ||
test(`renders ${bannerType} banner with ${colorMode} correctly`, async ({ page }) => { | ||
await page.goto(componentTestPath); | ||
|
||
if (colorMode === 'darkmode') { | ||
await page.evaluate(() => { | ||
document.body.classList.add('tds-mode-dark'); | ||
}); | ||
} | ||
|
||
await page.evaluate((mode) => { | ||
document.body.setAttribute( | ||
'style', | ||
`background-color: ${mode === 'lightmode' ? 'white' : 'grey-958'}; padding: 10px`, | ||
); | ||
}, colorMode); | ||
|
||
if (bannerType !== 'default') { | ||
await page.evaluate((type) => { | ||
document.getElementsByTagName('tds-banner')[0].setAttribute('variant', type); | ||
}, bannerType); | ||
} | ||
|
||
/* Check diff on screenshot */ | ||
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 }); | ||
}); | ||
}); | ||
}); | ||
}); |
Binary file added
BIN
+9.27 KB
...ner-default-darkmode-renders-default-banner-with-darkmode-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.
Binary file added
BIN
+9.3 KB
...r-default-lightmode-renders-default-banner-with-lightmode-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.
Binary file added
BIN
+9.21 KB
...-banner-error-darkmode-renders-error-banner-with-darkmode-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.
Binary file added
BIN
+9.28 KB
...anner-error-lightmode-renders-error-banner-with-lightmode-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.
Binary file added
BIN
+9.29 KB
...rmation-darkmode-renders-information-banner-with-darkmode-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.
Binary file added
BIN
+9.33 KB
...ation-lightmode-renders-information-banner-with-lightmode-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.
19 changes: 19 additions & 0 deletions
19
packages/core/src/components/banner/test/_screenshot_tests/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,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Banner - General screenshot tests</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-banner header="This is a header text area" subheader="This is the subheader text area"> | ||
<tds-link slot="actions"><a href="/">Link example</a></tds-link> | ||
</tds-banner> | ||
</body> | ||
</html> |