diff --git a/e2e/qr-test-user.png b/e2e/qr-test-user.png index 251d06c..34490d0 100644 Binary files a/e2e/qr-test-user.png and b/e2e/qr-test-user.png differ diff --git a/e2e/test-admin.spec.ts b/e2e/test-admin.spec.ts index 9dea2c6..09588e8 100644 --- a/e2e/test-admin.spec.ts +++ b/e2e/test-admin.spec.ts @@ -61,15 +61,28 @@ test("Show checkouts", async ({ page }) => { await page.keyboard.press("Backspace"); }); -test.skip("checkout with user search", async ({ page }) => { - await page.getByRole("link", { name: "Noten Ausleihe" }).click(); - await expect(page.getByRole("heading", { name: "Ausleihe" })).toBeVisible(); - await expect( - page.getByRole("button", { name: "User/Leihzettel scannen" }) - ).toBeVisible(); - await expect( - page.getByRole("button", { name: "User über Namen suchen" }) - ).toBeVisible(); + +test("checkout/checkin with user QR Code", async ({ page }) => { + await gotoCheckoutPage(page); + + // User scan + await page.getByRole("button", { name: "User/Leihzettel scannen" }).click(); + await expect(page.getByText("Scan an Image File")).toBeVisible({ timeout: 10 * 1000 }); + await page.getByText("Scan an Image File").click(); + await page.setInputFiles( + 'input[type="file"]', + path.join(__dirname, "qr-test-user.png") + ); + await expect(page.getByText("Benutzer: Monika Mustermann")).toBeVisible(); + + await scanScoreAndCheckout(page); + await page.goto(`/`); + await checkin(page); + // await page.pause(); +}); + +test("checkout/checkin with user last name", async ({ page }) => { + await gotoCheckoutPage(page); await page.locator('input[name="userLastName"]').click(); await page @@ -87,53 +100,31 @@ test.skip("checkout with user search", async ({ page }) => { .getByRole("cell", { name: "Auswählen", }) - .nth(2) + .first() ).toBeVisible(); await expect( page .getByRole("button", { name: "Auswählen", }) - .nth(2) + .first() ).toBeVisible(); await page .getByRole("button", { name: "Auswählen", }) - .nth(2) + .first() .click(); + await expect(page.getByText("Benutzer: Monika Mustermann")).toBeVisible(); - await expect(page.getByText("Benutzer: Susi Südkamp")).toBeVisible(); - await expect( - page.getByRole("button", { name: "Noten scannen" }) - ).toBeVisible(); - - await page.getByRole("button", { name: "Noten scannen" }).click(); - await expect(page.getByText("Scan an Image File")).toBeVisible(); - - await page.getByText("Scan an Image File").click(); - await expect( - page.getByRole("button", { name: "Choose Image - No image choosen" }) - ).toBeVisible(); - - console.log("__dirname", __dirname); - await expect(page.locator("css=html5-qrcode-element")).toBeHidden(); - await page - .getByRole("button", { name: "Choose Image - No image choosen" }) - .click(); - // await page.locator('css=html5-qrcode-element').setInputFiles(path.join(__dirname, '../qr-code.png')); - - // await page.pause(); -}); -test("checkout with user QR Code", async ({ page }) => { - await checkout(page); + await scanScoreAndCheckout(page); await page.goto(`/`); await checkin(page); // await page.pause(); }); -async function checkout(page: any) { +async function gotoCheckoutPage(page: any) { await page.getByRole("link", { name: "Noten Ausleihe" }).click(); await expect(page.getByRole("heading", { name: "Ausleihe" })).toBeVisible(); await expect( @@ -142,17 +133,12 @@ async function checkout(page: any) { await expect( page.getByRole("button", { name: "User über Namen suchen" }) ).toBeVisible(); +} - await page.getByRole("button", { name: "User/Leihzettel scannen" }).click(); - await page.getByText("Scan an Image File").click(); - await page.setInputFiles( - 'input[type="file"]', - path.join(__dirname, "qr-test-user.png") - ); - await expect(page.getByText("Benutzer: Monika Mustermann")).toBeVisible(); - +async function scanScoreAndCheckout(page: any) { // scan non existing score await page.getByRole("button", { name: "Noten scannen" }).click(); + await expect(page.getByText("Scan an Image File")).toBeVisible({ timeout: 10 * 1000 }); await page.getByText("Scan an Image File").click(); await page.setInputFiles( 'input[type="file"]', @@ -176,7 +162,7 @@ async function checkout(page: any) { page.getByText( "Benutzer: Monika MustermannNoten Id BRFS-AD-140Ausleihe erfolgreich" ) - ).toBeVisible(); + ).toBeVisible({ timeout: 10 * 1000 }); } async function checkin(page: any) { @@ -188,6 +174,7 @@ async function checkin(page: any) { // scan non existing score await page.getByRole("button", { name: "Noten scannen" }).click(); + await expect(page.getByText("Scan an Image File")).toBeVisible({ timeout: 10 * 1000 }); await page.getByText("Scan an Image File").click(); await page.setInputFiles( 'input[type="file"]', @@ -207,7 +194,7 @@ async function checkin(page: any) { path.join(__dirname, "qr-brfs-ad-140.png") ); await page.getByRole("button", { name: "Rückgabe" }).click(); - await expect(page.getByText("Rückgabe erfolgreich")).toBeVisible(); + await expect(page.getByText("Rückgabe erfolgreich")).toBeVisible({ timeout: 10 * 1000 }); // await page.pause(); }