From 971b98bf58c0bc429d0a185327367fe81fb4d73a Mon Sep 17 00:00:00 2001 From: philipp Date: Mon, 4 Mar 2024 09:49:04 +0100 Subject: [PATCH] make frontend tests work @ mobile view --- frontend/tests/log.spec.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/tests/log.spec.ts b/frontend/tests/log.spec.ts index 27b011d..f714b5c 100644 --- a/frontend/tests/log.spec.ts +++ b/frontend/tests/log.spec.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test'; -test('Cox can start and cancel trip', async ({ page }) => { +test('Cox can start and cancel trip', async ({ page }, testInfo) => { await page.goto('http://localhost:8000/auth'); await page.getByPlaceholder('Name').click(); await page.getByPlaceholder('Name').fill('cox2'); @@ -10,7 +10,12 @@ test('Cox can start and cancel trip', async ({ page }) => { await page.goto('http://localhost:8000/'); await page.getByRole('link', { name: 'Ausfahrt eintragen' }).click(); - await page.getByText('Joe', { exact: true }).click(); + if (testInfo.project.name.includes('Mobile')) { // No left boat selector on mobile views + await page.getByText('Kaputtes Boot :-( (7 x)').nth(1).click(); + await page.getByRole('option', { name: 'Joe' }).click(); + } else{ + await page.getByText('Joe', { exact: true }).click(); + } await page.getByPlaceholder('Ruderer auswählen').click(); await page.getByRole('option', { name: 'rower2' }).click(); await page.getByRole('option', { name: 'cox2' }).click(); @@ -23,13 +28,12 @@ test('Cox can start and cancel trip', async ({ page }) => { await page.getByRole('link', { name: 'Joe' }).click(); page.once('dialog', dialog => { - console.log(`Dialog message: ${dialog.message()}`); dialog.accept().catch(() => {}); }); await page.getByRole('link', { name: 'Löschen' }).click(); }); -test('Cox can start and finish trip', async ({ page }) => { +test('Cox can start and finish trip', async ({ page }, testInfo) => { await page.goto('http://localhost:8000/auth'); await page.getByPlaceholder('Name').click(); await page.getByPlaceholder('Name').fill('cox2'); @@ -39,7 +43,12 @@ test('Cox can start and finish trip', async ({ page }) => { await page.goto('http://localhost:8000/'); await page.getByRole('link', { name: 'Ausfahrt eintragen' }).click(); - await page.getByText('Joe', { exact: true }).click(); + if (testInfo.project.name.includes('Mobile')) { // No left boat selector on mobile views + await page.getByText('Kaputtes Boot :-( (7 x)').nth(1).click(); + await page.getByRole('option', { name: 'Joe' }).click(); + } else{ + await page.getByText('Joe', { exact: true }).click(); + } await page.getByPlaceholder('Ruderer auswählen').click(); await page.getByRole('option', { name: 'rower2' }).click(); await page.getByRole('option', { name: 'cox2' }).click();