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

chore: update testing table for patternhub with accessibility review #3020

Merged
merged 5 commits into from
Aug 9, 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
22 changes: 22 additions & 0 deletions docs/how-to-develop-a-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,25 @@ We have multiple tests you should update:
2. Showcase Test: `showcases/e2e/my-awesome-component/showcase-my-awesome-component.spec.ts`. Test the styling in a specific framework here and also the functionality/events.

To run all tests/update the screenshots you need `Docker`. More information here: `e2e/README.md`.

## Manually Accessibility Review

After creating a component and writing all test, we need some manually third party accessibility review to prove that the component is stable. This process is internal and will be handled by a team specialized in accessibility testing.
During this process you should track the progress of this manual test inside `showcases/shared/_accessibility-review.json`.
Add a new entry like this:

```json
{
"name": "button",
"status": "REVIEW",
"date": "2023-11-23"
},
```

You should change the `date` prop when the first manual test starts or when it gets any update.

The `status` can be:

- `REVIEW`, if the manual accessibility review should happen
- `PROGRESS`, if there are any open issues after the test
- `DONE`, if the component passed the accessibility review
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { useEffect, useState } from 'react';
import { DBInfotext, type SemanticType } from '../../../../output/react/src';

export type AccessibilityReviewInfoType = {
name: string;
status: 'DONE' | 'REVIEW' | 'PROGRESS' | string;
date: string;
};

const AccessibilityReviewInfo = (
accessibilityReview?: AccessibilityReviewInfoType
) => {
const [semantic, setSemantic] = useState<SemanticType>('critical');
const [text, setText] = useState<string>('Missing');

useEffect(() => {
if (accessibilityReview && accessibilityReview.status === 'DONE') {
setSemantic('successful');
setText('Done');
} else if (
accessibilityReview &&
accessibilityReview.status === 'REVIEW'
) {
setSemantic('warning');
setText('In review');
} else if (
accessibilityReview &&
accessibilityReview.status === 'PROGRESS'
) {
setSemantic('warning');
setText('In progress');
} else {
setSemantic('critical');
setText('Missing');
}
}, [accessibilityReview]);

return <DBInfotext semantic={semantic}>{text}</DBInfotext>;
};

export default AccessibilityReviewInfo;
74 changes: 51 additions & 23 deletions showcases/patternhub/pages/foundations/test-table/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import DefaultPage from '../../../components/default-page';
import { DBInfotext } from '../../../../../output/react/src';
import { testTableData } from '../../../data/testing-table'; // This file will be generated at runtime
import AccessibilityReviewInfo from '../../../components/accessibility-review-info/accessibility-review-info'; // This file will be generated at runtime

const tableHeaders = [
{
Expand Down Expand Up @@ -29,6 +30,12 @@ const tableHeaders = [
{
label: 'Showcase: A11y (Screen-Reader)',
href: 'https://github.com/guidepup/guidepup'
},
{
label: 'Manually accessibility review'
},
{
label: 'Testing stable'
}
];

Expand Down Expand Up @@ -63,36 +70,57 @@ const TestTable = () => {
showcaseVisuals,
showcaseAxe,
showcaseAC,
showcaseGP
}) => (
<tr key={name}>
<td>{name}</td>
{[
singleComponentVisuals,
singleComponentAxe,
showcaseVisuals,
showcaseAxe,
showcaseAC,
showcaseGP
].map((status, index) => (
<td key={`${name}-${index}`}>
showcaseGP,
accessibilityReview
}) => {
const stable =
singleComponentVisuals &&
singleComponentAxe &&
showcaseVisuals &&
showcaseAxe &&
showcaseAC &&
showcaseGP &&
accessibilityReview?.status === 'DONE';
return (
<tr key={name}>
<td>{name}</td>
{[
singleComponentVisuals,
singleComponentAxe,
showcaseVisuals,
showcaseAxe,
showcaseAC,
showcaseGP
].map((status, index) => (
<td key={`${name}-${index}`}>
<DBInfotext
semantic={
status
? 'successful'
: 'critical'
}>
{status ? 'Done' : 'Missing'}
</DBInfotext>
</td>
))}
<td>
<AccessibilityReviewInfo
{...accessibilityReview}
/>
</td>
<td>
<DBInfotext
semantic={
status
stable
? 'successful'
: 'critical'
}
icon={
status
? 'check_circle'
: 'cross_circle'
}>
{status ? 'Done' : 'Missing'}
{stable ? 'Done 🎉' : 'Missing'}
</DBInfotext>
</td>
))}
</tr>
)
</tr>
);
}
)}
</tbody>
</table>
Expand Down
12 changes: 11 additions & 1 deletion showcases/patternhub/scripts/generate-test-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const generateTestTable = () => {
const docs = JSON.parse(
FS.readFileSync('./../../output/docs.json', 'utf8').toString()
);
const accessibilityReview = JSON.parse(
FS.readFileSync(
'./../shared/_accessibility-review.json',
'utf8'
).toString()
);
const data = [];
for (const key of Object.keys(docs)) {
const componentName = getComponentName(key);
Expand All @@ -26,14 +32,18 @@ const generateTestTable = () => {
const hasScreenReaderTest = FS.existsSync(
`./../../showcases/screen-reader/tests/${componentName}.spec.ts`
);

data.push({
name: componentName,
singleComponentVisuals: hasComponentTest,
singleComponentAxe: hasComponentTest,
showcaseVisuals: hasShowcaseTest,
showcaseAxe: hasShowcaseTest,
showcaseAC: hasShowcaseTest,
showcaseGP: hasScreenReaderTest
showcaseGP: hasScreenReaderTest,
accessibilityReview: accessibilityReview.find(
(ar) => ar.name === componentName
)
});
}

Expand Down
47 changes: 47 additions & 0 deletions showcases/shared/_accessibility-review.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"name": "drawer",
"status": "REVIEW",
"date": "2023-11-23"
},
{
"name": "button",
"status": "REVIEW",
"date": "2023-11-23"
},
{
"name": "link",
"status": "DONE",
"date": "2023-11-23"
},
{
"name": "input",
"status": "DONE",
"date": "2023-11-23"
},
{
"name": "radio",
"status": "REVIEW",
"date": "2023-11-23"
},
{
"name": "checkbox",
"status": "REVIEW",
"date": "2023-11-23"
},
{
"name": "select",
"status": "DONE",
"date": "2023-11-23"
},
{
"name": "infotext",
"status": "DONE",
"date": "2023-11-23"
},
{
"name": "notification",
"status": "DONE",
"date": "2023-11-23"
}
]
Loading