diff --git a/showcases/screen-reader/default.ts b/showcases/screen-reader/default.ts index 4a7edeae7fa..ad2f7960056 100644 --- a/showcases/screen-reader/default.ts +++ b/showcases/screen-reader/default.ts @@ -46,15 +46,11 @@ const cleanSpeakInstructions = (phraseLog: string[]): string[] => export const generateSnapshot = async ( screenReader?: VoiceOverPlaywright | NVDAPlaywright, - shiftFirst?: boolean, retry?: number ) => { if (!screenReader) return; let phraseLog: string[] = await screenReader.spokenPhraseLog(); - if (shiftFirst) { - phraseLog.shift(); - } if (retry && retry > 0) { process.stdout.write(JSON.stringify(phraseLog)); @@ -100,19 +96,15 @@ export const runTest = async ({ nvda ?? voiceOver; if (!screenRecorder) return; + /** + * In macOS:Webkit the [automaticallySpeakWebPage](https://github.com/guidepup/guidepup/blob/main/src/macOS/VoiceOver/configureSettings.ts#L58) is acitve. + * Therefore, we need to move back with the cursor to the start and delete the logs before starting. + * In windows:Chrome the cursor is on the middle element. + * Therefore, we need to move back and delete the logs, and then start everything. + */ await screenRecorder.navigateToWebContent(); await page.waitForTimeout(500); - if (voiceOver) { - await voiceOver.perform('read contents of voiceover cursor' as any); - const lastPhrase = await voiceOver.lastSpokenPhrase(); - await voiceOver.clearSpokenPhraseLog(); - if (lastPhrase.includes('You are currently')) { - // We stop interacting here because screenRecorder.navigateToWebContent() calls voiceOver.interact() - await voiceOver.stopInteracting(); - } - } - await testFn?.(voiceOver, nvda); await postTestFn?.(voiceOver, nvda, retry); recorder?.(); @@ -121,7 +113,7 @@ export const runTest = async ({ export const testDefault = (defaultTestType: DefaultTestType) => { const { test, title, additionalParams, postTestFn } = defaultTestType; const fallbackPostFn = async (voiceOver, nvda, retry) => { - await generateSnapshot(voiceOver ?? nvda, nvda, retry); + await generateSnapshot(voiceOver ?? nvda, retry); }; const testType: DefaultTestType = { diff --git a/showcases/screen-reader/tests/button.spec.ts b/showcases/screen-reader/tests/button.spec.ts index 3335e782898..0e7c2b93314 100644 --- a/showcases/screen-reader/tests/button.spec.ts +++ b/showcases/screen-reader/tests/button.spec.ts @@ -8,12 +8,15 @@ test.describe('DBButton', () => { title: 'should not have icon in screen reader (next)', url: './#/02/button?page=content', async testFn(voiceOver, nvda) { - const screenReader = voiceOver ?? nvda; if (nvda) { - await screenReader?.next(); - await screenReader?.previous(); + await nvda?.next(); + } else if (voiceOver) { + await voiceOver?.previous(); } + const screenReader = voiceOver ?? nvda; + await screenReader?.clearSpokenPhraseLog(); + await screenReader?.previous(); await screenReader?.next(); await screenReader?.next(); } @@ -23,14 +26,17 @@ test.describe('DBButton', () => { title: 'should not have icon in screen reader (tab)', url: './#/02/button?page=content', async testFn(voiceOver, nvda) { - const screenReader = voiceOver ?? nvda; if (nvda) { - await screenReader?.press('Tab'); - await screenReader?.press('Shift+Tab'); + await nvda?.press('Tab'); + } else if (voiceOver) { + await voiceOver?.press('Shift+Tab'); } - await screenReader?.press('Tab'); - await screenReader?.press('Tab'); + const screenReader = voiceOver ?? nvda; + await screenReader?.clearSpokenPhraseLog(); + await nvda?.press('Shift+Tab'); + await nvda?.press('Tab'); + await nvda?.press('Tab'); } }); }); diff --git a/showcases/screen-reader/tests/input.spec.ts b/showcases/screen-reader/tests/input.spec.ts index 6a691fad1b3..ae12a535914 100644 --- a/showcases/screen-reader/tests/input.spec.ts +++ b/showcases/screen-reader/tests/input.spec.ts @@ -8,13 +8,14 @@ test.describe('DBInput', () => { title: 'should have message and label (tab)', url: './#/03/input?page=variant%20helper%20message', async testFn(voiceOver, nvda) { - const screenReader = voiceOver ?? nvda; if (nvda) { - await screenReader?.press('Tab'); - await screenReader?.press('Shift+Tab'); + await nvda?.press('Tab'); } - await screenReader?.press('Tab'); + const screenReader = voiceOver ?? nvda; + await screenReader?.clearSpokenPhraseLog(); + await nvda?.press('Shift+Tab'); + await nvda?.press('Tab'); } }); }); diff --git a/showcases/screen-reader/tests/radio.spec.ts b/showcases/screen-reader/tests/radio.spec.ts index e1d98aae5e4..312763f2eb3 100644 --- a/showcases/screen-reader/tests/radio.spec.ts +++ b/showcases/screen-reader/tests/radio.spec.ts @@ -7,12 +7,15 @@ test.describe('DBRadio', () => { title: 'should label duplicated (next)', url: './#/03/radio?page=density', async testFn(voiceOver, nvda) { - const screenReader = voiceOver ?? nvda; if (nvda) { - await screenReader?.next(); - await screenReader?.previous(); + await nvda?.next(); + } else if (voiceOver) { + await voiceOver?.previous(); } + const screenReader = voiceOver ?? nvda; + await screenReader?.clearSpokenPhraseLog(); + await screenReader?.previous(); await screenReader?.next(); await screenReader?.next(); } @@ -22,12 +25,13 @@ test.describe('DBRadio', () => { title: 'should label duplicated (arrows)', url: './#/03/radio?page=density', async testFn(voiceOver, nvda) { - const screenReader = voiceOver ?? nvda; if (nvda) { - await screenReader?.press('Left'); - await screenReader?.press('Left'); + await nvda?.press('Left'); } + const screenReader = voiceOver ?? nvda; + await screenReader?.clearSpokenPhraseLog(); + await screenReader?.press('Left'); await screenReader?.press('Right'); await screenReader?.press('Right'); }