forked from patternfly/patternfly-quickstarts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snapshots.js
60 lines (55 loc) · 2.05 KB
/
snapshots.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const PercyScript = require('@percy/script');
const options = { headless: true };
const withSnapshots = true;
const runThroughQuickStart = async (id, page, percySnapshot) => {
const snapshotOptions = {
widths: [375],
};
await page.goto(`http://localhost:3000?quickstart=${id}`);
// ensure the page has loaded before capturing a snapshot
await page.waitFor('.pf-c-drawer__panel');
withSnapshots && (await percySnapshot(`${id}__intro`, snapshotOptions));
await page.click('[data-test="Start button"]');
withSnapshots && (await percySnapshot(`${id}__step-1`, snapshotOptions));
await page.click('[data-test="Next button"]');
withSnapshots && (await percySnapshot(`${id}__step-1-verify`, snapshotOptions));
let sawCloseButton = false;
let isVerifyStep = false;
let step = 1;
while (!sawCloseButton) {
if ((await page.$('[data-test="Next button"]')) !== null) {
step = step + 1;
await page.click('[data-test="Next button"]');
if (isVerifyStep) {
withSnapshots && (await percySnapshot(`${id}__step-${step}-verify`, snapshotOptions));
} else {
withSnapshots && (await percySnapshot(`${id}__step-${step}`, snapshotOptions));
}
isVerifyStep = !isVerifyStep;
} else {
sawCloseButton = true;
await page.waitForSelector('[data-test="Close button"]');
withSnapshots && (await percySnapshot(`${id}__conclusion`, snapshotOptions));
await page.click('[data-test="Close button"]');
}
}
};
PercyScript.run(async (page, percySnapshot) => {
// catalog screenshot
await page.goto('http://localhost:3000');
await page.waitFor('.pfext-quick-start-tile');
withSnapshots && (await percySnapshot('catalog', { widths: [1280] }));
// quick starts
const quickStarts = [
'getting-started-with-quick-starts',
'mas-alert-note-prereq',
'add-healthchecks',
'install-app-and-associate-pipeline',
'serverless-application',
'node-with-s2i',
'spring-with-s2i',
];
for (const qs of quickStarts) {
await runThroughQuickStart(qs, page, percySnapshot);
}
}, options);