This repository has been archived on 2026-05-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
app/apps/web/e2e/tests/admin-reports.spec.ts
T
Flea Flicker 14b6539d7b fix(e2e): skip tests dependent on GRO-300/GRO-301, fix locator strictness
- portal-auth.spec.ts: skip both tests (GRO-300 not deployed)
- portal-data.spec.ts: skip all 3 tests (GRO-300 not deployed)
- admin-services.spec.ts: skip both tests (GRO-301 not deployed)
- admin-reports.spec.ts: fix getByText('Reports') strictness violation
  use getByRole('heading') instead to avoid nav link + h1 collision

Tests 3-5 (admin-services, admin-reports, console-health) were said to
pass against current dev state, but admin-services tests depend on GRO-301
(PR #185 not yet merged). Skipping until GRO-301 deploys. console-health
already passes.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-31 21:43:06 +00:00

64 lines
2.2 KiB
TypeScript

import { test, expect } from "./fixtures.js";
/**
* E2E test: Reports Data (GRO-306)
*
* Verifies that the reports page loads with non-zero data when date range
* is set to the last 60 days.
*
* This test runs against current dev state (no GRO-300 dependency).
*/
test.describe("Admin Reports Data", () => {
test("reports page shows non-zero data for last 60 days", async ({
staffPage,
}) => {
await staffPage.goto("/admin/reports");
await staffPage.waitForLoadState("networkidle");
// Wait for reports to load
await expect(staffPage.getByRole("heading", { name: "Reports" })).toBeVisible({ timeout: 10000 });
// Calculate 60 days ago date
const today = new Date();
const sixtyDaysAgo = new Date();
sixtyDaysAgo.setDate(today.getDate() - 60);
const formatDate = (d: Date) => d.toISOString().slice(0, 10);
// Set the date range to last 60 days
// The page has "From" and "To" date inputs
const fromInput = staffPage.locator('input[type="date"]').first();
const toInput = staffPage.locator('input[type="date"]').nth(1);
await fromInput.fill(formatDate(sixtyDaysAgo));
await toInput.fill(formatDate(today));
// Click Refresh to reload the report
await staffPage.getByRole("button", { name: /refresh/i }).click();
// Wait for data to reload
await staffPage.waitForLoadState("networkidle");
await staffPage.waitForTimeout(1000);
// At least one StatCard should show non-zero data
// The StatCards show: Revenue, Appointments, No-shows, Cancellations, New Clients
// We look for any card where the main value is not "0" or "$0.00"
const statCardValues = staffPage.locator('[style*="fontSize: 26"]');
const count = await statCardValues.count();
expect(count).toBeGreaterThan(0);
const hasNonZero = await staffPage.evaluate(() => {
const cards = document.querySelectorAll('[style*="fontSize: 26"]');
for (const card of Array.from(cards)) {
const text = card.textContent?.trim() ?? "";
// Check if it's a non-zero value
if (text !== "0" && text !== "$0.00") {
return true;
}
}
return false;
});
expect(hasNonZero).toBeTruthy();
});
});