-
Notifications
You must be signed in to change notification settings - Fork 106
test: Adjusting the visual regression test ratios and fixing test bugs #1528
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
Changes from all commits
eac0c20
023f840
bf250d6
8cc825f
7b2d6d0
73be602
c296a44
97ce3f7
1ac94cd
10a0619
bbcb4ca
bbb15fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,46 @@ | ||
| const element = require("../package.json").pfelement.elementName; | ||
| let windowSize; | ||
|
|
||
| describe(element, () => { | ||
| let snapshotOptions; | ||
|
|
||
| before(() => { | ||
| browser.url(`/elements/${element}/demo`); | ||
| // Capture window size | ||
| windowSize = browser.getWindowSize(); | ||
|
|
||
| snapshotOptions = { | ||
| removeElements: [ | ||
| $("#toc"), | ||
| $$(".skip-e2e") | ||
| ] | ||
| }; | ||
| browser.url(`/elements/${element}/demo/index_e2e.html`); | ||
|
|
||
| browser.setWindowSize(1200, 1000); | ||
| }); | ||
|
|
||
| ["light", "dark", "saturated"].forEach(context => { | ||
| it(`should take a screenshot and compare for ${context} context`, () => { | ||
| $("#context").selectByAttribute("value", context); | ||
| browser.saveFullPageScreen(`${element}--${context}`, snapshotOptions); | ||
| expect(browser.checkFullPageScreen(`${element}--${context}`, snapshotOptions)).toBeLessThan(3.1); | ||
| }); | ||
| after(function() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why set the browser window size after these tests?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An observation - I noticed that if you change the browser size between tests, it persists between test files unless you unset that update.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Future option is to set up a global before that sets the initial browser size |
||
| browser.setWindowSize(windowSize.width, windowSize.height); | ||
| }); | ||
| }); | ||
|
|
||
| if (browser.capabilities.browserName === "IE") { | ||
castastrophe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| it(`should take a screenshot and compare`, () => { | ||
| browser.saveFullPageScreen(element, {}); | ||
| expect(browser.checkFullPageScreen(element, {})).toBeLessThan(3.1); | ||
| }); | ||
| } else { | ||
|
|
||
| ["light", "dark", "saturated"].forEach(context => { | ||
| it(`should take a screenshot and compare for ${context} context`, () => { | ||
| if (context !== "light") { | ||
| let color = "darker"; | ||
| if (context === "saturated") color = "accent"; | ||
|
|
||
| browser.execute(function (color) { | ||
| document.querySelector("#wrapper").className = `surface--${color}`; | ||
| Promise.all([customElements.whenDefined("pfe-tabs")]).then(function () { | ||
| document.querySelectorAll("pfe-tabs").forEach(function (tab) { | ||
| tab.resetContext(); | ||
| }); | ||
| }); | ||
| }, color); | ||
| } | ||
|
|
||
| browser.saveFullPageScreen(`${element}--${context}`, {}); | ||
| expect(browser.checkFullPageScreen(`${element}--${context}`, {})).toBeLessThan(3.1); | ||
| }); | ||
| }); | ||
| } | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.