test: stabilize channel mode and discussion coverage

This commit is contained in:
zhi
2026-04-02 06:18:16 +00:00
parent 4e0a24333e
commit b11c15d8c8
6 changed files with 113 additions and 26 deletions

View File

@@ -117,15 +117,16 @@ describe("Shuffle Mode Tests", () => {
// Enable shuffling
setChannelShuffling(channelId, true);
// Single agent should work fine
// Dormant channels need a new message to activate the first speaker.
onNewMessage(channelId, "human-user", true);
const turnResult = checkTurn(channelId, "agent-a");
assert.strictEqual(turnResult.allowed, true);
onSpeakerDone(channelId, "agent-a", false);
// Should still work with single agent after reshuffle attempt
const turnResultAfter = checkTurn(channelId, "agent-a");
assert.strictEqual(turnResultAfter.allowed, true);
const stateAfter = getTurnDebugInfo(channelId);
assert.deepStrictEqual(stateAfter.turnOrder, ["agent-a"]);
assert.strictEqual(stateAfter.currentSpeaker, "agent-a");
});
it("should handle double agent scenario properly", () => {
@@ -135,6 +136,9 @@ describe("Shuffle Mode Tests", () => {
// Enable shuffling
setChannelShuffling(channelId, true);
// Activate the channel before exercising the round transition.
onNewMessage(channelId, "human-user", true);
const initialOrder = getTurnDebugInfo(channelId).turnOrder as string[];
const firstSpeaker = initialOrder[0];
const secondSpeaker = initialOrder[1];
@@ -146,14 +150,14 @@ describe("Shuffle Mode Tests", () => {
onSpeakerDone(channelId, secondSpeaker, false);
// The order might be reshuffled, but it should be valid
const newOrder = getTurnDebugInfo(channelId).turnOrder as string[];
const newState = getTurnDebugInfo(channelId);
const newOrder = newState.turnOrder as string[];
assert.strictEqual(newOrder.length, 2);
assert.ok(newOrder.includes("agent-a"));
assert.ok(newOrder.includes("agent-b"));
// Next speaker should be determined by the new order
const nextSpeaker = advanceTurn(channelId);
assert.ok(["agent-a", "agent-b"].includes(nextSpeaker as string));
// After a full round, the next current speaker should already be set.
assert.ok(["agent-a", "agent-b"].includes(newState.currentSpeaker as string));
});
});