56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import {
|
|
composeTrialDay2,
|
|
curatorLogicalDate,
|
|
resolveAgedTrialReuse,
|
|
} from "../src/v1/curator/streak-utils.js";
|
|
|
|
assert.equal(
|
|
curatorLogicalDate(new Date("2026-07-15T03:29:59.999Z")),
|
|
"2026-07-14",
|
|
"the previous Curator day remains active until 09:00 Asia/Kolkata",
|
|
);
|
|
assert.equal(
|
|
curatorLogicalDate(new Date("2026-07-15T03:30:00.000Z")),
|
|
"2026-07-15",
|
|
"the next Curator day starts at 09:00 Asia/Kolkata",
|
|
);
|
|
assert.equal(
|
|
curatorLogicalDate(new Date("2026-07-15T02:30:00.000Z"), 8),
|
|
"2026-07-15",
|
|
"deployments may explicitly configure a different business-morning hour",
|
|
);
|
|
const reuse = resolveAgedTrialReuse({
|
|
existing: { startDate: "2026-07-14", version: "icp-v10-static", durationDays: 2, access: "trial" },
|
|
desired: { durationDays: 2, access: "trial" },
|
|
today: curatorLogicalDate(new Date("2026-07-18T00:00:00.000Z")),
|
|
planVersion: "icp-v10-static",
|
|
});
|
|
assert.equal(reuse.action, "reuse");
|
|
assert.equal(reuse.startDate, "2026-07-14");
|
|
assert.equal(reuse.activeDayIndex, 2);
|
|
|
|
const fullDay7 = resolveAgedTrialReuse({
|
|
existing: { startDate: "2026-07-14", version: "icp-v10-static", durationDays: 7, access: "full" },
|
|
desired: { durationDays: 7, access: "full" },
|
|
today: "2026-07-20",
|
|
planVersion: "icp-v10-static",
|
|
});
|
|
assert.equal(fullDay7.action, "reuse", "a full sprint must remain on its seventh day");
|
|
assert.equal(fullDay7.activeDayIndex, 7);
|
|
|
|
const fullDay8 = resolveAgedTrialReuse({
|
|
existing: { startDate: "2026-07-14", version: "icp-v10-static", durationDays: 7, access: "full" },
|
|
desired: { durationDays: 7, access: "full" },
|
|
today: "2026-07-21",
|
|
planVersion: "icp-v10-static",
|
|
});
|
|
assert.equal(fullDay8.action, "restart", "a full sprint may restart only after its seventh day");
|
|
|
|
const native = [{ id: "native-1" }, { id: "native-2" }, { id: "native-3" }, { id: "native-4" }];
|
|
const recovery = { id: "recovery" };
|
|
assert.deepEqual(composeTrialDay2("student_recent_grad", 0, native, recovery), [recovery, ...native.slice(0, 3)]);
|
|
assert.deepEqual(composeTrialDay2("student_recent_grad", 1, native, recovery), native);
|
|
|
|
console.log("curator trial progression regression: ok");
|