test(hooks): remove unsafe test assertions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -80,7 +80,7 @@ describe("session-notification-sender", () => {
|
||||
describe("#when calling ctx.$ for notifications", () => {
|
||||
test("#then should call .quiet() on all shell commands to suppress stdout/stderr", async () => {
|
||||
const quietCalls: string[] = []
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: (cmd: TemplateStringsArray, ...values: unknown[]) => {
|
||||
const cmdStr = cmd.reduce((acc, part, i) => acc + part + (values[i] ?? ""), "")
|
||||
const result = { stdout: Buffer.from(""), stderr: Buffer.from(""), exitCode: 0 }
|
||||
@@ -95,7 +95,7 @@ describe("session-notification-sender", () => {
|
||||
promise.nothrow = () => promise
|
||||
return promise
|
||||
},
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
await sender.sendSessionNotification(mockCtx, "darwin", "Test", "Message")
|
||||
|
||||
@@ -107,7 +107,7 @@ describe("session-notification-sender", () => {
|
||||
spyOn(utils, "getTerminalNotifierPath").mockResolvedValue(null)
|
||||
|
||||
const quietCalls: string[] = []
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: (cmd: TemplateStringsArray, ...values: unknown[]) => {
|
||||
const cmdStr = cmd.reduce((acc, part, i) => acc + part + (values[i] ?? ""), "")
|
||||
const result = { stdout: Buffer.from(""), stderr: Buffer.from(""), exitCode: 0 }
|
||||
@@ -130,7 +130,7 @@ describe("session-notification-sender", () => {
|
||||
}
|
||||
return promise
|
||||
},
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
await sender.sendSessionNotification(mockCtx, "darwin", "Test", "Message")
|
||||
|
||||
@@ -142,9 +142,9 @@ describe("session-notification-sender", () => {
|
||||
spyOn(utils, "getCmuxPath").mockResolvedValue("/usr/local/bin/cmux")
|
||||
|
||||
const calls: string[] = []
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: createShellPromise((cmdStr) => { calls.push(cmdStr) }),
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
await sender.sendSessionNotification(mockCtx, "darwin", "Test", "Message")
|
||||
|
||||
@@ -157,9 +157,9 @@ describe("session-notification-sender", () => {
|
||||
test("#then should fall back to terminal-notifier when cmux fails", async () => {
|
||||
spyOn(utils, "getCmuxPath").mockResolvedValue("/usr/local/bin/cmux")
|
||||
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: createThrowingShellPromise((cmdStr) => cmdStr.includes("cmux notify")),
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
const originalFactory = mockCtx.$
|
||||
const trackingCalls: string[] = []
|
||||
@@ -180,9 +180,9 @@ describe("session-notification-sender", () => {
|
||||
spyOn(utils, "getCmuxPath").mockResolvedValue("/usr/local/bin/cmux")
|
||||
|
||||
const trackingCalls: string[] = []
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: createThrowingShellPromise((cmdStr) => cmdStr.includes("cmux notify") || cmdStr.includes("terminal-notifier")),
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
const originalFactory = mockCtx.$
|
||||
mockCtx.$ = ((cmd: TemplateStringsArray, ...values: unknown[]) => {
|
||||
@@ -200,9 +200,9 @@ describe("session-notification-sender", () => {
|
||||
|
||||
test("#then should skip cmux when not available and use terminal-notifier", async () => {
|
||||
const calls: string[] = []
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: createShellPromise((cmdStr) => { calls.push(cmdStr) }),
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
await sender.sendSessionNotification(mockCtx, "darwin", "Test", "Message")
|
||||
|
||||
@@ -213,7 +213,7 @@ describe("session-notification-sender", () => {
|
||||
|
||||
test("#then should call .quiet() on linux notify-send", async () => {
|
||||
const quietCalls: string[] = []
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: (cmd: TemplateStringsArray, ...values: unknown[]) => {
|
||||
const cmdStr = cmd.reduce((acc, part, i) => acc + part + (values[i] ?? ""), "")
|
||||
const result = { stdout: Buffer.from(""), stderr: Buffer.from(""), exitCode: 0 }
|
||||
@@ -236,7 +236,7 @@ describe("session-notification-sender", () => {
|
||||
}
|
||||
return promise
|
||||
},
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
await sender.sendSessionNotification(mockCtx, "linux", "Test", "Message")
|
||||
|
||||
@@ -246,7 +246,7 @@ describe("session-notification-sender", () => {
|
||||
|
||||
test("#then should call .quiet() on win32 powershell", async () => {
|
||||
const quietCalls: string[] = []
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: (cmd: TemplateStringsArray, ...values: unknown[]) => {
|
||||
const cmdStr = cmd.reduce((acc, part, i) => acc + part + (values[i] ?? ""), "")
|
||||
const result = { stdout: Buffer.from(""), stderr: Buffer.from(""), exitCode: 0 }
|
||||
@@ -269,7 +269,7 @@ describe("session-notification-sender", () => {
|
||||
}
|
||||
return promise
|
||||
},
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
await sender.sendSessionNotification(mockCtx, "win32", "Test", "Message")
|
||||
|
||||
@@ -283,7 +283,7 @@ describe("session-notification-sender", () => {
|
||||
describe("#when calling ctx.$ for sound playback", () => {
|
||||
test("#then should call .quiet() on darwin afplay", async () => {
|
||||
const quietCalls: string[] = []
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: (cmd: TemplateStringsArray, ...values: unknown[]) => {
|
||||
const cmdStr = cmd.reduce((acc, part, i) => acc + part + (values[i] ?? ""), "")
|
||||
const result = { stdout: Buffer.from(""), stderr: Buffer.from(""), exitCode: 0 }
|
||||
@@ -306,7 +306,7 @@ describe("session-notification-sender", () => {
|
||||
}
|
||||
return promise
|
||||
},
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
await sender.playSessionNotificationSound(mockCtx, "darwin", "/sound.aiff")
|
||||
|
||||
@@ -316,7 +316,7 @@ describe("session-notification-sender", () => {
|
||||
|
||||
test("#then should call .quiet() on linux paplay", async () => {
|
||||
const quietCalls: string[] = []
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: (cmd: TemplateStringsArray, ...values: unknown[]) => {
|
||||
const cmdStr = cmd.reduce((acc, part, i) => acc + part + (values[i] ?? ""), "")
|
||||
const result = { stdout: Buffer.from(""), stderr: Buffer.from(""), exitCode: 0 }
|
||||
@@ -339,7 +339,7 @@ describe("session-notification-sender", () => {
|
||||
}
|
||||
return promise
|
||||
},
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
await sender.playSessionNotificationSound(mockCtx, "linux", "/sound.oga")
|
||||
|
||||
@@ -351,7 +351,7 @@ describe("session-notification-sender", () => {
|
||||
spyOn(utils, "getPaplayPath").mockResolvedValue(null)
|
||||
|
||||
const quietCalls: string[] = []
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: (cmd: TemplateStringsArray, ...values: unknown[]) => {
|
||||
const cmdStr = cmd.reduce((acc, part, i) => acc + part + (values[i] ?? ""), "")
|
||||
const result = { stdout: Buffer.from(""), stderr: Buffer.from(""), exitCode: 0 }
|
||||
@@ -374,7 +374,7 @@ describe("session-notification-sender", () => {
|
||||
}
|
||||
return promise
|
||||
},
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
await sender.playSessionNotificationSound(mockCtx, "linux", "/sound.oga")
|
||||
|
||||
@@ -384,7 +384,7 @@ describe("session-notification-sender", () => {
|
||||
|
||||
test("#then should call .quiet() on win32 powershell sound", async () => {
|
||||
const quietCalls: string[] = []
|
||||
const mockCtx = {
|
||||
const mockCtx = testCoerce<PluginInput>({
|
||||
$: (cmd: TemplateStringsArray, ...values: unknown[]) => {
|
||||
const cmdStr = cmd.reduce((acc, part, i) => acc + part + (values[i] ?? ""), "")
|
||||
const result = { stdout: Buffer.from(""), stderr: Buffer.from(""), exitCode: 0 }
|
||||
@@ -407,7 +407,7 @@ describe("session-notification-sender", () => {
|
||||
}
|
||||
return promise
|
||||
},
|
||||
} as unknown as PluginInput
|
||||
})
|
||||
|
||||
await sender.playSessionNotificationSound(mockCtx, "win32", "C:\\sound.wav")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user