e2e: add medium-priority Playwright coverage (#44)
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m29s
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m29s
Co-authored-by: Shaun Campbell <shaun@campbellwireless.net> Reviewed-on: #44 Co-authored-by: AI Agent <ai-agent@campbellwireless.net> Co-committed-by: AI Agent <ai-agent@campbellwireless.net>
This commit was merged in pull request #44.
This commit is contained in:
79
e2e/lodging-permissions.test.ts
Normal file
79
e2e/lodging-permissions.test.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { TEST_USERS } from './setup/test-users.js';
|
||||
import { ensureSelfProfile, loginAsLocalUser } from './helpers/auth.js';
|
||||
import {
|
||||
addTraveller,
|
||||
createTrip,
|
||||
openAddToTripMenuItem,
|
||||
openAddTraveller,
|
||||
uniqueSuffix
|
||||
} from './helpers/trip.js';
|
||||
|
||||
test.beforeEach(async ({ context }) => {
|
||||
await context.clearCookies();
|
||||
});
|
||||
|
||||
test('lodging guest selection and access boundaries are enforced', async ({ page }) => {
|
||||
const suffix = uniqueSuffix();
|
||||
const tripName = `E2E Lodging ${suffix}`;
|
||||
const guestFirst = 'Jordan';
|
||||
const guestLast = 'Guest';
|
||||
const guestEmail = `jordan.${suffix}@test.local`;
|
||||
const lodgingName = `E2E Lodge ${suffix}`;
|
||||
|
||||
await loginAsLocalUser(page, TEST_USERS.regular.username, TEST_USERS.regular.password);
|
||||
await ensureSelfProfile(page);
|
||||
const { tripUrl } = await createTrip(page, {
|
||||
name: tripName,
|
||||
description: 'Lodging guest coverage'
|
||||
});
|
||||
|
||||
const selfName = 'E2E User';
|
||||
await openAddTraveller(page);
|
||||
const travellerDialog = page.getByRole('dialog', { name: 'Add traveller' });
|
||||
await expect(travellerDialog).toBeVisible();
|
||||
const selfButton = travellerDialog.getByRole('button', { name: /You/ }).first();
|
||||
if (await selfButton.isVisible().catch(() => false)) {
|
||||
await selfButton.click();
|
||||
await expect(travellerDialog).toBeHidden();
|
||||
} else {
|
||||
const selfNameButton = travellerDialog.getByRole('button', { name: selfName }).first();
|
||||
if (await selfNameButton.isVisible().catch(() => false)) {
|
||||
await selfNameButton.click();
|
||||
await expect(travellerDialog).toBeHidden();
|
||||
} else {
|
||||
await travellerDialog.getByRole('button', { name: 'Close' }).click();
|
||||
await expect(travellerDialog).toBeHidden();
|
||||
}
|
||||
}
|
||||
|
||||
await addTraveller(page, {
|
||||
firstName: guestFirst,
|
||||
lastName: guestLast,
|
||||
email: guestEmail
|
||||
});
|
||||
|
||||
await openAddToTripMenuItem(page, 'Lodgings');
|
||||
const lodgingDialog = page.getByRole('dialog', { name: 'Add lodging' });
|
||||
await expect(lodgingDialog).toBeVisible();
|
||||
|
||||
const guestName = `${guestFirst} ${guestLast}`;
|
||||
await expect(lodgingDialog.getByRole('checkbox', { name: guestName })).toBeVisible();
|
||||
|
||||
await lodgingDialog.getByLabel('Name', { exact: false }).fill(lodgingName);
|
||||
await lodgingDialog.getByText(guestName, { exact: true }).click();
|
||||
await lodgingDialog.getByRole('button', { name: 'Add lodging' }).click();
|
||||
await expect(lodgingDialog).toBeHidden();
|
||||
|
||||
await expect(page.getByText(lodgingName, { exact: true })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Edit lodging' }).click();
|
||||
const editDialog = page.getByRole('dialog', { name: 'Edit lodging' });
|
||||
await expect(editDialog).toBeVisible();
|
||||
await expect(editDialog.getByRole('checkbox', { name: guestName })).toBeChecked();
|
||||
await editDialog.getByRole('button', { name: 'Close' }).click();
|
||||
|
||||
await page.context().clearCookies();
|
||||
await loginAsLocalUser(page, TEST_USERS.admin.username, TEST_USERS.admin.password);
|
||||
await page.goto(tripUrl);
|
||||
await expect(page.getByText(/Trip not found|Not found/i)).toBeVisible();
|
||||
});
|
||||
Reference in New Issue
Block a user