generated from nholtware/service-template-react
feat: story library, player and builder UI
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
52778622a4
commit
364a911794
14 changed files with 1149 additions and 41 deletions
|
|
@ -26,26 +26,44 @@ afterEach(() => {
|
|||
});
|
||||
|
||||
describe("app", () => {
|
||||
it("home shows the app name from runtime config and the build sha", async () => {
|
||||
it("library lists published stories and links to play", async () => {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn(
|
||||
async () =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
stories: [
|
||||
{
|
||||
id: "s1",
|
||||
title: "Cave",
|
||||
description: "Dark",
|
||||
nodeCount: 3,
|
||||
published: true,
|
||||
},
|
||||
],
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
renderAt("/");
|
||||
expect(
|
||||
await screen.findByRole("heading", { name: "test-app" }),
|
||||
await screen.findByRole("heading", { name: "Cave" }),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByTestId("build-sha")).toHaveTextContent("dev");
|
||||
expect(
|
||||
screen.getAllByRole("link", { name: "Play" }).at(-1)!,
|
||||
).toHaveAttribute("href", "/play/s1");
|
||||
});
|
||||
|
||||
it("home hides the banner while hello-banner is off", async () => {
|
||||
renderAt("/");
|
||||
await screen.findByRole("heading", { name: "test-app" });
|
||||
expect(screen.queryByTestId("banner")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("home shows the banner while hello-banner is on", async () => {
|
||||
flagsOn.add("hello-banner");
|
||||
renderAt("/");
|
||||
expect(await screen.findByTestId("banner")).toHaveTextContent(
|
||||
"hello-banner flag is on",
|
||||
it("library shows a builder prompt when empty", async () => {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn(async () => new Response(JSON.stringify({ stories: [] }))),
|
||||
);
|
||||
renderAt("/");
|
||||
expect(
|
||||
await screen.findByText(/No published stories yet/),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("status fetches / and /readyz under API_BASE_URL and renders the JSON", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue