mirror of
https://github.com/stablyai/orca.git
synced 2026-10-28 00:02:54 +00:00
Fix PR CI and guard resume relay during shutdown
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -647,10 +647,11 @@ describe('CdpWsProxy', () => {
|
||||
})
|
||||
|
||||
it('does not register a PDF stream when the client disconnects mid-print', async () => {
|
||||
let resolvePrint: (buf: Buffer) => void = () => {}
|
||||
type PrintToPdfData = Awaited<ReturnType<typeof mock.webContents.printToPDF>>
|
||||
let resolvePrint: (buf: PrintToPdfData) => void = () => {}
|
||||
mock.webContents.printToPDF.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise<Buffer>((resolve) => {
|
||||
new Promise<PrintToPdfData>((resolve) => {
|
||||
resolvePrint = resolve
|
||||
})
|
||||
)
|
||||
|
||||
@@ -2822,6 +2822,7 @@ describe('createMainWindow', () => {
|
||||
invalidate: vi.fn(),
|
||||
setWindowOpenHandler: vi.fn(),
|
||||
send: vi.fn(),
|
||||
isDestroyed: vi.fn(() => false),
|
||||
id: 1
|
||||
}
|
||||
const instance = {
|
||||
@@ -2883,6 +2884,20 @@ describe('createMainWindow', () => {
|
||||
expect(webContents.invalidate).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not send the resume event once webContents is destroyed', () => {
|
||||
const { webContents } = setupResumeWindow()
|
||||
createMainWindow(null)
|
||||
const onResume = getPowerResumeListener()
|
||||
webContents.isDestroyed.mockReturnValue(true)
|
||||
webContents.send.mockClear()
|
||||
webContents.invalidate.mockClear()
|
||||
|
||||
onResume()
|
||||
|
||||
expect(webContents.send).not.toHaveBeenCalled()
|
||||
expect(webContents.invalidate).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('removes the powerMonitor resume listener when the window closes', () => {
|
||||
const { windowHandlers } = setupResumeWindow()
|
||||
createMainWindow(null)
|
||||
|
||||
@@ -345,7 +345,7 @@ export function createMainWindow(
|
||||
// run. Relay powerMonitor resume explicitly (supported on mac/win/linux)
|
||||
// and force a repaint so stale compositor surfaces recover too.
|
||||
const onSystemResume = (): void => {
|
||||
if (mainWindow.isDestroyed()) {
|
||||
if (mainWindow.isDestroyed() || mainWindow.webContents.isDestroyed?.() === true) {
|
||||
return
|
||||
}
|
||||
forceRepaint(mainWindow)
|
||||
|
||||
Reference in New Issue
Block a user