Files
deepseek-harness/packages/client/web/tests/boot-page.client.spec.ts
T

54 lines
1.8 KiB
TypeScript

// @vitest-environment jsdom
import { afterEach, describe, expect, it } from 'vitest'
import { BootPage } from '../src/boot-page.ts'
afterEach(() => { document.body.innerHTML = '' })
function mount() {
const el = document.createElement('div')
document.body.append(el)
return { el, page: new BootPage(el) }
}
describe('BootPage', () => {
it('draws the loading skeleton before any plugin state arrives', () => {
const { el } = mount()
expect(el.textContent).toContain('HARNESS')
expect(el.textContent).toContain('Loading plugins…')
})
it('keeps loading while entries are active or loading', () => {
const { el, page } = mount()
page.setState('a', 'active')
page.setState('b', 'loading')
expect(el.textContent).toContain('Loading plugins…')
expect(el.textContent).not.toContain('Failed to load plugins')
})
it('lists failed entries', () => {
const { el, page } = mount()
page.setState('@deepseek-ai/dsh-client-ui-layout', 'failed')
page.setState('ok', 'active')
page.setState('@deepseek-ai/dsh-client-ui-tool', 'failed')
expect(el.textContent).toContain('@deepseek-ai/dsh-client-ui-layout')
expect(el.textContent).toContain('@deepseek-ai/dsh-client-ui-tool')
expect(el.textContent).not.toContain('ok')
expect(el.textContent).not.toContain('Loading plugins…')
})
it('shows the complete sweep report', () => {
const { el, page } = mount()
const report = 'web boot: 1 entry did not activate\nx: pending (waiting for service: y)'
page.fail(report)
page.setState('a', 'active')
expect(el.textContent).toContain(report)
expect(el.textContent).not.toContain('Loading plugins…')
})
it('detaches on disposal', () => {
const { el, page } = mount()
page.dispose()
expect(el.childNodes).toHaveLength(0)
})
})