integratedhub/tests/e2e/landlord-dashboard.spec.ts
open-swe-dev-andrinoid[bot] 9dd9520532 Apply patch [skip ci]
2026-01-22 21:32:58 +00:00

78 lines
2.7 KiB
TypeScript

import { expect, Page, test } from "@playwright/test";
import { applyDeterministicPage, useE2EUser } from "./helpers.ts";
test("landlord dashboard surfaces portfolio activity", async ({ page }: { page: Page }) => {
await applyDeterministicPage(page);
await useE2EUser(page, "landlord");
await page.goto("/landlord/dashboard");
await expect(page.getByRole("heading", { name: /landlord dashboard/i }))
.toBeVisible();
await expect(page.getByText("123 Harbor Ave")).toBeVisible();
const maintenancePlaceholder = page.getByText(
/no open maintenance requests/i,
);
const maintenancePriority = page.getByText(/priority:/i).first();
if (await maintenancePriority.count()) {
await expect(maintenancePriority).toBeVisible();
} else {
await expect(maintenancePlaceholder).toBeVisible();
}
await expect(
page.getByRole("heading", { name: /recent messages/i }),
).toBeVisible();
});
test("landlord properties list includes active listings", async ({ page }: { page: Page }) => {
await applyDeterministicPage(page);
await useE2EUser(page, "landlord");
await page.goto("/landlord/properties");
await expect(page.getByRole("heading", { name: /my properties/i }))
.toBeVisible();
await expect(page.getByText("123 Harbor Ave")).toBeVisible();
await expect(page.getByText("456 Maple St")).toBeVisible();
});
test("landlord can approve an application", async ({ page }: { page: Page }) => {
await applyDeterministicPage(page);
await useE2EUser(page, "landlord");
await page.goto("/landlord/applications");
await expect(page.getByRole("heading", { name: /tenant applications/i }))
.toBeVisible();
await expect(page.getByText("Taylor Tenant")).toBeVisible();
const applicationRow = page.locator("li", {
hasText: "taylor.tenant@example.com",
}).first();
const approveButton = applicationRow.getByRole("button", { name: "Approve" });
if (await approveButton.count()) {
await approveButton.click();
await expect(page).toHaveURL(/\/landlord\/applications/);
}
const updatedRow = page.locator("li", {
hasText: "taylor.tenant@example.com",
}).first();
await expect(updatedRow).toContainText(/approved/i);
});
test("landlord can update maintenance status", async ({ page }: { page: Page }) => {
await applyDeterministicPage(page);
await useE2EUser(page, "landlord");
await page.goto("/landlord/maintenance");
await expect(page.getByRole("heading", { name: /maintenance requests/i }))
.toBeVisible();
const statusSelect = page.locator("select[name='new_status']").first();
await statusSelect.selectOption("in_progress");
await expect(page).toHaveURL(/\/landlord\/maintenance/);
await expect(statusSelect).toHaveValue("in_progress");
});