|
1 | | -import { expect } from "@playwright/test"; |
| 1 | +import { platform, release } from "os"; |
2 | 2 | import { headerNavigation } from "../headerNavigation"; |
3 | 3 | import itemTextSnapshot from "./chromium.itemText.snapshot.json"; |
| 4 | +import { logIncludesExpectedPhrases } from "../logIncludesExpectedPhrases"; |
4 | 5 | import { macOSRecord } from "@guidepup/guidepup"; |
5 | 6 | import spokenPhraseSnapshot from "./chromium.spokenPhrase.snapshot.json"; |
6 | 7 | import { voTest as test } from "../../../src"; |
7 | 8 |
|
8 | 9 | test.describe("Chromium Playwright VoiceOver", () => { |
9 | 10 | test("I can navigate the Guidepup Github page", async ({ |
| 11 | + browser, |
| 12 | + browserName, |
10 | 13 | page, |
11 | 14 | voiceOver, |
12 | 15 | }) => { |
13 | | - const stopRecording = macOSRecord( |
14 | | - `./recordings/playwright-voiceover-chromium-${+new Date()}.mov` |
15 | | - ); |
| 16 | + const osName = platform(); |
| 17 | + const osVersion = release(); |
| 18 | + const browserVersion = browser.version(); |
| 19 | + const { retry } = test.info(); |
| 20 | + const recordingFilePath = `./recordings/playwright-voiceover-${osName}-${osVersion}-${browserName}-${browserVersion}-attempt-${retry}-${+new Date()}.mov`; |
16 | 21 |
|
17 | | - await headerNavigation({ page, voiceOver }); |
| 22 | + console.table({ |
| 23 | + osName, |
| 24 | + osVersion, |
| 25 | + browserName, |
| 26 | + browserVersion, |
| 27 | + retry, |
| 28 | + }); |
18 | 29 |
|
19 | | - // Assert that we've ended up where we expected and what we were told on |
20 | | - // the way there is as expected. |
| 30 | + let stopRecording: (() => void) | undefined; |
21 | 31 |
|
22 | | - const itemTextLog = await voiceOver.itemTextLog(); |
23 | | - const spokenPhraseLog = await voiceOver.spokenPhraseLog(); |
| 32 | + try { |
| 33 | + const isMacOSVentura = |
| 34 | + osName === "darwin" && osVersion.split(".")[0] === "22"; |
24 | 35 |
|
25 | | - console.log(JSON.stringify(itemTextLog, undefined, 2)); |
26 | | - console.log(JSON.stringify(spokenPhraseLog, undefined, 2)); |
| 36 | + if (!isMacOSVentura) { |
| 37 | + stopRecording = macOSRecord(recordingFilePath); |
| 38 | + } |
27 | 39 |
|
28 | | - for (const expectedItem of itemTextSnapshot) { |
29 | | - expect(!!itemTextLog.find((log) => log.includes(expectedItem))).toBe( |
30 | | - true |
31 | | - ); |
32 | | - } |
| 40 | + await headerNavigation({ page, voiceOver }); |
33 | 41 |
|
34 | | - for (const expectedPhrase of spokenPhraseSnapshot) { |
35 | | - expect( |
36 | | - !!spokenPhraseLog.find((log) => log.includes(expectedPhrase)) |
37 | | - ).toBe(true); |
38 | | - } |
| 42 | + // Assert that we've ended up where we expected and what we were told on |
| 43 | + // the way there is as expected. |
| 44 | + |
| 45 | + const itemTextLog = await voiceOver.itemTextLog(); |
| 46 | + const spokenPhraseLog = await voiceOver.spokenPhraseLog(); |
39 | 47 |
|
40 | | - stopRecording(); |
| 48 | + console.log(JSON.stringify(itemTextLog, undefined, 2)); |
| 49 | + console.log(JSON.stringify(spokenPhraseLog, undefined, 2)); |
| 50 | + |
| 51 | + logIncludesExpectedPhrases(itemTextLog, itemTextSnapshot); |
| 52 | + logIncludesExpectedPhrases(spokenPhraseLog, spokenPhraseSnapshot); |
| 53 | + } finally { |
| 54 | + stopRecording?.(); |
| 55 | + } |
41 | 56 | }); |
42 | 57 | }); |
0 commit comments