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); });