Initial commit: CI Agent competitive-intelligence monitoring app
FastAPI + Celery + Next.js + Postgres/Redis app with company monitoring, source collection, LLM-based change analysis, enrichment, and account security (Turnstile, escalating lockout, email verification).
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import { screen } from "@testing-library/react";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import LandingPage from "@/app/page";
|
||||
import { renderWithQueryClient } from "./test-utils";
|
||||
|
||||
function mockFetchImplementation(isLocalhost: boolean) {
|
||||
return vi.fn().mockImplementation((url: string) => {
|
||||
const path = url.replace("http://localhost:8000", "");
|
||||
if (path.startsWith("/api/v1/system/status")) {
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
status: 200,
|
||||
json: async () => ({
|
||||
app_env: "development",
|
||||
auth_mode: "local",
|
||||
llm_provider: "mock",
|
||||
search_provider: "mock",
|
||||
sms_enabled: false,
|
||||
sms_provider: "twilio",
|
||||
ninjapear_configured: false,
|
||||
ninjapear_credit_balance: null,
|
||||
ninjapear_estimated_credits_per_company: null,
|
||||
is_localhost: isLocalhost,
|
||||
components: [],
|
||||
}),
|
||||
});
|
||||
}
|
||||
return Promise.resolve({ ok: false, status: 404, json: async () => ({ detail: "not found" }) });
|
||||
});
|
||||
}
|
||||
|
||||
describe("LandingPage", () => {
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal("fetch", mockFetchImplementation(true));
|
||||
});
|
||||
|
||||
it("renders the value proposition and primary calls to action", async () => {
|
||||
renderWithQueryClient(<LandingPage />);
|
||||
|
||||
expect(
|
||||
screen.getByRole("heading", { name: /know what your competitors are doing/i }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
await screen.findByRole("link", { name: /open dashboard \(local mode\)/i }),
|
||||
).toHaveAttribute("href", "/dashboard");
|
||||
expect(screen.getByRole("link", { name: /sign in/i })).toHaveAttribute("href", "/login");
|
||||
expect(screen.getByRole("link", { name: /create account/i })).toHaveAttribute(
|
||||
"href",
|
||||
"/register",
|
||||
);
|
||||
});
|
||||
|
||||
it("discloses the public-information-only collection policy", () => {
|
||||
renderWithQueryClient(<LandingPage />);
|
||||
expect(
|
||||
screen.getByRole("heading", { name: /only publicly available information/i }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("drops the local-mode wording when the request isn't from localhost", async () => {
|
||||
vi.stubGlobal("fetch", mockFetchImplementation(false));
|
||||
renderWithQueryClient(<LandingPage />);
|
||||
|
||||
expect(await screen.findByRole("link", { name: /^open dashboard$/i })).toHaveAttribute(
|
||||
"href",
|
||||
"/dashboard",
|
||||
);
|
||||
expect(screen.queryByText(/local mode/i)).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user