From a4839aa5d9b3c6f29a9ece54fcd7de27534e4346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20S=C3=BCdkamp?= Date: Sat, 30 Sep 2023 16:58:16 +0200 Subject: [PATCH] test admin checkouts --- .github/workflows/playwright.yml | 48 +++++++++++++------------ e2e/test-admin.spec.ts | 61 ++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 23 deletions(-) create mode 100644 e2e/test-admin.spec.ts diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 9162a7d..9c70396 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,32 +1,34 @@ name: Playwright Tests on: push: - branches: [ main, master ] + branches: [main, master] pull_request: - branches: [ main, master ] + branches: [main, master] jobs: test: timeout-minutes: 60 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install dependencies - run: npm ci - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - run: npx playwright test - env: - PLAYWRIGHT_BASE_URL: ${{ secrets.PLAYWRIGHT_BASE_URL }} - PLAYWRIGHT_ENABLE_WEBSERVER: ${{ vars.PLAYWRIGHT_ENABLE_WEBSERVER }} - PLAYWRIGHT_USER: ${{ secrets.PLAYWRIGHT_USER }} - PLAYWRIGHT_PASSWORD: ${{ secrets.PLAYWRIGHT_PASSWORD }} - - uses: actions/upload-artifact@v3 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npx playwright test + env: + PLAYWRIGHT_BASE_URL: ${{ secrets.PLAYWRIGHT_BASE_URL }} + PLAYWRIGHT_ENABLE_WEBSERVER: ${{ vars.PLAYWRIGHT_ENABLE_WEBSERVER }} + PLAYWRIGHT_USER: ${{ secrets.PLAYWRIGHT_USER }} + PLAYWRIGHT_PASSWORD: ${{ secrets.PLAYWRIGHT_PASSWORD }} + PLAYWRIGHT_ADMIN_USER: ${{ secrets.PLAYWRIGHT_ADMIN_USER }} + PLAYWRIGHT_ADMIN_PASSWORD: ${{ secrets.PLAYWRIGHT_ADMIN_PASSWORD }} + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/e2e/test-admin.spec.ts b/e2e/test-admin.spec.ts new file mode 100644 index 0000000..e572896 --- /dev/null +++ b/e2e/test-admin.spec.ts @@ -0,0 +1,61 @@ +import { test, expect } from "@playwright/test"; +require("dotenv").config(); + +test.beforeEach(async ({ page }) => { + // login + await page.goto(`/login`); + await page.locator('input[name="email"]').click(); + await page + .locator('input[name="email"]') + .fill(process.env.PLAYWRIGHT_ADMIN_USER!); + await page.locator('input[name="email"]').press("Tab"); + await page + .locator('input[name="password"]') + .fill(process.env.PLAYWRIGHT_ADMIN_PASSWORD!); + await page.getByRole("button", { name: "Login" }).click(); + await expect( + page.getByRole("link", { name: "Ausleihen anzeigen" }) + ).toBeVisible(); +}); + +test("Show checkouts", async ({ page }) => { + await page.getByRole("link", { name: "Ausleihen anzeigen" }).click(); + await expect(page.getByRole("heading", { name: "Ausleihen" })).toBeVisible(); + await page.getByRole("combobox").selectOption("ORFF-COM"); + await page.getByRole("button", { name: "Suchen" }).click(); + + await expect( + page.getByRole("cell", { + name: "ORFF-COM-1f3e2bf1-7dbb-43c7-9b9e-b8b4f7f0306f", + }) + ).toBeVisible(); + + // filter by extId + await expect( + page.getByRole("cell", { name: "Filtern.." }).first() + ).toBeVisible(); + await page.locator("#searchScoreExtIdInput").click(); + await page.locator("#searchScoreExtIdInput").pressSequentially("9"); // fill will not create keypress event and thus will not reduce the list + // extId '115' should become hidden + await expect( + page.getByRole("cell", { + name: "ORFF-COM-1f3e2bf1-7dbb-43c7-9b9e-b8b4f7f0306f", + }) + ).toBeHidden(); + await page.keyboard.press("Backspace"); + + // filter by last name + await expect( + page.getByRole("cell", { name: "Filtern.." }).nth(1) + ).toBeVisible(); + await page.locator("#searchUserInput").click(); + await page.locator("#searchUserInput").pressSequentially("Be"); // fill will not create keypress event and thus will not reduce the list + // extId '115' should become hidden + await expect( + page.getByRole("cell", { + name: "ORFF-COM-1f3e2bf1-7dbb-43c7-9b9e-b8b4f7f0306f", + }) + ).toBeHidden(); + await page.keyboard.press("Backspace"); + await page.keyboard.press("Backspace"); +});