integratedhub/tests/e2e/documents.spec.ts
2026-01-20 09:02:26 -06:00

57 lines
1.7 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { applyDeterministicPage, useE2EUser } from "./helpers.ts";
test("tenant can review and sign lease documents", async ({ page }) => {
await applyDeterministicPage(page);
await useE2EUser(page, "tenant");
await page.goto("/tenant/documents");
await expect(page.getByRole("heading", { name: /documents/i })).toBeVisible();
const leaseRow = page.locator("tbody tr", {
hasText: "maple-row-lease.pdf",
}).first();
await expect(leaseRow).toBeVisible();
const signButton = leaseRow.getByRole("button", { name: /sign as tenant/i });
if (await signButton.isVisible()) {
await signButton.click();
await expect(page).toHaveURL(/\/tenant\/documents/);
}
const updatedRow = page.locator("tbody tr", {
hasText: "maple-row-lease.pdf",
}).first();
await expect(updatedRow).toContainText("Signed");
});
test("landlord can review and sign lease documents", async ({ page }) => {
await applyDeterministicPage(page);
await useE2EUser(page, "landlord");
await page.goto("/landlord/documents");
await expect(
page.getByRole("heading", { name: /lease documents/i }),
).toBeVisible();
const leaseRow = page.locator("tbody tr", {
hasText: "maple-row-lease.pdf",
}).first();
await expect(leaseRow).toBeVisible();
const signButton = leaseRow.getByRole("button", {
name: /sign as landlord/i,
});
if (await signButton.isVisible()) {
await signButton.click();
await expect(page).toHaveURL(/\/landlord\/documents/);
}
const updatedRow = page.locator("tbody tr", {
hasText: "maple-row-lease.pdf",
}).first();
await expect(updatedRow).toContainText("Signed");
});