32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
const source = readFileSync(
|
|
new URL('../../app/h/[hostId]/session/[worktreeId].tsx', import.meta.url),
|
|
'utf8'
|
|
)
|
|
|
|
function sliceBetween(startPattern: string, endPattern: string): string {
|
|
const start = source.indexOf(startPattern)
|
|
expect(start).toBeGreaterThanOrEqual(0)
|
|
const end = source.indexOf(endPattern, start)
|
|
expect(end).toBeGreaterThan(start)
|
|
return source.slice(start, end)
|
|
}
|
|
|
|
describe('mobile session startup', () => {
|
|
it('auto-creates one terminal for an initially empty connected session', () => {
|
|
expect(source).toContain('const initialEmptySessionAutoCreateRef = useRef<string | null>(null)')
|
|
expect(source).toContain('initialEmptySessionAutoCreateRef.current = null')
|
|
|
|
const autoCreateEffect = sliceBetween(
|
|
'if (\n !client ||\n !showEmptyState',
|
|
'const terminalSummary ='
|
|
)
|
|
expect(autoCreateEffect).toContain('initialEmptySessionAutoCreateRef.current === worktreeId')
|
|
expect(autoCreateEffect).toContain('initialEmptySessionAutoCreateRef.current = worktreeId')
|
|
expect(autoCreateEffect).toContain("setCreateError('')")
|
|
expect(autoCreateEffect).toContain('void handleCreateTerminal()')
|
|
})
|
|
})
|