From c372051561b9a13440ff50a0200d441e18d8a963 Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 16 Jan 2024 22:29:57 +0100 Subject: [PATCH] try --- .gitea/workflows/action.yml | 2 +- frontend/tests/cox.spec.ts | 114 ++++++++++++++++++++++++++++ frontend/tests/example.spec.ts | 22 ------ templates/includes/macros.html.tera | 2 +- 4 files changed, 116 insertions(+), 24 deletions(-) create mode 100644 frontend/tests/cox.spec.ts delete mode 100644 frontend/tests/example.spec.ts diff --git a/.gitea/workflows/action.yml b/.gitea/workflows/action.yml index 62422d6..cdf19ad 100644 --- a/.gitea/workflows/action.yml +++ b/.gitea/workflows/action.yml @@ -28,7 +28,7 @@ jobs: - name: Install Playwright Browsers run: cd frontend && npx playwright install --with-deps - name: Run Playwright tests - run: cd frontend && npx playwright test + run: cd frontend && npx playwright test --workers 1 - uses: actions/upload-artifact@v3 if: always() with: diff --git a/frontend/tests/cox.spec.ts b/frontend/tests/cox.spec.ts new file mode 100644 index 0000000..ae65a99 --- /dev/null +++ b/frontend/tests/cox.spec.ts @@ -0,0 +1,114 @@ +import { test, expect } from '@playwright/test'; + +test('cox can create and delete trip', async ({ page }) => { + await page.goto('http://localhost:8000/auth'); + await page.getByPlaceholder('Name').click(); + await page.getByPlaceholder('Name').fill('cox'); + await page.getByPlaceholder('Name').press('Tab'); + await page.getByPlaceholder('Passwort').fill('cox'); + await page.getByPlaceholder('Passwort').press('Enter'); + await page.getByRole('link', { name: 'Geplante Ausfahrten' }).click(); + await page.locator('.relative').first().click(); + await page.locator('#sidebar #planned_starting_time').click(); + await page.locator('#sidebar #planned_starting_time').fill('18:00'); + await page.locator('#sidebar #planned_starting_time').press('Tab'); + await page.locator('#sidebar #planned_starting_time').press('Tab'); + await page.getByRole('spinbutton').fill('5'); + await page.getByRole('button', { name: 'Erstellen', exact: true }).click(); + await page.getByRole('link', { name: 'Geplante Ausfahrten' }).click(); + await expect(page.locator('body')).toContainText('18:00 Uhr (cox) Details'); + + await page.goto('http://localhost:8000/planned'); + await page.getByRole('link', { name: 'Details' }).click(); + await page.getByRole('link', { name: 'Termin löschen' }).click(); + await expect(page.locator('body')).toContainText('Erfolgreich gelöscht!'); +}); + +test.describe('cox can edit trips', () => { + let sharedPage; + + test.beforeEach(async ({ browser }) => { + const page = await browser.newPage(); + + await page.goto('http://localhost:8000/auth'); + await page.getByPlaceholder('Name').click(); + await page.getByPlaceholder('Name').fill('cox'); + await page.getByPlaceholder('Name').press('Tab'); + await page.getByPlaceholder('Passwort').fill('cox'); + await page.getByPlaceholder('Passwort').press('Enter'); + await page.getByRole('link', { name: 'Geplante Ausfahrten' }).click(); + await page.locator('.relative').first().click(); + await page.locator('#sidebar #planned_starting_time').click(); + await page.locator('#sidebar #planned_starting_time').fill('18:00'); + await page.locator('#sidebar #planned_starting_time').press('Tab'); + await page.locator('#sidebar #planned_starting_time').press('Tab'); + await page.getByRole('spinbutton').fill('5'); + await page.getByRole('button', { name: 'Erstellen', exact: true }).click(); + + sharedPage = page; + }); + + test('edit remarks', async () => { + await sharedPage.goto('http://localhost:8000/planned'); + await sharedPage.getByRole('link', { name: 'Details' }).click(); + await sharedPage.locator('#sidebar #notes').click(); + await sharedPage.locator('#sidebar #notes').fill('Meine Anmerkung'); + await sharedPage.getByRole('button', { name: 'Speichern' }).click(); + await sharedPage.getByRole('link', { name: 'Geplante Ausfahrten' }).click(); + await sharedPage.getByRole('link', { name: 'Details' }).click(); + await expect(sharedPage.locator('#sidebar')).toContainText('Meine Anmerkung'); + await sharedPage.locator('.sidebar-overlay').click(); + }); + + test('add and remove guest', async () => { + await sharedPage.goto('http://localhost:8000/planned'); + await sharedPage.getByRole('link', { name: 'Details' }).click(); + await sharedPage.locator('#sidebar #user_note').click(); + await sharedPage.locator('#sidebar #user_note').fill('Mein Gast'); + await sharedPage.getByRole('button', { name: 'Gast hinzufügen' }).click(); + await expect(sharedPage.locator('body')).toContainText('Erfolgreich angemeldet!'); + await sharedPage.getByRole('link', { name: 'Details' }).click(); + await expect(sharedPage.locator('#sidebar')).toContainText('Freie Plätze: 4'); + await expect(sharedPage.locator('#sidebar')).toContainText('Mein Gast (Gast) Abmelden'); + await expect(sharedPage.getByRole('link', { name: 'Termin löschen' })).not.toBeVisible(); + + await sharedPage.getByRole('link', { name: 'Abmelden' }).click(); + await expect(sharedPage.locator('body')).toContainText('Erfolgreich abgemeldet!'); + await sharedPage.getByRole('link', { name: 'Details' }).click(); + await expect(sharedPage.locator('#sidebar')).toContainText('Freie Plätze: 5'); + await expect(sharedPage.locator('#sidebar')).toContainText('Keine Ruderer angemeldet'); + await expect(sharedPage.getByRole('link', { name: 'Termin löschen' })).toBeVisible(); + + await sharedPage.locator('.sidebar-overlay').click(); + }); + + test('change amount rower', async () => { + await sharedPage.goto('http://localhost:8000/planned'); + await sharedPage.getByRole('link', { name: 'Details' }).click(); + await expect(sharedPage.locator('#sidebar')).toContainText('Freie Plätze: 5'); + await sharedPage.getByRole('spinbutton').click(); + await sharedPage.getByRole('spinbutton').fill('3'); + await sharedPage.getByRole('button', { name: 'Speichern' }).click(); + await expect(sharedPage.locator('body')).toContainText('Ausfahrt erfolgreich aktualisiert.'); + await sharedPage.getByRole('link', { name: 'Geplante Ausfahrten' }).click(); + }); + + test('call off trip', async () => { + await sharedPage.goto('http://localhost:8000/planned'); + await sharedPage.getByRole('link', { name: 'Details' }).click(); + await expect(sharedPage.locator('#sidebar')).toContainText('Freie Plätze: 5'); + await sharedPage.getByRole('spinbutton').click(); + await sharedPage.getByRole('spinbutton').fill('0'); + await sharedPage.getByRole('button', { name: 'Speichern' }).click(); + await expect(sharedPage.locator('body')).toContainText('Ausfahrt erfolgreich aktualisiert.'); + await sharedPage.getByRole('link', { name: 'Geplante Ausfahrten' }).click(); + await expect(sharedPage.locator('body')).toContainText('(Absage cox )'); + }); + + test.afterEach(async () => { + await sharedPage.goto('http://localhost:8000/planned'); + await sharedPage.getByRole('link', { name: 'Details' }).click(); + await sharedPage.getByRole('link', { name: 'Termin löschen' }).click(); + await sharedPage.close(); + }); +}); diff --git a/frontend/tests/example.spec.ts b/frontend/tests/example.spec.ts deleted file mode 100644 index 18740ca..0000000 --- a/frontend/tests/example.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('cox can create trip', async ({ page }) => { - await page.goto('http://localhost:8000/auth'); - await page.getByPlaceholder('Name').click(); - await page.getByPlaceholder('Name').fill('cox'); - await page.getByPlaceholder('Name').press('Tab'); - await page.getByPlaceholder('Passwort').fill('cox'); - await page.getByRole('button', { name: 'Einloggen' }).click(); - await expect(page.locator('body')).toContainText('Login erfolgreich'); - await page.locator('li').filter({ hasText: 'Geplante Ausfahrten' }).click(); - await page.getByRole('link', { name: 'Geplante Ausfahrten' }).click(); - await page.locator('.relative').first().click(); - await page.locator('#sidebar #planned_starting_time').click(); - await page.locator('#sidebar #planned_starting_time').press('ArrowLeft'); - await page.locator('#sidebar #planned_starting_time').press('Tab'); - await page.locator('#sidebar #planned_starting_time').fill('14:00'); - await page.locator('#sidebar #planned_starting_time').press('Tab'); - await page.getByRole('spinbutton').fill('4'); - await page.getByRole('button', { name: 'Erstellen', exact: true }).click(); - await expect(page.locator('body')).toContainText('Ausfahrt erfolgreich erstellt.'); -}); diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index c2691b4..c1adb2d 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -209,7 +209,7 @@ {% if rower.is_real_guest %} (Gast) {% if allow_removing %} - Abmelden + Abmelden {% endif %} {% endif %}