diff --git a/e2e-tests/assistant-view.spec.ts b/e2e-tests/assistant-view.spec.ts index b2fe6644..ffb5b62a 100644 --- a/e2e-tests/assistant-view.spec.ts +++ b/e2e-tests/assistant-view.spec.ts @@ -12,17 +12,26 @@ test('Should fetch Kristiansund - Molde and loading more after first result', as await page.getByRole('textbox', { name: 'From' }).click(); await page.getByRole('textbox', { name: 'From' }).fill('Kristiansund'); - await page.getByRole('option', { name: 'Kristiansund Kristiansund' }).click(); + await page + .getByRole('option', { name: 'Kristiansund Kristiansund', exact: true }) + .click(); await page.getByRole('textbox', { name: 'To' }).click(); await page.getByRole('textbox', { name: 'To' }).fill('Molde'); + + const initialRequest = page.waitForResponse((request) => { + return request.url().includes('trip') && request.url().includes('cursor'); + }); + await page.getByRole('option', { name: 'Molde Molde', exact: true }).click(); + await initialRequest; + await page.getByRole('button', { name: 'More choices' }).click(); await page.getByText('Bus', { exact: true }).click(); await page.getByRole('button', { name: 'Find departures' }).click(); - const tripPatternItem = page.getByTestId('trip-pattern-0'); + const tripPatternItem = page.getByTestId('tripPattern-0-0'); await tripPatternItem.waitFor(); const additionalRequest = page.waitForRequest((request) => { @@ -100,6 +109,6 @@ test('should show boats and message on Correspondance', async ({ page }) => { await additionalRequest2; - await page.getByTestId('trip-pattern-0').click(); + await page.getByTestId('tripPattern-0-0').click(); await expect(page.getByText('Correspondance between 1145')).toBeVisible(); }); diff --git a/e2e-tests/fram-specific/line-filter.spec.ts b/e2e-tests/fram-specific/line-filter.spec.ts index 8fde2b36..bb1af573 100644 --- a/e2e-tests/fram-specific/line-filter.spec.ts +++ b/e2e-tests/fram-specific/line-filter.spec.ts @@ -37,7 +37,7 @@ test('Should filter on line 701', async ({ page }) => { await page.getByRole('button', { name: 'Find departures' }).click(); await tripResponse2; - const tripPatternItem2 = page.getByTestId('trip-pattern-0'); + const tripPatternItem2 = page.getByTestId('tripPattern-0-0'); await tripPatternItem2.waitFor(); await expect(tripPatternItem2).toBeVisible(); diff --git a/src/page-modules/assistant/trip/index.tsx b/src/page-modules/assistant/trip/index.tsx index b53cde53..c0be6222 100644 --- a/src/page-modules/assistant/trip/index.tsx +++ b/src/page-modules/assistant/trip/index.tsx @@ -100,6 +100,7 @@ export default function Trip({ tripQuery, fallback }: TripProps) { tripPattern={tripPattern} delay={i * 0.1} index={i} + testId={`tripPattern-${tripIndex}-${i}`} /> )), diff --git a/src/page-modules/assistant/trip/trip-pattern/index.tsx b/src/page-modules/assistant/trip/trip-pattern/index.tsx index df2ab95d..029da9c4 100644 --- a/src/page-modules/assistant/trip/trip-pattern/index.tsx +++ b/src/page-modules/assistant/trip/trip-pattern/index.tsx @@ -19,12 +19,14 @@ type TripPatternProps = { tripPattern: TripPatternType; delay: number; index: number; + testId?: string; }; export default function TripPattern({ tripPattern, delay, index, + testId, }: TripPatternProps) { const { t, language } = useTranslation(); @@ -70,7 +72,7 @@ export default function TripPattern({