36 lines
1.8 KiB
TypeScript
36 lines
1.8 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
describe('desktop startup ordering', () => {
|
|
it('passes the startup barrier into PTY handlers without blocking window creation', () => {
|
|
const source = readFileSync(join(process.cwd(), 'src/main/index.ts'), 'utf8')
|
|
const attachStart = source.indexOf('attachMainWindowServices(')
|
|
const attachEnd = source.indexOf('rateLimits.attach(window)', attachStart)
|
|
const attachBlock = source.slice(attachStart, attachEnd)
|
|
const desktopStart = source.indexOf('const [win] = await Promise.all([')
|
|
const desktopEnd = source.indexOf('// Why: the macOS notification permission dialog')
|
|
const desktopStartup = source.slice(desktopStart, desktopEnd)
|
|
|
|
expect(attachBlock).toContain('awaitLocalPtyStartup: () => localPtyStartupReady')
|
|
expect(source).toContain('firstWindowStartupServicesReady = startupServices.firstWindowReady')
|
|
expect(source).toContain('localPtyStartupReady = startupServices.localPtyReady')
|
|
|
|
const windowIndex = desktopStartup.indexOf('Promise.resolve(openMainWindow())')
|
|
const rpcStartIndex = desktopStartup.indexOf('desktopRuntimeRpc.start()')
|
|
const legacyRpcStartIndex = desktopStartup.indexOf('runtimeRpc.start()')
|
|
|
|
expect(windowIndex).toBeGreaterThanOrEqual(0)
|
|
expect(Math.max(rpcStartIndex, legacyRpcStartIndex)).toBeGreaterThanOrEqual(0)
|
|
})
|
|
|
|
it('does not run the rate-limit quota fetch before the first window can show results', () => {
|
|
const source = readFileSync(join(process.cwd(), 'src/main/index.ts'), 'utf8')
|
|
const attachIndex = source.indexOf('rateLimits.attach(window)')
|
|
const startIndex = source.indexOf('rateLimits.start({ fetchImmediately: false })')
|
|
|
|
expect(attachIndex).toBeGreaterThanOrEqual(0)
|
|
expect(startIndex).toBeGreaterThan(attachIndex)
|
|
})
|
|
})
|