github-docs-arabic-enhanced / src /fixtures /tests /playwright-a11y.spec.ts
AbdulElahGwaith's picture
Upload folder using huggingface_hub
88df9e4 verified
import { test, expect } from '@playwright/test'
import AxeBuilder from '@axe-core/playwright'
import { turnOffExperimentsInPage, turnOnExperimentsInPage } from '../helpers/turn-off-experiments'
const pages: { [key: string]: string } = {
category: '/actions/category',
codeAnnotations: '/get-started/markdown/code-annotations',
guides: '/code-security/guides',
homepage: '/',
learningPath:
'/code-security/getting-started/quickstart?learn=foo_bar&learnProduct=code-security',
mapAndTopic: '/actions/category/subcategory',
procedural: '/get-started/images/images-in-lists',
productLanding: '/code-security',
restCategory: '/rest/actions/artifacts',
restLanding: '/rest',
restOverview: '/rest/about-the-rest-api/comparing-githubs-rest-api-and-graphql-api',
search: '/search?q=playwright',
switchers: '/get-started/liquid/tool-platform-switcher',
tableWithHeaders: '/get-started/liquid/table-row-headers',
video: '/get-started',
videoTranscript: '/get-started/video-transcripts/transcript--my-awesome-video',
}
// create a test for each page, will eventually be separated into finer grain tests
for (const pageName of Object.keys(pages)) {
test.describe(`${pageName}`, () => {
test('full page axe scan without experiments', async ({ page }) => {
await page.goto(pages[pageName])
await turnOffExperimentsInPage(page)
const accessibilityScanResults = await new AxeBuilder({ page }).analyze()
expect(accessibilityScanResults.violations).toEqual([])
})
})
test.describe(`${pageName} (with experiments)`, () => {
test('full page axe scan with experiments', async ({ page }) => {
await page.goto(pages[pageName])
await turnOnExperimentsInPage(page)
const accessibilityScanResults = await new AxeBuilder({ page }).analyze()
expect(accessibilityScanResults.violations).toEqual([])
})
})
}