Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
66 lines
2.3 KiB
TypeScript
66 lines
2.3 KiB
TypeScript
import * as React from "react";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { cleanup, render, screen, within } from "@testing-library/react";
|
|
|
|
vi.mock("@/lib/use-api-token", () => ({ useApiToken: () => async () => "token" }));
|
|
|
|
import AdminFunnelPage from "./page";
|
|
import { dayOrNo } from "./funnel-data";
|
|
|
|
const payload = {
|
|
since: "2026-09-25T00:00:00+00:00",
|
|
totals: {
|
|
users: 2,
|
|
reach: { signed_up: 2, card_check: 1, first_render: 1, first_kept: 1, first_payment: 0 },
|
|
by_source: { scribase: 1, unknown: 1 },
|
|
by_plan: { free: 2 },
|
|
},
|
|
rows: [
|
|
{
|
|
user_id: "u1", email: "a@example.com", signed_up: "2026-09-26T10:00:00+00:00",
|
|
card_check: "2026-09-26T10:05:00+00:00", first_render: "2026-09-26T11:00:00+00:00",
|
|
first_kept: "2026-09-26T11:00:00+00:00", first_payment: null, plan: "free", source: "scribase",
|
|
utm_source: "unknown", utm_medium: "unknown", utm_campaign: "launch-video", referrer: "unknown",
|
|
},
|
|
],
|
|
};
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
describe("admin funnel page", () => {
|
|
it("renders reach, mixes and rows, with 'no' and 'unknown' for missing data", async () => {
|
|
const calls: string[] = [];
|
|
vi.stubGlobal(
|
|
"fetch",
|
|
vi.fn(async (url: string) => {
|
|
calls.push(url);
|
|
const body = { status: 200, data: payload };
|
|
return { ok: true, status: 200, json: async () => body, text: async () => JSON.stringify(body) };
|
|
}),
|
|
);
|
|
render(<AdminFunnelPage />);
|
|
const row = await screen.findByText("a@example.com");
|
|
expect(calls[0]).toMatch(/\/admin\/funnel\/readout\?since=2026-09-25$/);
|
|
const cells = within(row.closest("tr") as HTMLElement).getAllByRole("cell").map((c) => c.textContent);
|
|
expect(cells).toContain("no");
|
|
expect(cells).toContain("scribase");
|
|
expect(screen.getAllByText("unknown").length).toBeGreaterThan(0);
|
|
expect(dayOrNo(null)).toBe("no");
|
|
});
|
|
|
|
it("shows the API's refusal for a non-admin", async () => {
|
|
vi.stubGlobal(
|
|
"fetch",
|
|
vi.fn(async () => {
|
|
const body = { status: 403, message: "staff access required" };
|
|
return { ok: false, status: 403, json: async () => body, text: async () => JSON.stringify(body) };
|
|
}),
|
|
);
|
|
render(<AdminFunnelPage />);
|
|
expect(await screen.findByRole("alert")).toBeTruthy();
|
|
});
|
|
});
|