32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
import { registerViaUi, uniqueUsername } from './helpers/auth'
|
|
|
|
test.describe('UI quality', () => {
|
|
test('no unexpected console errors on home and RTL layout', async ({ page }) => {
|
|
const errors: string[] = []
|
|
page.on('pageerror', (err) => errors.push(err.message))
|
|
page.on('console', (msg) => {
|
|
if (msg.type() === 'error') errors.push(msg.text())
|
|
})
|
|
|
|
const user = uniqueUsername('ui')
|
|
await registerViaUi(page, user, 'pass1234')
|
|
const bodyDir = await page.evaluate(() => getComputedStyle(document.body).direction)
|
|
expect(bodyDir).toBe('rtl')
|
|
|
|
const overflow = await page.evaluate(() => document.documentElement.scrollWidth > window.innerWidth + 2)
|
|
expect(overflow).toBe(false)
|
|
|
|
const filtered = errors.filter(
|
|
(e) => !e.includes('favicon') && !e.includes('DevTools') && !e.includes('404'),
|
|
)
|
|
expect(filtered).toEqual([])
|
|
})
|
|
|
|
test('keyboard focus reaches login username field', async ({ page }) => {
|
|
await page.goto('/login')
|
|
await page.getByLabel('نام کاربری').focus()
|
|
await expect(page.getByLabel('نام کاربری')).toBeFocused()
|
|
})
|
|
})
|