add screen to view a barcode isolated
This commit is contained in:
@@ -115,4 +115,55 @@ test("cancelling the remove confirmation keeps the rewards card", async ({
|
||||
// The card must remain after cancelling.
|
||||
await expect(page.locator(".rewards-card")).toHaveCount(1);
|
||||
await expect(page.locator(".rewards-card").filter({ hasText: "Kroger" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("a user can open a single-card scan view with only one barcode", async ({
|
||||
page,
|
||||
}) => {
|
||||
await registerAndLogin(page, "alice@example.com");
|
||||
await gotoRewards(page);
|
||||
await addCard(page, "Kroger", "606171584511340224537");
|
||||
await addCard(page, "Safeway", "012345678901");
|
||||
|
||||
// Click the Kroger card's barcode to open its focused scan view.
|
||||
await page
|
||||
.locator(".rewards-card")
|
||||
.filter({ hasText: "Kroger" })
|
||||
.locator(".rewards-card-link")
|
||||
.click();
|
||||
|
||||
await expect(page).toHaveURL(/\/rewards\/\d+/);
|
||||
// Only one barcode is rendered on the scan page.
|
||||
await expect(page.locator(".scan-barcode svg")).toHaveCount(1);
|
||||
await expect(page.locator(".scan-store")).toHaveText("Kroger");
|
||||
await expect(page.locator(".scan-card .rewards-number")).toHaveText(
|
||||
"606171584511340224537",
|
||||
);
|
||||
// The wake-lock script is loaded on the scan page.
|
||||
await expect(page.locator('script[src*="rewards.js"]')).toHaveCount(1);
|
||||
|
||||
// Back link returns to the list.
|
||||
await page.click('.scan-back');
|
||||
await expect(page).toHaveURL(/\/rewards$/);
|
||||
});
|
||||
|
||||
test("a scan view for another user's card is not accessible", async ({ page }) => {
|
||||
await registerAndLogin(page, "alice@example.com");
|
||||
await gotoRewards(page);
|
||||
await addCard(page, "Kroger", "606171584511340224537");
|
||||
|
||||
// Grab the card id from the URL of the scan view.
|
||||
await page
|
||||
.locator(".rewards-card-link")
|
||||
.click();
|
||||
const url = page.url();
|
||||
const cardId = url.split("/").pop();
|
||||
|
||||
// Sign out and sign in as a different user.
|
||||
await page.click('button:has-text("Sign out")');
|
||||
await registerAndLogin(page, "bob@example.com");
|
||||
|
||||
// Bob cannot view Alice's card.
|
||||
await page.goto(`/rewards/${cardId}`);
|
||||
await expect(page.locator(".scan-barcode svg")).toHaveCount(0);
|
||||
});
|
||||
Reference in New Issue
Block a user