| 15 | const millisecondsInOneMinute = 60_000; |
| 16 | |
| 17 | function generateMockLogs( |
| 18 | logCount: number, |
| 19 | baseDate = new Date("April 1, 1970"), |
| 20 | ): readonly WorkspaceAgentLog[] { |
| 21 | return Array.from({ length: logCount }, (_, i) => { |
| 22 | // Make sure that the logs generated each have unique timestamps, so |
| 23 | // that we can test whether the hook is sorting them properly as it's |
| 24 | // receiving them over time |
| 25 | const logDate = new Date(baseDate.getTime() + i * millisecondsInOneMinute); |
| 26 | return { |
| 27 | id: i, |
| 28 | created_at: logDate.toISOString(), |
| 29 | level: "info", |
| 30 | output: `Log ${i}`, |
| 31 | source_id: "", |
| 32 | }; |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | // A mutable object holding the most recent mock WebSocket server that was |
| 37 | // created when initializing a mock WebSocket. Inner value will be undefined if |