Some checks failed
Build and Push Docker Images (Trusted) / build-and-push (., docker/caddy/Dockerfile, caddy) (push) Has been cancelled
Build and Push Docker Images (Trusted) / build-and-push (., docker/l4-port-manager/Dockerfile, l4-port-manager) (push) Has been cancelled
Build and Push Docker Images (Trusted) / build-and-push (., docker/web/Dockerfile, web) (push) Has been cancelled
Tests / test (push) Has been cancelled
51 lines
2.1 KiB
TypeScript
Executable File
51 lines
2.1 KiB
TypeScript
Executable File
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Profile', () => {
|
|
test('profile page loads without redirecting to login', async ({ page }) => {
|
|
await page.goto('/profile');
|
|
await expect(page).not.toHaveURL(/login/);
|
|
await expect(page.locator('body')).toBeVisible();
|
|
});
|
|
|
|
test('profile page shows username or email', async ({ page }) => {
|
|
await page.goto('/profile');
|
|
// Use first() since username appears in sidebar + profile body
|
|
await expect(page.locator('text=/testadmin|testadmin@/i').first()).toBeVisible({ timeout: 5000 });
|
|
});
|
|
|
|
test('Change Password button is visible', async ({ page }) => {
|
|
await page.goto('/profile');
|
|
await expect(page.getByRole('button', { name: /change password|set password/i })).toBeVisible();
|
|
});
|
|
|
|
test('change password: wrong current password shows error', async ({ page }) => {
|
|
await page.goto('/profile');
|
|
|
|
await page.getByRole('button', { name: /change password|set password/i }).click();
|
|
await expect(page.getByRole('dialog')).toBeVisible();
|
|
|
|
await page.getByLabel('Current Password', { exact: true }).fill('WrongCurrentPassword!');
|
|
await page.getByLabel('New Password', { exact: true }).fill('NewPassword2026!');
|
|
await page.getByLabel('Confirm New Password', { exact: true }).fill('NewPassword2026!');
|
|
|
|
await page.getByRole('button', { name: /change password|set password/i }).last().click();
|
|
|
|
// Should show an error alert
|
|
await expect(page.locator('[role="alert"]')).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('change password: new password too short shows validation error', async ({ page }) => {
|
|
await page.goto('/profile');
|
|
|
|
await page.getByRole('button', { name: /change password|set password/i }).click();
|
|
await expect(page.getByRole('dialog')).toBeVisible();
|
|
|
|
await page.getByLabel('New Password', { exact: true }).fill('short');
|
|
await page.getByLabel('Confirm New Password', { exact: true }).fill('short');
|
|
|
|
await page.getByRole('button', { name: /change password|set password/i }).last().click();
|
|
|
|
await expect(page.locator('text=/at least 12 characters/i')).toBeVisible({ timeout: 5000 });
|
|
});
|
|
});
|