26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/')
|
|
})
|
|
|
|
test('shows an error for invalid credentials', async ({ page }) => {
|
|
await page.getByLabel('Username').fill('admin')
|
|
await page.getByRole('textbox', { name: 'Password', exact: true }).fill('wrong-password')
|
|
await page.getByRole('button', { name: 'Sign in' }).click()
|
|
|
|
await expect(page.getByRole('alert')).toHaveText('Invalid username or password')
|
|
})
|
|
|
|
test('logs in with the initialized admin user', async ({ page }) => {
|
|
await page.getByLabel('Username').fill('admin')
|
|
await page.getByRole('textbox', { name: 'Password', exact: true }).fill('admin')
|
|
await page.getByRole('button', { name: 'Sign in' }).click()
|
|
|
|
await expect(page).toHaveURL('/users')
|
|
await expect(page.getByRole('heading', { name: 'User Management' })).toBeVisible()
|
|
const adminRow = page.getByRole('row').filter({ hasText: 'admin' })
|
|
await expect(adminRow).toContainText('admin')
|
|
await expect(page.getByRole('button', { name: 'Sign out' })).toBeVisible()
|
|
})
|