From 6dcb6bf4b5a470d333ed1ece2539170c9b383f92 Mon Sep 17 00:00:00 2001 From: Tetardtek Date: Sun, 5 Apr 2026 07:37:55 +0200 Subject: [PATCH] =?UTF-8?q?test:=20flip=20anti-regression=20double=20XP=20?= =?UTF-8?q?=E2=80=94=20fix=20merged,=20assertion=20invers=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/list/list.service.spec.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/backend/src/list/list.service.spec.ts b/backend/src/list/list.service.spec.ts index 656f456..67e059c 100644 --- a/backend/src/list/list.service.spec.ts +++ b/backend/src/list/list.service.spec.ts @@ -233,21 +233,9 @@ describe('ListService', () => { await service.updateStatus(1, 1, ListStatus.COMPLETED); - // THIS TEST DOCUMENTS THE BUG: updateStatus awards XP_COMPLETE - // even when the entry is already COMPLETED. - // - // Current behavior (BUG): addXp IS called => test expects the call. - // When the fix lands, flip this assertion to: - // expect(userService.addXp).not.toHaveBeenCalled(); - // - // Until then, this test proves the double-XP path exists. - const secondXpCalls = userService.addXp.mock.calls.filter( - ([, amount]) => amount === XP_COMPLETE, - ); - expect(secondXpCalls).toHaveLength(1); // BUG: this SHOULD be 0 - - // Total across both steps = 2 x XP_COMPLETE — the double-XP bug - // After fix, total should be exactly 1 x XP_COMPLETE + // FIX MERGED: updateStatus now guards against already-completed status. + // addXp should NOT be called a second time. + expect(userService.addXp).not.toHaveBeenCalled(); }); });