Files
OmniRoute/tests/unit/gamification/streaks.test.ts
Diego Rodrigues de Sa e Souza 0adae00c7b Release v3.8.42 (#5459)
Release v3.8.42 — full CHANGELOG in CHANGELOG.md.

CI: 103 checks green incl. CodeQL (all languages), Semgrep, all 8 unit shards,
coverage, Node 24 compat, and integration tests. Full unit suite validated
locally: 19437 pass / 0 fail. The 3 red checks are advisory and do not gate
main (no required status checks): SonarCloud/SonarQube new-code coverage gate,
and PR Test Policy (test-masking detector flagging the legitimate dead-Phind
provider removal in #5530 — reviewed, correct).

Includes cycle-close reconciliation + repair of inherited base-red tests from
#5480/#5527/#5427/#5521 that the PR->release fast-path did not exercise.
2026-06-30 06:54:29 -03:00

37 lines
1.2 KiB
TypeScript

import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { getStreak, updateStreak } from "../../../src/lib/gamification/streaks";
describe("Streak Tracker", () => {
describe("getStreak", () => {
it("returns zero streak for unknown user", async () => {
const streak = await getStreak("nonexistent-user");
assert.equal(streak.currentStreak, 0);
assert.equal(streak.longestStreak, 0);
});
});
describe("updateStreak", () => {
it("returns positive streak count", async () => {
const streak = await updateStreak("test-user-1");
assert.ok(streak >= 1);
});
it("returns same count if called twice same day", async () => {
const first = await updateStreak("test-user-2");
const second = await updateStreak("test-user-2");
assert.equal(first, second);
});
it("stores date metadata when starting a streak", async () => {
await updateStreak("test-user-3");
const streak = await getStreak("test-user-3");
assert.equal(streak.currentStreak, 1);
assert.equal(streak.longestStreak, 1);
assert.match(streak.lastActiveDate, /^\d{4}-\d{2}-\d{2}$/);
assert.equal(streak.streakStartDate, streak.lastActiveDate);
});
});
});