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:
51
e2e/transportation-lifecycle.test.ts
Normal file
51
e2e/transportation-lifecycle.test.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { TEST_USERS } from './setup/test-users.js';
|
||||
import { loginAsLocalUser } from './helpers/auth.js';
|
||||
import { addFlight, createTrip, uniqueSuffix } from './helpers/trip.js';
|
||||
|
||||
function formatDate(offsetDays: number): string {
|
||||
const date = new Date();
|
||||
date.setDate(date.getDate() + offsetDays);
|
||||
return date.toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ context }) => {
|
||||
await context.clearCookies();
|
||||
});
|
||||
|
||||
test('transportation lifecycle updates the trip view', async ({ page }) => {
|
||||
const suffix = uniqueSuffix();
|
||||
const tripName = `E2E Transport ${suffix}`;
|
||||
const departureDate = formatDate(30);
|
||||
|
||||
await loginAsLocalUser(page, TEST_USERS.regular.username, TEST_USERS.regular.password);
|
||||
await createTrip(page, {
|
||||
name: tripName,
|
||||
startDate: departureDate,
|
||||
description: 'Transportation lifecycle coverage'
|
||||
});
|
||||
|
||||
await addFlight(page, {
|
||||
departureDate,
|
||||
airlineCode: 'UA',
|
||||
flightNumber: '1001',
|
||||
departureAirport: 'SFO',
|
||||
arrivalAirport: 'LAX'
|
||||
});
|
||||
|
||||
await expect(page.getByRole('heading', { name: 'Transportation' })).toBeVisible();
|
||||
await expect(page.getByText(/UA\s*1001/)).toBeVisible();
|
||||
|
||||
await page.getByRole('button', { name: 'Edit transportation' }).click();
|
||||
const editDialog = page.getByRole('dialog', { name: 'Edit transportation' });
|
||||
await expect(editDialog).toBeVisible();
|
||||
await editDialog.locator('input[name="segments[0][flight_number]"]').fill('1002');
|
||||
await editDialog.getByRole('button', { name: 'Save changes' }).click();
|
||||
await expect(editDialog).toBeHidden();
|
||||
|
||||
await expect(page.getByText(/UA\s*1002/)).toBeVisible();
|
||||
await expect(page.getByText(/UA\s*1001/)).toHaveCount(0);
|
||||
|
||||
await page.getByRole('button', { name: 'Remove transportation' }).click();
|
||||
await expect(page.getByRole('heading', { name: 'Transportation' })).toHaveCount(0);
|
||||
});
|
||||
Reference in New Issue
Block a user