Skip to content

Commit

Permalink
Merge pull request #3005 from db-ui/test-guidepup-checkbox
Browse files Browse the repository at this point in the history
test: adds guidepup test for checkbox
  • Loading branch information
bruno-sch authored Sep 11, 2024
2 parents 61b2b22 + 5e45e95 commit 5923892
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 9 deletions.
5 changes: 2 additions & 3 deletions packages/components/src/styles/_form-components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,8 @@ $input-valid-types: "color", "date", "datetime-local", "email", "file", "hidden"
&:is(label),
label {
&::after {
content: "*";
// Hiding asterisk from screenreaders, https://www.w3.org/TR/css-content-3/#alt
content: "*" / "";
@include icons.icon-content("*");

padding-inline-start: variables.$db-spacing-fixed-2xs;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["Required required unchecked checkbox","Required","Required - Indeterminate mixed checkbox","Required","Required required unchecked checkbox","TODO: Add a validMessage","Required","TODO: Add a validMessage","Required - Indeterminate mixed checkbox","TODO: Add a validMessage","Required","Required TODO: Add a validMessage required checked checkbox","Select this checkbox","Required","Select this checkbox","Required - Indeterminate mixed checkbox"]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["check box, not checked, required, Required","TODO: Add a valid Message. checked","Required","TODO: Add a valid Message","Required","check box, checked, required, Required","Please check this box if you want to proceed.. not checked","Required","Please check this box if you want to proceed.","check box, half checked, Required Indeterminate"]
23 changes: 17 additions & 6 deletions showcases/screen-reader/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,29 @@ const standardPhrases = [
'To expand'
];

const flakyExpressions: Record<string, string> = {
'pop-up': 'pop up',
'checked. checked': 'checked',
'selected. selected': 'selected'
};

const cleanSpeakInstructions = (phraseLog: string[]): string[] =>
phraseLog.map((phrase) =>
phrase
phraseLog.map((phrase) => {
let result = phrase
.split('. ')
.filter(
(sPhrase) =>
!standardPhrases.some((string) => sPhrase.includes(string))
)
.join('. ')
// We need to replace specific phrases, as they are being reported differently on localhost and within CI/CD
.replaceAll('pop-up', 'pop up')
);
.join('. ');

// We need to replace specific phrases, as they are being reported differently on localhost and within CI/CD
for (const [key, value] of Object.entries(flakyExpressions)) {
result = result.replaceAll(key, value);
}

return result;
});

export const generateSnapshot = async (
screenReader?: VoiceOverPlaywright | NVDAPlaywright,
Expand Down
48 changes: 48 additions & 0 deletions showcases/screen-reader/tests/checkbox.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { getTest, testDefault } from '../default';

const test = getTest();

test.describe('DBCheckbox', () => {
testDefault({
test,
title: 'default',
description:
'should tick and untick checkbox, feedback messages must appear',
url: './#/03/checkbox?page=requirement',
async testFn(voiceOver, nvda) {
if (nvda) {
await nvda?.next(); // Focus checkbox 2
await nvda?.act(); // Tick checkbox 2
await nvda?.next(); // Focus checkbox 2 label
await nvda?.next(); // Focus checkbox 2 message
await nvda?.previous(); // Focus checkbox 2 label
await nvda?.previous(); // Focus checkbox 2
await nvda?.act(); // Tick checkbox 2
await nvda?.next(); // Focus checkbox 2 label
await nvda?.next(); // Focus checkbox 2 message
await nvda?.next(); // Focus checkbox 3
} else if (voiceOver) {
await voiceOver?.next(); // Focus checkbox 1
await voiceOver?.next(); // Focus checkbox 1 label
await voiceOver?.clearSpokenPhraseLog();

await voiceOver?.next(); // Focus checkbox 2
await voiceOver?.next(); // Focus checkbox 2 label
await voiceOver?.next(); // Focus checkbox 3
await voiceOver?.previous(); // Focus checkbox 2 label
await voiceOver?.previous(); // Focus checkbox 2
await voiceOver?.act(); // Tick checkbox 2
await voiceOver?.next(); // Focus checkbox 2 label
await voiceOver?.next(); // Focus checkbox 2 message
await voiceOver?.next(); // Focus checkbox 3
await voiceOver?.previous(); // Focus checkbox 2 message
await voiceOver?.previous(); // Focus checkbox 2 label
await voiceOver?.previous(); // Focus checkbox 2
await voiceOver?.act(); // Tick checkbox 2
await voiceOver?.next(); // Focus checkbox 2 label
await voiceOver?.next(); // Focus checkbox 2 message
await voiceOver?.next(); // Focus checkbox 3
}
}
});
});
3 changes: 3 additions & 0 deletions showcases/screen-reader/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const translations: Record<string, string[]> = {
edit: ['Eingabefeld'],
'radio button': ['Auswahlschalter'],
blank: ['Leer'],
not: ['Nicht'],
'half checked': ['teilweise aktiviert'],
checked: ['aktiviert'],
' of ': [' von '],
clickable: ['anklickbar'],
Expand All @@ -17,6 +19,7 @@ export const translations: Record<string, string[]> = {
dialog: ['Dialogfeld'],
document: ['Dokument'],
unavailable: ['nicht verfügbar'],
'check box': ['Kontrollfeld'],
collapsed: ['reduziert'],
expanded: ['erweitert']
};

0 comments on commit 5923892

Please sign in to comment.