generated from nhcarrigan/template
fix: save character name correctly and show story on character sheet
- Load route syncs characterName from Player record so profile updates are reflected immediately on next load - Save route preserves Player record's characterName so auto-saves cannot overwrite profile updates - Public profile response now includes completedChapters - Character sheet panel displays completed story chapters with outcome - Removed stale CSS for old achievement/codex toast classes
This commit is contained in:
@@ -181,6 +181,24 @@ describe("profile route", () => {
|
||||
const unknown = body.unlockedTitles.find((t) => t.id === "unknown_title_id");
|
||||
expect(unknown?.name).toBe("unknown_title_id");
|
||||
});
|
||||
|
||||
it("includes completed story chapters in profile response", async () => {
|
||||
const state = makeState({
|
||||
story: {
|
||||
unlockedChapterIds: [ "boss_troll_king" ],
|
||||
completedChapters: [ { chapterId: "boss_troll_king", choiceId: "fight" } ],
|
||||
},
|
||||
});
|
||||
vi.mocked(prisma.player.findUnique).mockResolvedValueOnce(makePlayer() as never);
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
const res = await app.fetch(new Request(`http://localhost/profile/${DISCORD_ID}`));
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json() as {
|
||||
completedChapters: Array<{ chapterId: string; choiceId: string }>;
|
||||
};
|
||||
expect(body.completedChapters).toHaveLength(1);
|
||||
expect(body.completedChapters[0]).toMatchObject({ chapterId: "boss_troll_king", choiceId: "fight" });
|
||||
});
|
||||
});
|
||||
|
||||
describe("PUT /", () => {
|
||||
|
||||
Reference in New Issue
Block a user