Files
sales-trainer/frontend/tests/e2e/auth.spec.js

15 lines
795 B
JavaScript

import { expect, test } from '@playwright/test'
test('login page renders and protected routes redirect without a token', async ({ page }) => {
await page.goto('/training')
await expect(page.locator('input[autocomplete="username"]')).toBeVisible()
await expect(page.locator('input[autocomplete="current-password"]')).toBeVisible()
await expect(page.locator('h1')).toContainText(/ระบบฝึกทักษะการขาย|Sales Trainer/)
expect(new URL(page.url()).pathname).toBe('/login')
expect(new URL(page.url()).searchParams.get('redirect')).toBe('/training')
const widthState = await page.evaluate(() => ({ width: window.innerWidth, scrollWidth: document.documentElement.scrollWidth }))
expect(widthState.scrollWidth).toBeLessThanOrEqual(widthState.width)
})