@@ -2,35 +2,12 @@
|
2 | 2 | import { describe, expect, it } from "vitest"; |
3 | 3 | import type { SessionState } from "../logging/diagnostic-session-state.js"; |
4 | 4 | import { |
5 | | -calculateBackoffMs, |
6 | | -getCommandPollSuggestion, |
7 | 5 | pruneStaleCommandPolls, |
8 | 6 | recordCommandPoll, |
9 | 7 | resetCommandPollCount, |
10 | 8 | } from "./command-poll-backoff.js"; |
11 | 9 | |
12 | 10 | describe("command-poll-backoff", () => { |
13 | | -describe("calculateBackoffMs", () => { |
14 | | -it("returns 5s for first poll", () => { |
15 | | -expect(calculateBackoffMs(0)).toBe(5000); |
16 | | -}); |
17 | | - |
18 | | -it("returns 10s for second poll", () => { |
19 | | -expect(calculateBackoffMs(1)).toBe(10000); |
20 | | -}); |
21 | | - |
22 | | -it("returns 30s for third poll", () => { |
23 | | -expect(calculateBackoffMs(2)).toBe(30000); |
24 | | -}); |
25 | | - |
26 | | -it("returns 60s for fourth and subsequent polls (capped)", () => { |
27 | | -expect(calculateBackoffMs(3)).toBe(60000); |
28 | | -expect(calculateBackoffMs(4)).toBe(60000); |
29 | | -expect(calculateBackoffMs(10)).toBe(60000); |
30 | | -expect(calculateBackoffMs(100)).toBe(60000); |
31 | | -}); |
32 | | -}); |
33 | | - |
34 | 11 | describe("recordCommandPoll", () => { |
35 | 12 | it("returns 5s on first no-output poll", () => { |
36 | 13 | const state: SessionState = { |
@@ -94,30 +71,6 @@ describe("command-poll-backoff", () => {
|
94 | 71 | }); |
95 | 72 | }); |
96 | 73 | |
97 | | -describe("getCommandPollSuggestion", () => { |
98 | | -it("returns undefined for untracked command", () => { |
99 | | -const state: SessionState = { |
100 | | -lastActivity: Date.now(), |
101 | | -state: "processing", |
102 | | -queueDepth: 0, |
103 | | -}; |
104 | | -expect(getCommandPollSuggestion(state, "unknown")).toBeUndefined(); |
105 | | -}); |
106 | | - |
107 | | -it("returns current backoff for tracked command", () => { |
108 | | -const state: SessionState = { |
109 | | -lastActivity: Date.now(), |
110 | | -state: "processing", |
111 | | -queueDepth: 0, |
112 | | -}; |
113 | | - |
114 | | -recordCommandPoll(state, "cmd-123", false); |
115 | | -recordCommandPoll(state, "cmd-123", false); |
116 | | - |
117 | | -expect(getCommandPollSuggestion(state, "cmd-123")).toBe(10000); |
118 | | -}); |
119 | | -}); |
120 | | - |
121 | 74 | describe("resetCommandPollCount", () => { |
122 | 75 | it("removes command from tracking", () => { |
123 | 76 | const state: SessionState = { |
|