All checks were successful
PR Checks / lint-test-and-docker-build (pull_request) Successful in 2m18s
52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
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.getByLabel('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);
|
|
});
|