fix(test): align zombie pane tmux mocks
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
/// <reference path="../../../bun-test.d.ts" />
|
||||||
import { beforeEach, describe, expect, mock, test, afterAll } from "bun:test"
|
import { beforeEach, describe, expect, mock, test, afterAll } from "bun:test"
|
||||||
import type { TmuxConfig } from "../../config/schema"
|
import type { TmuxConfig } from "../../config/schema"
|
||||||
import type { ActionResult, ExecuteContext, ExecuteActionsResult } from "./action-executor"
|
import type { ActionResult, ExecuteContext, ExecuteActionsResult } from "./action-executor"
|
||||||
@@ -25,6 +26,9 @@ const mockExecuteActions = mock<(
|
|||||||
results: [],
|
results: [],
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
const mockSpawnTmuxWindow = mock(async () => ({ success: true, paneId: "%window" }))
|
||||||
|
const mockSpawnTmuxSession = mock(async () => ({ success: true, paneId: "%session" }))
|
||||||
|
|
||||||
const mockIsInsideTmux = mock<() => boolean>(() => true)
|
const mockIsInsideTmux = mock<() => boolean>(() => true)
|
||||||
const mockGetCurrentPaneId = mock<() => string | undefined>(() => "%0")
|
const mockGetCurrentPaneId = mock<() => string | undefined>(() => "%0")
|
||||||
|
|
||||||
@@ -44,6 +48,8 @@ mock.module("../../shared/tmux", () => ({
|
|||||||
SESSION_READY_POLL_INTERVAL_MS: 10,
|
SESSION_READY_POLL_INTERVAL_MS: 10,
|
||||||
SESSION_READY_TIMEOUT_MS: 50,
|
SESSION_READY_TIMEOUT_MS: 50,
|
||||||
SESSION_MISSING_GRACE_MS: 1_000,
|
SESSION_MISSING_GRACE_MS: 1_000,
|
||||||
|
spawnTmuxWindow: mockSpawnTmuxWindow,
|
||||||
|
spawnTmuxSession: mockSpawnTmuxSession,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
afterAll(() => { mock.restore() })
|
afterAll(() => { mock.restore() })
|
||||||
@@ -56,6 +62,7 @@ const mockTmuxDeps: TmuxUtilDeps = {
|
|||||||
function createConfig(): TmuxConfig {
|
function createConfig(): TmuxConfig {
|
||||||
return {
|
return {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
isolation: "inline",
|
||||||
layout: "main-vertical",
|
layout: "main-vertical",
|
||||||
main_pane_size: 60,
|
main_pane_size: 60,
|
||||||
main_pane_min_width: 80,
|
main_pane_min_width: 80,
|
||||||
@@ -156,6 +163,8 @@ describe("TmuxSessionManager zombie pane handling", () => {
|
|||||||
mockQueryWindowState.mockClear()
|
mockQueryWindowState.mockClear()
|
||||||
mockExecuteAction.mockClear()
|
mockExecuteAction.mockClear()
|
||||||
mockExecuteActions.mockClear()
|
mockExecuteActions.mockClear()
|
||||||
|
mockSpawnTmuxWindow.mockClear()
|
||||||
|
mockSpawnTmuxSession.mockClear()
|
||||||
mockIsInsideTmux.mockClear()
|
mockIsInsideTmux.mockClear()
|
||||||
mockGetCurrentPaneId.mockClear()
|
mockGetCurrentPaneId.mockClear()
|
||||||
|
|
||||||
@@ -171,6 +180,8 @@ describe("TmuxSessionManager zombie pane handling", () => {
|
|||||||
spawnedPaneId: "%1",
|
spawnedPaneId: "%1",
|
||||||
results: [],
|
results: [],
|
||||||
}))
|
}))
|
||||||
|
mockSpawnTmuxWindow.mockImplementation(async () => ({ success: true, paneId: "%window" }))
|
||||||
|
mockSpawnTmuxSession.mockImplementation(async () => ({ success: true, paneId: "%session" }))
|
||||||
mockIsInsideTmux.mockReturnValue(true)
|
mockIsInsideTmux.mockReturnValue(true)
|
||||||
mockGetCurrentPaneId.mockReturnValue("%0")
|
mockGetCurrentPaneId.mockReturnValue("%0")
|
||||||
})
|
})
|
||||||
@@ -259,9 +270,15 @@ describe("TmuxSessionManager zombie pane handling", () => {
|
|||||||
"ses_pending",
|
"ses_pending",
|
||||||
createTrackedSession({ closePending: true, closeRetryCount: 0 }),
|
createTrackedSession({ closePending: true, closeRetryCount: 0 }),
|
||||||
)
|
)
|
||||||
mockExecuteAction.mockImplementationOnce(async () => {
|
let shouldFailClose = true
|
||||||
sessions.delete("ses_pending")
|
mockExecuteAction.mockImplementation(async () => {
|
||||||
return { success: false }
|
if (shouldFailClose) {
|
||||||
|
shouldFailClose = false
|
||||||
|
sessions.delete("ses_pending")
|
||||||
|
return { success: false }
|
||||||
|
}
|
||||||
|
|
||||||
|
return { success: true }
|
||||||
})
|
})
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
|||||||
Reference in New Issue
Block a user