Fix mail pointer repoint scheduler tests with pending count getter

Add pendingCount getter to MailPointerRepointScheduler to expose the
number of handles awaiting repoint. Replace flaky vi.getTimerCount()
assertions with direct scheduler state checks.
This commit is contained in:
Jinjing
2026-08-24 12:28:37 -07:00
parent 9d87532ecf
commit d9d48f4d08
2 changed files with 14 additions and 2 deletions
+9 -2
View File
@@ -1282,6 +1282,13 @@ function setInMemoryOrchestrationMessages(
runtime.setOrchestrationDb(db as unknown as OrchestrationDb)
}
function pendingMailPointerRepoints(runtime: OrcaRuntimeService): number {
const internals = runtime as unknown as {
mailPointerRepointScheduler: { pendingCount: number }
}
return internals.mailPointerRepointScheduler.pendingCount
}
function bindSinglePtyRun(db: InMemoryOrchestrationMessages, terminalHandle: string): string {
db.setRun({
id: 'run_test',
@@ -35712,7 +35719,7 @@ describe('OrcaRuntimeService', () => {
await vi.advanceTimersByTimeAsync(20_000)
expect(pendingReads).not.toHaveBeenCalled()
expect(vi.getTimerCount()).toBe(0)
expect(pendingMailPointerRepoints(runtime)).toBe(0)
runtime.onPtyData('pty-1', '\x1b]0;Codex done\x07', 101)
expect(pendingReads).toHaveBeenCalledTimes(1)
@@ -35799,7 +35806,7 @@ describe('OrcaRuntimeService', () => {
typeof payload === 'string' && payload.includes('orca orchestration check')
)
).toHaveLength(1)
expect(vi.getTimerCount()).toBe(0)
expect(pendingMailPointerRepoints(runtime)).toBe(0)
db.close()
} finally {
vi.useRealTimers()
@@ -20,6 +20,11 @@ export class MailPointerRepointScheduler {
this.timersByHandle.set(handle, timer)
}
/** Handles still awaiting a repoint; a quiet scheduler holds none. */
get pendingCount(): number {
return this.timersByHandle.size
}
clear(): void {
for (const timer of this.timersByHandle.values()) {
clearTimeout(timer)