Skip to content

Commit

Permalink
test admin checkouts
Browse files Browse the repository at this point in the history
  • Loading branch information
hsc-nue committed Sep 30, 2023
1 parent 55b12fa commit a4839aa
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 23 deletions.
48 changes: 25 additions & 23 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -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
61 changes: 61 additions & 0 deletions e2e/test-admin.spec.ts
Original file line number Diff line number Diff line change
@@ -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");
});

0 comments on commit a4839aa

Please sign in to comment.