Skip to content

Commit a03674f

Browse files
committed
test: test actual mock api
1 parent 13daf25 commit a03674f

File tree

3 files changed

+37
-19
lines changed

3 files changed

+37
-19
lines changed

__tests__/auto-mocker-smoke.test.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/app/page.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@ export default async function Home() {
1212
redirect("/signin");
1313
}
1414

15+
// Try to load servers list from the registry API.
16+
// In dev, this may fail if no backend is running; tests use MSW.
17+
let serversSummary: { count: number; titles: string[] } | null = null;
18+
try {
19+
const res = await fetch("http://localhost/registry/v0.1/servers");
20+
if (res.ok) {
21+
const data = (await res.json()) as any;
22+
const items = Array.isArray(data?.servers) ? data.servers : [];
23+
const titles = items
24+
.map((it: any) => it?.server?.title || it?.server?.name)
25+
.filter(Boolean)
26+
.slice(0, 5);
27+
serversSummary = { count: items.length, titles };
28+
}
29+
} catch {
30+
// ignore; likely no backend in dev
31+
}
32+
1533
return (
1634
<div className="flex min-h-screen items-center justify-center bg-zinc-50 dark:bg-black">
1735
<main className="flex flex-col items-center gap-8 p-8">
@@ -30,6 +48,24 @@ export default async function Home() {
3048
>
3149
Go to Catalog
3250
</Link>
51+
52+
<div className="mt-6 text-sm text-zinc-600 dark:text-zinc-400">
53+
{serversSummary ? (
54+
<>
55+
<div>
56+
Registry servers available:{" "}
57+
<strong>{serversSummary.count}</strong>
58+
</div>
59+
{serversSummary.titles.length > 0 && (
60+
<div>Sample: {serversSummary.titles.join(", ")}</div>
61+
)}
62+
</>
63+
) : (
64+
<div className="italic">
65+
Registry unavailable in dev (expected)
66+
</div>
67+
)}
68+
</div>
3369
</div>
3470
</main>
3571
</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default {};

0 commit comments

Comments
 (0)