11import { expect } from "@playwright/test" ;
2- import itemTextSnapshot from "./itemTextSnapshot .json" ;
2+ import snapshot from "./webkit.snapshot .json" ;
33import { voTest as test } from "../../src" ;
44
5- function delay ( ms : number ) {
6- return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
7- }
8-
9- async function waitForWebContentAnnouncement ( voiceOver ) {
10- for ( let i = 0 ; i < 10 ; i ++ ) {
11- const itemText = await voiceOver . itemText ( ) ;
12-
13- if ( itemText ?. includes ( "web content" ) ) {
14- return ;
15- }
16-
17- await delay ( 50 ) ;
18- }
19-
20- throw new Error ( "web content could not be found" ) ;
21- }
22-
235test . describe ( "Playwright VoiceOver" , ( ) => {
246 test ( "I can navigate the Guidepup Github page" , async ( {
7+ browserName,
258 page,
269 voiceOver,
2710 } ) => {
11+ test . skip ( browserName !== "webkit" , "Webkit only test" ) ;
12+
2813 // Navigate to Guidepup GitHub page 🎉
2914 await page . goto ( "https://github.com/guidepup/guidepup" , {
3015 waitUntil : "domcontentloaded" ,
3116 } ) ;
3217
3318 // Wait for page to be ready and interact 🙌
3419 await expect ( page . locator ( 'header[role="banner"]' ) ) . toBeVisible ( ) ;
35- await waitForWebContentAnnouncement ( voiceOver ) ;
3620 await voiceOver . interact ( ) ;
3721
3822 // Move across the page menu to the Guidepup heading using VoiceOver 🔎
@@ -42,10 +26,10 @@ test.describe("Playwright VoiceOver", () => {
4226
4327 // Assert that we've ended up where we expected and what we were told on
4428 // the way there is as expected.
45- const itemTextLog = await voiceOver . itemTextLog ( ) ;
29+ const spokenPhraseLog = await voiceOver . spokenPhraseLog ( ) ;
4630
47- for ( const expectedItem of itemTextSnapshot ) {
48- expect ( itemTextLog ) . toContain ( expectedItem ) ;
31+ for ( const expectedPhrase of snapshot ) {
32+ expect ( ! ! spokenPhraseLog . find ( log => log . includes ( expectedPhrase ) ) ) . toBe ( true ) ;
4933 }
5034 } ) ;
5135} ) ;
0 commit comments