Files
Reactive-Resume/tests/e2e/specs/sharing-password.spec.ts
T
Amruth Pillai 6540c2aee9 test(e2e): drive the share and export sheet
The sharing specs use Share → Link (public switch, visitor downloads, the
password switch and the public address from Open public page), and the
export specs pick a format in the Download tab. share-history covers
renaming the address with the old one redirecting, and naming, previewing
and restoring versions.
2026-09-28 19:48:15 +02:00

35 lines
1.6 KiB
TypeScript

import { createSampleResumeFromDashboard, makeResumePublic } from "../fixtures/resume";
import { expect, test } from "../fixtures/test";
test("password-protects a public resume and unlocks it as a visitor", async ({ browser, authPage: page }, testInfo) => {
await createSampleResumeFromDashboard(page, testInfo);
const publicUrl = await makeResumePublic(page);
const password = "e2e-secret-42";
const requirePassword = page.getByRole("switch", { name: "Require a password" });
await requirePassword.click();
const dialog = page.getByRole("dialog", { name: "Protect your resume with a password" });
await dialog.getByLabel("Password", { exact: true }).fill(password);
await dialog.getByLabel("Confirm Password", { exact: true }).fill("different-password");
await dialog.getByRole("button", { name: "Set Password" }).click();
await expect(dialog.getByRole("alert")).toHaveText("Passwords do not match.");
await dialog.getByLabel("Confirm Password", { exact: true }).fill(password);
await dialog.getByRole("button", { name: "Set Password" }).click();
await expect(requirePassword).toBeChecked();
const anonymous = await browser.newPage();
try {
// Anonymous visitors hit the password gate first
await anonymous.goto(publicUrl);
await anonymous.waitForURL(/\/auth\/resume-password/);
await anonymous.getByLabel("Password", { exact: true }).fill(password);
await anonymous.getByRole("button", { name: "Unlock" }).click();
// The correct password reveals the actual resume
await expect(anonymous.getByRole("button", { name: "Download PDF" }).first()).toBeVisible();
} finally {
await anonymous.close();
}
});