← back to Homesonspec

tests/end-to-end/consumer.spec.ts

47 lines

import { expect, test } from "@playwright/test";

test("search by city shows results and map markers", async ({ page }) => {
  await page.goto("/search?q=Leander");
  await expect(page.getByTestId("result-count")).toContainText(/\d+ homes/, { timeout: 15_000 });
  await expect(page.getByTestId("home-card").first()).toBeVisible();
  // Leaflet map container mounts client-side.
  await expect(page.getByTestId("map").locator(".leaflet-container")).toBeVisible({ timeout: 10_000 });
});

test("price and beds filters change the result count", async ({ page }) => {
  await page.goto("/search?q=Leander");
  await expect(page.getByTestId("result-count")).toContainText(/\d+ homes/, { timeout: 15_000 });
  const initial = await page.getByTestId("result-count").textContent();

  await page.getByTestId("beds-5").click();
  await expect(page.getByTestId("result-count")).not.toHaveText(initial ?? "", { timeout: 10_000 });
});

test("sort and density persist across reload (localStorage)", async ({ page }) => {
  await page.goto("/search?q=Leander");
  await page.getByTestId("sort-select").selectOption("price_desc");
  await page.getByTestId("density-slider").fill("4");
  await page.reload();
  await expect(page.getByTestId("sort-select")).toHaveValue("price_desc");
  await expect(page.getByTestId("density-slider")).toHaveValue("4");
});

test("home detail shows verification label, last-verified, and demo banner", async ({ page }) => {
  await page.goto("/search?q=Leander");
  await page.getByTestId("home-card").first().click();
  await expect(page).toHaveURL(/\/homes\//);
  await expect(page.getByTestId("verification-block")).toContainText(/Demonstration data|Verified/);
  await expect(page.getByTestId("verification-block")).toContainText(/Last verified/);
  await expect(page.getByText(/Demonstration inventory/)).toBeVisible();
  await expect(page.getByTestId("evidence-table")).toBeVisible();
});

test("correction report control submits", async ({ page }) => {
  await page.goto("/search?q=Leander");
  await page.getByTestId("home-card").first().click();
  await page.getByTestId("correction-toggle").click();
  await page.getByTestId("correction-message").fill("e2e test: price looks stale");
  await page.getByTestId("correction-submit").click();
  await expect(page.getByTestId("correction-done")).toBeVisible({ timeout: 10_000 });
});