Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue with wrong snapshot #2922

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
});
});
Loading