Skip to content

Commit 1c7922c

Browse files
authored
test: extend tests to cover all playwright browsers (#7)
* test: extend tests * test: attempt to stabilise the initial page interaction * test: increase timeout and store recordings as artifacts * revert: can't trust the browser/vo output
1 parent 0edd62a commit 1c7922c

20 files changed

+598
-399
lines changed

.github/workflows/test-voiceover.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [macos-11, macos-12]
15+
browser: [chromium, firefox, webkit]
1516
steps:
1617
- uses: actions/checkout@v2
1718
- uses: actions/setup-node@v1
@@ -20,9 +21,12 @@ jobs:
2021
- name: Guidepup Setup
2122
uses: guidepup/[email protected]
2223
- run: yarn install --frozen-lockfile
23-
- run: yarn test
24+
- run: yarn pretest
25+
- run: yarn test:${{ matrix.browser }}
2426
- uses: actions/upload-artifact@v2
2527
if: always()
2628
with:
2729
name: artifacts
28-
path: ./test-results/**/*
30+
path: |
31+
**/test-results/**/*
32+
**/recordings/**/*
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import { devices, PlaywrightTestConfig } from "@playwright/test";
2-
import { voConfig } from "../src";
32

43
const config: PlaywrightTestConfig = {
5-
...voConfig,
64
reportSlowTests: null,
75
workers: 1,
8-
timeout: 2 * 60 * 1000,
9-
retries: 3,
6+
timeout: 3 * 60 * 1000,
7+
retries: 2,
108
projects: [
11-
{
12-
name: "webkit",
13-
use: { ...devices["Desktop Safari"], headless: false, video: "on" },
14-
},
159
{
1610
name: "chromium",
1711
use: { ...devices["Desktop Chrome"], headless: false, video: "on" },

example/firefox.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { devices, PlaywrightTestConfig } from "@playwright/test";
2+
3+
const config: PlaywrightTestConfig = {
4+
reportSlowTests: null,
5+
workers: 1,
6+
timeout: 3 * 60 * 1000,
7+
retries: 2,
8+
projects: [
9+
{
10+
name: "firefox",
11+
use: { ...devices["Desktop Firefox"], headless: false, video: "on" },
12+
},
13+
],
14+
};
15+
16+
export default config;

example/tests/chromium.snapshot.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

example/tests/chromium.spec.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
"guidepup/guidepup heading level 1",
3+
"Latest commit heading level 2",
4+
"Git stats heading level 2",
5+
"Files heading level 2",
6+
"README.md heading level 2",
7+
"Guidepup heading level 1"
8+
]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { expect } from "@playwright/test";
2+
import { headerNavigation } from "../headerNavigation";
3+
import itemTextSnapshot from "./chromium.itemText.snapshot.json";
4+
import { macOSRecord } from "@guidepup/guidepup";
5+
import spokenPhraseSnapshot from "./chromium.spokenPhrase.snapshot.json";
6+
import { voTest as test } from "../../../src";
7+
8+
test.describe("Chromium Playwright VoiceOver", () => {
9+
test("I can navigate the Guidepup Github page", async ({
10+
page,
11+
voiceOver,
12+
}) => {
13+
const stopRecording = macOSRecord(
14+
`./recordings/playwright-voiceover-chromium-${+new Date()}.mov`
15+
);
16+
17+
await headerNavigation({ page, voiceOver });
18+
19+
// Assert that we've ended up where we expected and what we were told on
20+
// the way there is as expected.
21+
22+
const itemTextLog = await voiceOver.itemTextLog();
23+
const spokenPhraseLog = await voiceOver.spokenPhraseLog();
24+
25+
console.log(JSON.stringify(itemTextLog, undefined, 2));
26+
console.log(JSON.stringify(spokenPhraseLog, undefined, 2));
27+
28+
for (const expectedItem of itemTextSnapshot) {
29+
expect(!!itemTextLog.find((log) => log.includes(expectedItem))).toBe(
30+
true
31+
);
32+
}
33+
34+
for (const expectedPhrase of spokenPhraseSnapshot) {
35+
expect(
36+
!!spokenPhraseLog.find((log) => log.includes(expectedPhrase))
37+
).toBe(true);
38+
}
39+
40+
stopRecording();
41+
});
42+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
"heading level 1 guidepup/guidepup. You are currently on a heading level 1.",
3+
"heading level 2 Latest commit. You are currently on a heading level 2.",
4+
"heading level 2 Git stats. You are currently on a heading level 2.",
5+
"heading level 2 Files. You are currently on a heading level 2.",
6+
"heading level 2 link README.md. You are currently on a heading level 2.",
7+
"heading level 1 Guidepup. You are currently on a heading level 1."
8+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
"guidepup/guidepup heading level 1",
3+
"Latest commit heading level 2",
4+
"Git stats heading level 2",
5+
"Files heading level 2",
6+
"README.md heading level 2",
7+
"Guidepup heading level 1"
8+
]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { expect } from "@playwright/test";
2+
import { headerNavigation } from "../headerNavigation";
3+
import itemTextSnapshot from "./firefox.itemText.snapshot.json";
4+
import { macOSRecord } from "@guidepup/guidepup";
5+
import spokenPhraseSnapshot from "./firefox.spokenPhrase.snapshot.json";
6+
import { voTest as test } from "../../../src";
7+
8+
test.describe("Firefox Playwright VoiceOver", () => {
9+
test("I can navigate the Guidepup Github page", async ({
10+
page,
11+
voiceOver,
12+
}) => {
13+
const stopRecording = macOSRecord(
14+
`./recordings/playwright-voiceover-firefox-${+new Date()}.mov`
15+
);
16+
17+
await headerNavigation({ page, voiceOver });
18+
19+
// Assert that we've ended up where we expected and what we were told on
20+
// the way there is as expected.
21+
22+
const itemTextLog = await voiceOver.itemTextLog();
23+
const spokenPhraseLog = await voiceOver.spokenPhraseLog();
24+
25+
console.log(JSON.stringify(itemTextLog, undefined, 2));
26+
console.log(JSON.stringify(spokenPhraseLog, undefined, 2));
27+
28+
for (const expectedItem of itemTextSnapshot) {
29+
expect(!!itemTextLog.find((log) => log.includes(expectedItem))).toBe(
30+
true
31+
);
32+
}
33+
34+
for (const expectedPhrase of spokenPhraseSnapshot) {
35+
expect(
36+
!!spokenPhraseLog.find((log) => log.includes(expectedPhrase))
37+
).toBe(true);
38+
}
39+
40+
stopRecording();
41+
});
42+
});

0 commit comments

Comments
 (0)