Skip to content

Commit 918e067

Browse files
authored
test: visual regression testing (#885)
* first pass at visual regression testing * updating package-lock.json * updating the baseline * adding http-server for local testing I couldn't figure out a way to kill the npm start process in the onComplete callback for web driver. Adding http-server, starting it in onPrepare, storing the process as a variable, and then killing it in the onComplete callback works well. * working on creating dynamic tests * adding a test for pfe-accordion * updating travis file to run just e2e second * updating pfe-accordion baseline images * new baseline images, more tests, and updated configuration * pfe-collapse, pfe-content-set, pfe-cta, pfe-datetime tests * more tests and baseline images * using local versions of webcomponentsjs and require Trying to cut down on external dependencies for testing * moving webcomponentsjs and requirejs to dependencies * making webcomponentsjs and requirejs devDependencies again * copying webcomponentsjs and requirejs in the build step * using webcomponentsjs and requirejs from the examples directory * using local images instead of images from the internet * updating spandx config to the root doesn't point to just node_modules * increasing e2e test timeout to 30 seconds and increasing the maxInstances to 7 * updating the location of the webcomponent polyfills and require * creating a simplified e2e demo page for pfe-icon * updating and creating e2e tests * updated and new baseline images * updating the location of the web component polyfills and require.js in the generator * adding more wait time in the autocomplete e2e test * updating demo page polyfills and require and updating baseline images * trying a lower number of max instances * more baseline updates * updating pfe-health-index IE11 baseline * updating pfe-cta IE11 baseline * adding 500x500 kitten * baseline updates and test adjustments * package-lock updates * increase the tolerance in the pfe-toast test
1 parent c9e3ae4 commit 918e067

File tree

117 files changed

+3672
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+3672
-391
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Development files
22
node_modules
33
tmp
4+
.tmp
45

56
# Generator config file
67
project.conf.json
@@ -16,6 +17,7 @@ doc/index.html
1617
# Logs
1718
lerna-debug.log
1819
npm-debug.log*
20+
local.log
1921

2022
# Local files
2123
.env

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ os:
77
addons:
88
firefox: latest
99
chrome: stable
10+
browserstack:
11+
username: BROWSERSTACK_USER
12+
access_key: BROWSERSTACK_KEY
1013
script:
1114
- npm test -- --verbose
15+
- npm run e2e -- --verbose
1216
cache:
1317
directories:
1418
- node_modules

elements/pfe-accordion/demo/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
<link rel="stylesheet" href="../../pfe-styles/dist/pfe-layouts.css" />
2222

2323
<!-- uncomment the es5-adapter if you're using the umd version -->
24-
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.3.0/custom-elements-es5-adapter.js"></script>
25-
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.3.0/webcomponents-bundle.js"></script>
26-
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js"></script>
24+
<script src="/examples/node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
25+
<script src="/examples/node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
26+
<script src="/examples/node_modules/requirejs/require.js"></script>
2727

2828
<script>require([
2929
'../dist/pfe-accordion.umd.js',
@@ -105,7 +105,7 @@ <h2>Accordion component</h2>
105105
</header>
106106
<article>
107107
<pfe-accordion>
108-
<pfe-accordion-header>
108+
<pfe-accordion-header id="first-header">
109109
<h3>Nested panel example</h3>
110110
</pfe-accordion-header>
111111
<pfe-accordion-panel>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const element = require("../package.json").pfelement.elementName;
2+
3+
describe(element, () => {
4+
let accordion;
5+
6+
before(() => {
7+
browser.url(`/elements/${element}/demo`);
8+
9+
accordion = $(element);
10+
accordion.$(function() {
11+
this.toggle(0);
12+
});
13+
browser.pause(1000);
14+
});
15+
16+
it("should take a screenshot", () => {
17+
browser.saveScreen(element);
18+
});
19+
20+
it("should compare to the baseline", () => {
21+
expect(browser.checkScreen(element)).toBeLessThan(1.25);
22+
});
23+
});

elements/pfe-autocomplete/demo/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
<link href="../../pfelement/dist/pfelement.min.css" rel="stylesheet">
2222

2323
<!-- uncomment the es5-adapter if you're using the umd version -->
24-
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.3.0/custom-elements-es5-adapter.js"></script>
25-
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.3.0/webcomponents-bundle.js"></script>
26-
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js"></script>
24+
<script src="/examples/node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
25+
<script src="/examples/node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
26+
<script src="/examples/node_modules/requirejs/require.js"></script>
2727
<script>require([
2828
'../dist/pfe-autocomplete.umd.js'
2929
])</script>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const element = require("../package.json").pfelement.elementName;
2+
3+
describe(element, () => {
4+
let autocomplete;
5+
let input
6+
7+
before(() => {
8+
browser.url(`/elements/${element}/demo`);
9+
autocomplete = $(element);
10+
input = $(element + " input");
11+
12+
browser.execute(function (element) {
13+
element.focus();
14+
}, input);
15+
16+
browser.keys(['i']);
17+
browser.pause(1000);
18+
browser.keys(['Down arrow']);
19+
browser.pause(1000);
20+
});
21+
22+
it("should take a screenshot", () => {
23+
browser.saveScreen(element);
24+
});
25+
26+
it("should compare to the baseline", () => {
27+
expect(browser.checkScreen(element)).toBeLessThan(1.5);
28+
});
29+
});

elements/pfe-avatar/demo/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.2/vue.min.js"></script>
2323

2424
<!-- uncomment the es5-adapter if you're using the umd version -->
25-
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.3.0/custom-elements-es5-adapter.js"></script>
26-
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.3.0/webcomponents-bundle.js"></script>
27-
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js"></script>
25+
<script src="/examples/node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
26+
<script src="/examples/node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
27+
<script src="/examples/node_modules/requirejs/require.js"></script>
2828

2929
<script>require([
3030
'../dist/pfe-avatar.umd.js'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const element = require("../package.json").pfelement.elementName;
2+
3+
describe(element, () => {
4+
before(() => {
5+
browser.url(`/elements/${element}/demo`);
6+
});
7+
8+
it("should take a screenshot", () => {
9+
browser.saveScreen(element);
10+
});
11+
12+
it("should compare to the baseline", () => {
13+
expect(browser.checkScreen(element)).toBeLessThan(1.25);
14+
});
15+
});

elements/pfe-badge/demo/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<title>PatternFly Element | pfe-badge Demo</title>
99

1010
<!-- uncomment the es5-adapter if you're using the umd version -->
11-
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.2.10/custom-elements-es5-adapter.js"></script>
12-
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.2.10/webcomponents-bundle.js"></script>
13-
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js"></script>
11+
<script src="/examples/node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
12+
<script src="/examples/node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
13+
<script src="/examples/node_modules/requirejs/require.js"></script>
1414
<script>require(['../dist/pfe-badge.umd.js'])</script>
1515

1616
<style>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const element = require("../package.json").pfelement.elementName;
2+
3+
describe(element, () => {
4+
before(() => {
5+
browser.url(`/elements/${element}/demo`);
6+
});
7+
8+
it("should take a screenshot", () => {
9+
browser.saveScreen(element);
10+
});
11+
12+
it("should compare to the baseline", () => {
13+
expect(browser.checkScreen(element)).toBeLessThan(1.25);
14+
});
15+
});

0 commit comments

Comments
 (0)