Files
growqr-backend/scripts/curator-access-choice.test.ts

59 lines
2.1 KiB
TypeScript

import assert from "node:assert/strict";
import { planSeedsForVariant, resolveCuratorSprintAccess } from "../src/v1/curator/curator-store.js";
import { templateSetFor, trialDaysFor } from "../src/v1/curator/task-registry.js";
const variant = "fresher_early_professional" as const;
const template = templateSetFor(variant);
const trial = trialDaysFor(variant);
// Persisted choice is authoritative within the user's entitlement: a paid user
// may choose trial, but a free user may not self-upgrade through "full".
assert.deepEqual(resolveCuratorSprintAccess({ accessChoice: "trial", plan: "pro" }), {
access: "trial",
durationDays: 2,
});
assert.deepEqual(resolveCuratorSprintAccess({ accessChoice: "full", plan: "pro" }), {
access: "full",
durationDays: 7,
});
assert.deepEqual(resolveCuratorSprintAccess({ accessChoice: "full", plan: "free" }), {
access: "trial",
durationDays: 2,
});
assert.deepEqual(resolveCuratorSprintAccess({ plan: "pro" }), {
access: "full",
durationDays: 7,
});
assert.deepEqual(resolveCuratorSprintAccess({ plan: "free" }), {
access: "trial",
durationDays: 2,
});
const trialDays = planSeedsForVariant(template, "2026-07-13", 2, "trial");
assert.deepEqual(
trialDays[0]?.plannedTasks.map((task) => task.title),
[trial[0]!.socialTitle, trial[0]!.measurementTitle, trial[0]!.proofTitle, trial[0]!.practiceTitle],
"trial Day 1 must use the ICP trial registry",
);
assert.deepEqual(
trialDays[1]?.plannedTasks.map((task) => task.title),
[trial[1]!.socialTitle, trial[1]!.measurementTitle, trial[1]!.proofTitle, trial[1]!.practiceTitle],
"trial Day 2 must use the ICP trial registry",
);
const fullDays = planSeedsForVariant(template, "2026-07-13", 7, "full");
assert.equal(fullDays.length, 7);
assert.deepEqual(
fullDays[0]?.plannedTasks.map((task) => task.title),
[
template.weeks[0]!.days[0]!.measurement.title,
template.weeks[0]!.days[0]!.proof.title,
template.weeks[0]!.days[0]!.practice.title,
template.weeks[0]!.days[0]!.roleplay!.title,
],
"authorized full Day 1 must use the normal 7-day registry",
);
assert.equal(fullDays[0]?.isTrialDay, false);
console.log("curator access-choice tests passed");