-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add testing table for patternhub (#2983)
* docs: add testing table for patternhub * fix: issue with patternhub build
- Loading branch information
Showing
7 changed files
with
155 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,5 @@ components/code-docs/ | |
!components/06-feedback.mdx | ||
!.env | ||
/generated.js | ||
|
||
data/testing-table.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
showcases/patternhub/pages/foundations/test-table/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
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 | ||
|
||
const tableHeaders = [ | ||
{ | ||
label: 'Component' | ||
}, | ||
{ | ||
label: 'Single Component: Visuals', | ||
href: 'https://playwright.dev/docs/screenshots' | ||
}, | ||
{ | ||
label: 'Single Component: A11y (Axe)', | ||
href: 'https://github.com/dequelabs/axe-core' | ||
}, | ||
{ | ||
label: 'Showcase: Visuals', | ||
href: 'https://playwright.dev/docs/screenshots' | ||
}, | ||
{ | ||
label: 'Showcase: A11y (Axe)', | ||
href: 'https://github.com/dequelabs/axe-core' | ||
}, | ||
{ | ||
label: 'Showcase: A11y (Accessibility-Checker)', | ||
href: 'https://github.com/IBMa/equal-access' | ||
}, | ||
{ | ||
label: 'Showcase: A11y (Screen-Reader)', | ||
href: 'https://github.com/guidepup/guidepup' | ||
} | ||
]; | ||
|
||
const TestTable = () => { | ||
return ( | ||
<DefaultPage> | ||
<table> | ||
<thead> | ||
<tr> | ||
{tableHeaders.map((header) => ( | ||
<th key={header.label}> | ||
{header.href ? ( | ||
<a | ||
href={header.href} | ||
target="_blank" | ||
referrerPolicy="no-referrer"> | ||
{header.label} | ||
</a> | ||
) : ( | ||
header.label | ||
)} | ||
</th> | ||
))} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{testTableData.map( | ||
({ | ||
name, | ||
singleComponentVisuals, | ||
singleComponentAxe, | ||
showcaseVisuals, | ||
showcaseAxe, | ||
showcaseAC, | ||
showcaseGP | ||
}) => ( | ||
<tr key={name}> | ||
<td>{name}</td> | ||
{[ | ||
singleComponentVisuals, | ||
singleComponentAxe, | ||
showcaseVisuals, | ||
showcaseAxe, | ||
showcaseAC, | ||
showcaseGP | ||
].map((status, index) => ( | ||
<td key={`${name}-${index}`}> | ||
<DBInfotext | ||
semantic={ | ||
status | ||
? 'successful' | ||
: 'critical' | ||
} | ||
icon={ | ||
status | ||
? 'check_circle' | ||
: 'cross_circle' | ||
}> | ||
{status ? 'Done' : 'Missing'} | ||
</DBInfotext> | ||
</td> | ||
))} | ||
</tr> | ||
) | ||
)} | ||
</tbody> | ||
</table> | ||
</DefaultPage> | ||
); | ||
}; | ||
|
||
export default TestTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import FS from 'node:fs'; | ||
import { getComponentName } from './utils.js'; | ||
|
||
const generateTestTable = () => { | ||
const docs = JSON.parse( | ||
FS.readFileSync('./../../output/docs.json', 'utf8').toString() | ||
); | ||
const data = []; | ||
for (const key of Object.keys(docs)) { | ||
const componentName = getComponentName(key); | ||
if ( | ||
componentName.endsWith('-list') || | ||
componentName.endsWith('-panel') || | ||
componentName.endsWith('-item') | ||
) { | ||
// We don't want to add something like accordion-item | ||
continue; | ||
} | ||
|
||
const hasComponentTest = FS.existsSync( | ||
`./../../packages/components/src/components/${componentName}/${componentName}.spec.tsx` | ||
); | ||
const hasShowcaseTest = FS.existsSync( | ||
`./../../showcases/e2e/${componentName}/showcase-${componentName}.spec.ts` | ||
); | ||
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 | ||
}); | ||
} | ||
|
||
FS.writeFileSync( | ||
`./data/testing-table.ts`, | ||
'export const testTableData: any[] = ' + JSON.stringify(data) | ||
); | ||
}; | ||
|
||
generateTestTable(); |