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:
60
e2e/package-tours-import.test.ts
Normal file
60
e2e/package-tours-import.test.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { TEST_USERS } from './setup/test-users.js';
|
||||
import { loginAsLocalUser } from './helpers/auth.js';
|
||||
import { createTrip, openAddToTripMenuItem, uniqueSuffix } from './helpers/trip.js';
|
||||
|
||||
test.beforeEach(async ({ context }) => {
|
||||
await context.clearCookies();
|
||||
});
|
||||
|
||||
test('admin can import a package tour and attach it to a trip', async ({ page }) => {
|
||||
if (!process.env.GADVENTURES_API_KEY) {
|
||||
test.skip(true, 'G Adventures API key not set for deterministic import');
|
||||
}
|
||||
|
||||
const suffix = uniqueSuffix();
|
||||
const operatorName = 'G Adventures';
|
||||
|
||||
await loginAsLocalUser(page, TEST_USERS.admin.username, TEST_USERS.admin.password);
|
||||
await page.goto('/trips/admin/tour-operators');
|
||||
await expect(page.getByRole('heading', { name: 'Tour Operators' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Add operator' }).click();
|
||||
|
||||
await page.getByPlaceholder('Search or type operator name').fill(operatorName);
|
||||
await page.getByRole('button', { name: 'Add operator' }).last().click();
|
||||
await expect(page.getByText(operatorName, { exact: true })).toBeVisible();
|
||||
|
||||
const operatorCard = page
|
||||
.getByText(operatorName, { exact: true })
|
||||
.locator('xpath=ancestor::div[contains(@class,"rounded-xl")]');
|
||||
await operatorCard.getByRole('link', { name: 'Tours' }).click();
|
||||
await expect(page.getByRole('heading', { name: operatorName })).toBeVisible();
|
||||
|
||||
await page.getByRole('button', { name: 'Import' }).click();
|
||||
const importDialog = page.getByRole('dialog', { name: 'Import tours' });
|
||||
await expect(importDialog).toBeVisible();
|
||||
await importDialog.getByPlaceholder('Search tours...').fill('a');
|
||||
const results = importDialog.locator('ul button');
|
||||
await expect(results.first()).toBeVisible();
|
||||
|
||||
const tourTitle = (await results.first().innerText()).trim();
|
||||
await results.first().click();
|
||||
await importDialog.getByRole('button', { name: 'Import tour' }).click();
|
||||
await expect(importDialog).toBeHidden();
|
||||
await expect(page.getByRole('link', { name: tourTitle })).toBeVisible();
|
||||
|
||||
await page.context().clearCookies();
|
||||
await loginAsLocalUser(page, TEST_USERS.regular.username, TEST_USERS.regular.password);
|
||||
await createTrip(page, { name: `E2E Tour Trip ${suffix}` });
|
||||
|
||||
await openAddToTripMenuItem(page, 'Package Tours');
|
||||
const addDialog = page.getByRole('dialog', { name: 'Add package tour' });
|
||||
await expect(addDialog).toBeVisible();
|
||||
await addDialog.getByPlaceholder('Search or type operator name').fill(operatorName);
|
||||
await addDialog.getByRole('button', { name: operatorName }).click();
|
||||
await expect(addDialog.locator('select')).toContainText(tourTitle);
|
||||
await addDialog.locator('select').first().selectOption({ label: tourTitle });
|
||||
await addDialog.getByRole('button', { name: 'Add tour' }).click();
|
||||
await expect(addDialog).toBeHidden();
|
||||
await expect(page.getByText(tourTitle, { exact: true })).toBeVisible();
|
||||
});
|
||||
Reference in New Issue
Block a user