Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
hsc-nue committed Oct 5, 2023
1 parent bf45bc6 commit 9dd77a4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 47 deletions.
Binary file modified e2e/qr-test-user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 34 additions & 47 deletions e2e/test-admin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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"]',
Expand All @@ -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) {
Expand All @@ -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"]',
Expand All @@ -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();
}
Expand Down

0 comments on commit 9dd77a4

Please sign in to comment.