test: cover folder archive context tie-breakers

This commit is contained in:
kris
2026-04-05 13:17:28 +08:00
parent 20b296ce4f
commit f9a0d205df

View File

@@ -164,6 +164,121 @@ test("folder archives use the latest thread preview/time while subtitle and cont
assert.equal(folder?.contextBudgetUpdatedAt, "2026-04-04T11:05:00+08:00");
});
test("folder archive context ring prefers more urgent contextBudgetLevel when mustFinishBeforeCompaction is equal", async () => {
await setup();
const state = await readState();
state.projects = state.projects.filter((project) => project.id === "master-agent");
state.projects.push(
buildImportedThreadProject(
"mac-studio",
"boss-thread-latest",
"Boss",
"boss",
"最新线程",
"thread-latest",
"2026-04-04T12:00:00+08:00",
),
buildImportedThreadProject(
"mac-studio",
"boss-thread-watch",
"Boss",
"boss",
"次要关注",
"thread-watch",
"2026-04-04T11:00:00+08:00",
),
);
state.threadContextSnapshots = [
buildThreadContextSnapshot(
"boss-thread-latest",
"thread-latest",
"最新线程",
"watch",
false,
22,
"2026-04-04T12:05:00+08:00",
"node-watch",
),
buildThreadContextSnapshot(
"boss-thread-watch",
"thread-watch",
"次要关注",
"urgent",
false,
61,
"2026-04-04T11:05:00+08:00",
"node-urgent",
),
];
const folder = getConversationHomeItems(state).find((item) => item.conversationType === "folder_archive");
assert.ok(folder, "expected grouped folder archive item");
assert.equal(folder?.contextBudgetIndicator.level, "urgent");
assert.equal(folder?.contextBudgetIndicator.percent, 61);
assert.equal(folder?.contextBudgetSourceNodeId, "node-urgent");
assert.equal(folder?.contextBudgetUpdatedAt, "2026-04-04T11:05:00+08:00");
});
test("folder archive context ring prefers newer latestReplyAt when mustFinishBeforeCompaction and contextBudgetLevel are equal", async () => {
await setup();
const state = await readState();
state.projects = state.projects.filter((project) => project.id === "master-agent");
state.projects.push(
buildImportedThreadProject(
"mac-studio",
"boss-thread-older",
"Boss",
"boss",
"较早线程",
"thread-older",
"2026-04-04T10:00:00+08:00",
),
buildImportedThreadProject(
"mac-studio",
"boss-thread-newer",
"Boss",
"boss",
"较新线程",
"thread-newer",
"2026-04-04T12:00:00+08:00",
),
);
state.threadContextSnapshots = [
buildThreadContextSnapshot(
"boss-thread-older",
"thread-older",
"较早线程",
"urgent",
false,
19,
"2026-04-04T10:05:00+08:00",
"node-older",
),
buildThreadContextSnapshot(
"boss-thread-newer",
"thread-newer",
"较新线程",
"urgent",
false,
19,
"2026-04-04T12:05:00+08:00",
"node-newer",
),
];
const folder = getConversationHomeItems(state).find((item) => item.conversationType === "folder_archive");
assert.ok(folder, "expected grouped folder archive item");
assert.equal(folder?.latestReplyAt, "2026-04-04T12:00:00+08:00");
assert.equal(folder?.contextBudgetIndicator.level, "urgent");
assert.equal(folder?.contextBudgetIndicator.percent, 19);
assert.equal(folder?.contextBudgetSourceNodeId, "node-newer");
assert.equal(folder?.contextBudgetUpdatedAt, "2026-04-04T12:05:00+08:00");
});
test("conversation home upgrades and downgrades a folder archive as thread count crosses 1 and 2", async () => {
await setup();
const state = await readState();