Compare commits
1 Commits
c12b21ae8a
...
ai-agent/4
| Author | SHA1 | Date | |
|---|---|---|---|
| 9dd4025a81 |
9
e2e/evidence-workflow.test.ts
Normal file
9
e2e/evidence-workflow.test.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { TEST_USERS } from './setup/test-users.js';
|
||||
import { loginAsLocalUser } from './helpers/auth.js';
|
||||
|
||||
test('evidence workflow @evidence login to dashboard', async ({ page }) => {
|
||||
await loginAsLocalUser(page, TEST_USERS.regular.username, TEST_USERS.regular.password);
|
||||
await expect(page).toHaveURL(/\/trips\/dashboard/);
|
||||
await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
|
||||
});
|
||||
79
e2e/smoke-cross-role.test.ts
Normal file
79
e2e/smoke-cross-role.test.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { TEST_USERS } from './setup/test-users.js';
|
||||
import { loginAsLocalUser } from './helpers/auth.js';
|
||||
import { uniqueSuffix } from './helpers/trip.js';
|
||||
|
||||
const DASHBOARD_URL = '/trips/dashboard';
|
||||
const ADMIN_USERS_URL = '/trips/admin/users';
|
||||
|
||||
async function expectDashboardLoaded(page: Parameters<typeof loginAsLocalUser>[0]): Promise<void> {
|
||||
await expect(page).toHaveURL(/\/trips\/dashboard/);
|
||||
await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ context }) => {
|
||||
await context.clearCookies();
|
||||
});
|
||||
|
||||
test('regular user smoke', async ({ page }) => {
|
||||
await loginAsLocalUser(page, TEST_USERS.regular.username, TEST_USERS.regular.password);
|
||||
await expectDashboardLoaded(page);
|
||||
|
||||
await page.goto(ADMIN_USERS_URL);
|
||||
await expect(page).toHaveURL(/\/trips\/dashboard/);
|
||||
await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('admin user smoke', async ({ page }) => {
|
||||
await loginAsLocalUser(page, TEST_USERS.admin.username, TEST_USERS.admin.password);
|
||||
await expectDashboardLoaded(page);
|
||||
|
||||
await page.goto(ADMIN_USERS_URL);
|
||||
await expect(page).toHaveURL(/\/trips\/admin\/users/);
|
||||
await expect(page.getByRole('heading', { name: 'Users' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('disposable local user smoke', async ({ page }) => {
|
||||
const suffix = uniqueSuffix();
|
||||
const username = `e2e_disposable_${suffix}`;
|
||||
const fullName = `E2E Disposable ${suffix}`;
|
||||
const email = `e2e_disposable_${suffix}@test.local`;
|
||||
const password = `TempPass-${suffix}-1234`;
|
||||
|
||||
await loginAsLocalUser(page, TEST_USERS.admin.username, TEST_USERS.admin.password);
|
||||
await page.goto(ADMIN_USERS_URL);
|
||||
await expect(page.getByRole('heading', { name: 'Users' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Add User' }).click();
|
||||
|
||||
const addDialog = page
|
||||
.locator('[role="dialog"]')
|
||||
.filter({ has: page.getByRole('heading', { name: 'Add user' }) })
|
||||
.first();
|
||||
await expect(addDialog).toBeVisible();
|
||||
|
||||
await addDialog.locator('input[type="text"]').nth(0).fill(username);
|
||||
await addDialog.locator('input[type="text"]').nth(1).fill(fullName);
|
||||
await addDialog.getByPlaceholder('name@example.com').fill(email);
|
||||
await addDialog.locator('input[type="password"]').nth(0).fill(password);
|
||||
await addDialog.locator('input[type="password"]').nth(1).fill(password);
|
||||
|
||||
const createResponse = page.waitForResponse((response) => {
|
||||
return (
|
||||
response.url().includes('/admin/api/users') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.ok()
|
||||
);
|
||||
});
|
||||
await addDialog.getByRole('button', { name: 'Create user' }).click();
|
||||
await createResponse;
|
||||
|
||||
await expect(page.getByRole('cell', { name: username, exact: true })).toBeVisible();
|
||||
|
||||
await page.context().clearCookies();
|
||||
await loginAsLocalUser(page, username, password);
|
||||
await expectDashboardLoaded(page);
|
||||
|
||||
await page.goto(ADMIN_USERS_URL);
|
||||
await expect(page).toHaveURL(/\/trips\/dashboard/);
|
||||
await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
|
||||
});
|
||||
Reference in New Issue
Block a user