From d43889c7b0e89e94f989841c921aee9da462023c Mon Sep 17 00:00:00 2001 From: AI Agent Date: Mon, 23 Feb 2026 00:48:21 +0000 Subject: [PATCH] trips) add low-priority e2e smoke coverage (#46) Reviewed-on: https://cloud.campbellwireless.net/git/campbellwireless/trips/pulls/46 Co-authored-by: AI Agent Co-committed-by: AI Agent --- e2e/evidence-workflow.test.ts | 9 ++++ e2e/smoke-cross-role.test.ts | 79 +++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 e2e/evidence-workflow.test.ts create mode 100644 e2e/smoke-cross-role.test.ts diff --git a/e2e/evidence-workflow.test.ts b/e2e/evidence-workflow.test.ts new file mode 100644 index 0000000..a1c51c4 --- /dev/null +++ b/e2e/evidence-workflow.test.ts @@ -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(); +}); diff --git a/e2e/smoke-cross-role.test.ts b/e2e/smoke-cross-role.test.ts new file mode 100644 index 0000000..1c93e1d --- /dev/null +++ b/e2e/smoke-cross-role.test.ts @@ -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[0]): Promise { + 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(); +});