import { render, waitFor } from "@testing-library/react"; import { MemoryRouter } from "react-router-dom"; import { beforeEach, describe, expect, it, vi } from "vitest"; import type { Repos } from "../data/repos"; import { I18nProvider } from "../i18n/I18nContext"; import { TodayPage } from "./TodayPage"; const harness = vi.hoisted(() => ({ repos: null as Repos | null, legacyListPostsCalls: 0, })); vi.mock("../data/DataContext", () => ({ useRepos: () => harness.repos, useData: () => ({ repos: harness.repos, tick: 0, refresh: () => {} }), })); function buildRepos(): Repos { return { scout: { async listPosts() { harness.legacyListPostsCalls += 1; return []; }, async listRuns() { return { list: [], pagination: { page: 1, pageSize: 10, total: 0, totalPages: 0 } }; }, async listRunPosts() { throw new Error("not used"); }, }, accounts: { async list() { return []; } }, outbox: { async list() { return []; } }, inspiration: { async listTrends() { return []; }, async refreshTrends() { return []; }, }, ownPosts: { async list() { return []; }, async sync() { return []; } }, mentions: { async list() { return []; } }, growth: { async getOutcomeSummary() { return null; }, async getLatestCheckup() { return null; } }, radar: { async getToday() { return null; } }, } as unknown as Repos; } describe("TodayPage legacy Scout compatibility", () => { beforeEach(() => { harness.repos = buildRepos(); harness.legacyListPostsCalls = 0; }); it("continues to load the legacy listPosts endpoint", async () => { render( , ); await waitFor(() => expect(harness.legacyListPostsCalls).toBeGreaterThan(0)); }); });