refactor(private-zoom): rename full feature surface

This commit is contained in:
Codex
2026-07-22 18:21:47 +08:00
parent e813333607
commit ed3b34ce1c
102 changed files with 695 additions and 519 deletions
@@ -0,0 +1,58 @@
import { describe, expect, it } from "vitest";
import { createActor, waitFor } from "xstate";
import {
createTestPrivateZoomMachine,
loadPrivateZoom,
makeAlbum,
makeAlbumsResponse,
TEST_PRIVATE_ZOOM_INPUT,
} from "./private-zoom-machine.test-utils";
describe("private zoom album flow", () => {
it("loads albums for the supplied character", async () => {
let loadedCharacterId: string | null = null;
const actor = createActor(
createTestPrivateZoomMachine({
onLoad: ({ characterId }) => {
loadedCharacterId = characterId;
},
}),
{ input: { characterId: "character_aria" } },
).start();
actor.send({ type: "PrivateZoomInit" });
await waitFor(actor, (snapshot) => snapshot.matches("ready"));
expect(actor.getSnapshot().context.characterId).toBe("character_aria");
expect(loadedCharacterId).toBe("character_aria");
actor.stop();
});
it("loads only the first non-paginated album page", async () => {
const actor = await loadPrivateZoom({
loadResponse: makeAlbumsResponse({
items: Array.from({ length: 20 }, (_, index) => makeAlbum(index)),
}),
});
expect(actor.getSnapshot().context.items).toHaveLength(20);
expect(actor.getSnapshot().context).not.toHaveProperty("hasMore");
expect(actor.getSnapshot().context).not.toHaveProperty("nextCursor");
actor.stop();
});
it("moves to failed when the album actor rejects", async () => {
const actor = createActor(
createTestPrivateZoomMachine({
loadError: new Error("albums unavailable"),
}),
{ input: TEST_PRIVATE_ZOOM_INPUT },
).start();
actor.send({ type: "PrivateZoomInit" });
await waitFor(actor, (snapshot) => snapshot.matches("failed"));
expect(actor.getSnapshot().context.errorMessage).toBe(
"albums unavailable",
);
actor.stop();
});
});