admin/e2e/shared/accessibility.spec.ts
alisaza f9a9afc697 feat: add layout components for various admin dashboard pages
- Introduced layout components for multiple admin dashboard sections including events, audit logs, bank accounts, blog articles, bookings, chat oversight, cities, contact messages, dashboard, discount codes, event categories, guest lists, identity verifications, manage events, manual notifications, notification rules, payments, provinces, push deliveries, reviews, settlements, sms messages, support tickets, user reports, and users.
- Updated metadata for the auth layout to include the admin page title.
- Modified branch protection documentation to clarify deployment notifications.
2026-09-05 14:29:43 +03:30

57 lines
2.3 KiB
TypeScript

import AxeBuilder from '@axe-core/playwright'
import { expect, test, type Page } from '@playwright/test'
import { authenticateAs } from '@/e2e/fixtures/session'
const expectNoSeriousViolations = async (page: Page) => {
await page.waitForLoadState('domcontentloaded')
await page.locator('body').waitFor({ state: 'visible' })
let violations
try {
;({ violations } = await new AxeBuilder({ page }).withTags(['wcag2a', 'wcag2aa', 'wcag21aa']).analyze())
} catch (error) {
if (!(error instanceof Error) || !error.message.includes('Execution context was destroyed')) throw error
await page.waitForLoadState('domcontentloaded')
;({ violations } = await new AxeBuilder({ page }).withTags(['wcag2a', 'wcag2aa', 'wcag21aa']).analyze())
}
const blocking = violations.filter(({ impact }) => impact === 'critical' || impact === 'serious')
expect(blocking, blocking.map(({ id, help }) => `${id}: ${help}`).join('\n')).toEqual([])
}
test('auth route has no serious automated accessibility violations', async ({ page }) => {
await page.goto('/auth')
await expectNoSeriousViolations(page)
})
test('admin shell has no serious automated accessibility violations', async ({ context, page }) => {
await authenticateAs(context, page, 'admin')
await page.route('**/api/v1/**', (route) => route.fulfill({ json: { success: true, data: {} } }))
await page.route('**/api/v1/admin/reports/overview', (route) =>
route.fulfill({
json: {
success: true,
data: {
users: { total: 0, active: 0, pending: 0, suspended: 0 },
events: {
total: 0,
active: 0,
totalHeld: 0,
byStatus: { draft: 0, pending_review: 0, published: 0, full: 0, cancelled: 0, completed: 0 },
},
bookings: { total: 0, byStatus: { pending_payment: 0, confirmed: 0, cancelled: 0, expired: 0, refunded: 0, no_show: 0 } },
identityVerifications: { none: 0, pending: 0, verified: 0, rejected: 0 },
financial: { totalCommissionCollected: '0', totalWalletBalance: '0' },
},
},
})
)
await page.goto('/dashboard')
await expect(page.getByText('کل کاربران').first()).toBeVisible()
await expect(page.locator('#mainContent')).toHaveCSS('opacity', '1')
await expectNoSeriousViolations(page)
})