import test from "node:test"; import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; async function readSource(relativePath: string) { return readFile(new URL(`../${relativePath}`, import.meta.url), "utf8"); } test("ai accounts page refreshes when AI account state changes", async () => { const source = await readSource("src/app/me/ai-accounts/page.tsx"); assert.match(source, /import \{ RealtimeRefresh \}/, "expected ai accounts page to import RealtimeRefresh"); assert.match(source, / { const source = await readSource("src/app/me/storage/page.tsx"); assert.match(source, /import \{ RealtimeRefresh \}/, "expected storage page to import RealtimeRefresh"); assert.match(source, / { for (const relativePath of [ "src/app/me/master-agent/page.tsx", "src/app/me/master-agent/takeover/page.tsx", "src/app/me/master-agent/evolution/page.tsx", ]) { const source = await readSource(relativePath); assert.match(source, /import \{ RealtimeRefresh \}/, `expected ${relativePath} to import RealtimeRefresh`); assert.match(source, / { const source = await readSource("src/app/me/page.tsx"); assert.match(source, /href="\/me\/master-agent\/evolution"/, "expected me page to link evolution page"); assert.match(source, /title="主 Agent 自动进化"/, "expected me page to show evolution menu title"); }); test("master agent evolution page renders admin-aware dashboard shell", async () => { const pageSource = await readSource("src/app/me/master-agent/evolution/page.tsx"); const clientSource = await readSource("src/components/master-agent-evolution-client.tsx"); assert.match(pageSource, /getMasterAgentEvolutionDashboard/, "expected page to load evolution dashboard server-side"); assert.match(pageSource, /session\.role === "highest_admin"/, "expected page to gate admin actions by role"); assert.match(pageSource, /