Skip to content

Commit

Permalink
fix: issue with wrong snapshot (#2922)
Browse files Browse the repository at this point in the history
* fix: issue with wrong snapshot

* fix: issue with wrong snapshot

---------

Co-authored-by: Maximilian Franzke <[email protected]>
  • Loading branch information
nmerget and mfranzke authored Jul 26, 2024
1 parent 8d332e6 commit 808d48f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["unknown. dialog. document. clickable, Close Button, button. dialog. button, Close Button","Functional"]
["button. dialog. document. clickable, Close Button, button. dialog. button, Close Button","Functional"]
7 changes: 6 additions & 1 deletion showcases/screen-reader/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ const cleanSpeakInstructions = (phraseLog: string[]): string[] =>

export const generateSnapshot = async (
screenReader?: VoiceOverPlaywright | NVDAPlaywright,
retry?: number
retry?: number,
phraseLogConvertFn?: (phraseLog: string[]) => string[]
) => {
if (!screenReader) return;

Expand All @@ -61,6 +62,10 @@ export const generateSnapshot = async (

phraseLog = cleanSpeakInstructions(phraseLog);

if (phraseLogConvertFn) {
phraseLog = phraseLogConvertFn(phraseLog);
}

let snapshot = JSON.stringify(phraseLog);

for (const [key, values] of Object.entries(translations)) {
Expand Down
19 changes: 18 additions & 1 deletion showcases/screen-reader/tests/drawer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getTest, testDefault } from '../default';
import { generateSnapshot, getTest, testDefault } from '../default';

const test = getTest();

Expand All @@ -11,6 +11,23 @@ test.describe('DBDrawer', () => {
const screenReader = voiceOver ?? nvda;
await screenReader?.act();
await screenReader?.next();
},
async postTestFn(voiceOver, nvda, retry) {
if (nvda) {
/*
* There is a timing issue for windows which results in different outputs in CICD.
* We avoid this by replacing the generated log files
*/
await generateSnapshot(nvda, retry, (phraseLog) =>
phraseLog.map((log) =>
log
.replace('Showcase, document. unknown', 'button')
.replace('unknown', 'button')
)
);
} else if (voiceOver) {
await generateSnapshot(voiceOver, retry);
}
}
});
});

0 comments on commit 808d48f

Please sign in to comment.