cc-haha/desktop/electron/services/appModeLifecycle.test.ts
2026-07-11 21:09:19 +08:00

18 lines
700 B
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)')
})
})