Files

29 lines
1.8 KiB
JavaScript

import AxeBuilder from '@axe-core/playwright'
import { expect, test } from '@playwright/test'
for (const theme of ['dark', 'light']) {
test(`Projects and case studies work in ${theme}`, async ({ page }) => {
await page.addInitScript(value => localStorage.setItem('bortstack-theme', value), theme)
await page.goto('/projects')
await expect(page.getByText('In development', { exact: true })).toBeVisible()
await expect(page.getByText('Small showcase project', { exact: true })).toBeVisible()
await expect(page.getByText('Genuine project screenshot pending', { exact: true })).toHaveCount(3)
expect((await new AxeBuilder({ page }).analyze()).violations).toEqual([])
await page.getByRole('link', { name: 'View case study', exact: true }).focus()
await page.keyboard.press('Enter')
await expect(page.getByRole('heading', { level: 1, name: 'RouletteBuddy' })).toBeVisible()
await expect(page.getByRole('heading', { name: 'Work to date' })).toBeVisible()
await page.getByRole('link', { name: 'All projects' }).click()
await page.getByRole('link', { name: 'Explore PitchInvader' }).click()
await expect(page.getByRole('heading', { level: 1, name: 'PitchInvader' })).toBeVisible()
await expect(page.getByText('In development', { exact: true })).toBeVisible()
expect((await new AxeBuilder({ page }).analyze()).violations).toEqual([])
expect(await page.locator('html').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true)
await page.goto('/projects/api-admin')
await expect(page.getByRole('list', { name: 'Technologies' }).getByText('SQLite')).toBeVisible()
await page.goto('/projects/unavailable')
await expect(page.getByRole('heading', { name: 'Project not found' })).toBeVisible()
await expect(page.locator('meta[name="robots"]')).toHaveAttribute('content', 'noindex, nofollow')
})
}