mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 11:53:10 +08:00
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
describe('app mode restart lifecycle', () => {
|
|
it('synchronously stops Windows sidecars before relaunching with another data directory', () => {
|
|
const desktopDir = path.basename(process.cwd()) === 'desktop'
|
|
? process.cwd()
|
|
: path.join(process.cwd(), 'desktop')
|
|
const source = readFileSync(path.join(desktopDir, 'electron', 'main.ts'), 'utf8')
|
|
const handler = source.match(
|
|
/registerHandler\(ELECTRON_IPC_CHANNELS\.appModePrepareRestart,[\s\S]*?\n\s*registerHandler/,
|
|
)?.[0]
|
|
|
|
expect(handler).toContain('getServerRuntime().stopAll(true)')
|
|
})
|
|
|
|
it('keeps the Electron host alive until graceful server shutdown finishes', () => {
|
|
const desktopDir = path.basename(process.cwd()) === 'desktop'
|
|
? process.cwd()
|
|
: path.join(process.cwd(), 'desktop')
|
|
const source = readFileSync(path.join(desktopDir, 'electron', 'main.ts'), 'utf8')
|
|
const handler = source.match(/app\.on\('before-quit',[\s\S]*\n\}\)\s*$/)?.[0]
|
|
|
|
expect(handler).toContain('event.preventDefault()')
|
|
expect(handler).toContain('getServerRuntime().stopAllAndWait()')
|
|
expect(handler).toMatch(/stopAllAndWait\(\)[\s\S]*app\.quit\(\)/)
|
|
})
|
|
})
|