generated from nhcarrigan/template
balance: add crafting daily challenge type to unblock progression-stuck players (closes #167)
This commit is contained in:
@@ -144,6 +144,34 @@ describe("craft route", () => {
|
||||
expect(body.bonusType).toBe("gold_income");
|
||||
});
|
||||
|
||||
it("updates crafting challenge progress and awards crystals when dailyChallenges is defined", async () => {
|
||||
const state = makeState({
|
||||
dailyChallenges: {
|
||||
date: "2024-01-15",
|
||||
challenges: [
|
||||
{
|
||||
completed: false,
|
||||
id: "2024-01-15_crafting",
|
||||
label: "Craft 1 recipe",
|
||||
progress: 0,
|
||||
rewardCrystals: 75,
|
||||
target: 1,
|
||||
type: "crafting",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
vi.mocked(prisma.gameState.update).mockResolvedValueOnce({} as never);
|
||||
const res = await post({ recipeId: TEST_RECIPE_ID });
|
||||
expect(res.status).toBe(200);
|
||||
const updateArg = vi.mocked(prisma.gameState.update).mock.calls[0]![0] as {
|
||||
data: { state: GameState };
|
||||
};
|
||||
expect(updateArg.data.state.dailyChallenges?.challenges[0]?.completed).toBe(true);
|
||||
expect(updateArg.data.state.resources.crystals).toBe(75);
|
||||
});
|
||||
|
||||
it("returns 500 when the database throws", async () => {
|
||||
vi.mocked(prisma.gameState.findUnique).mockRejectedValueOnce(new Error("DB error"));
|
||||
const res = await post({ recipeId: TEST_RECIPE_ID });
|
||||
|
||||
Reference in New Issue
Block a user