Adapt to two contract changes master introduced: - The generated Remote face now wraps every business result in RemoteResult, folding carrier failures into an ok:false branch instead of rejecting. The controller reads that envelope at its three call sites and maps a carrier failure onto the same settled shape the controls already render; three specs cover the new branch. - Client packages split their tsconfig into host and client halves, and the host aggregate now compiles any test not named *.client.spec.*. Rename this package's specs to the client convention and drop the ../connection project reference, which pointed at a solution file that no longer carries the client sources. Keep master's mount loop with its rollback-on-failure in api-remotes and add messageFeedbackRemote to it.
66 lines
2.5 KiB
TypeScript
66 lines
2.5 KiB
TypeScript
// @vitest-environment jsdom
|
|
/**
|
|
* buildRenderApp on SlotTestRuntime: the fail-loud sessions precondition, the
|
|
* one ctx-level renderSlot('root') call, and the document-title projection
|
|
* arms over the real slot stack.
|
|
*/
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { cleanup, render } from '@testing-library/react'
|
|
import { Context } from '@deepseek-ai/cordis'
|
|
import { SlotTestRuntime } from '@deepseek-ai/dsh-client-test-runtime'
|
|
import type { SessionId } from '@deepseek-ai/dsh-client-runtime/client'
|
|
import { buildRenderApp } from '@deepseek-ai/dsh-client-web/src/app.tsx'
|
|
|
|
let runtime: SlotTestRuntime | undefined
|
|
|
|
afterEach(async () => {
|
|
cleanup()
|
|
await runtime?.dispose()
|
|
runtime = undefined
|
|
document.title = ''
|
|
})
|
|
|
|
async function bench() {
|
|
runtime = await SlotTestRuntime.create()
|
|
await runtime.root.declare({}, () => <div data-testid="frame" />)
|
|
return { runtime, renderApp: buildRenderApp({ ctx: runtime.ctx }) }
|
|
}
|
|
|
|
describe('buildRenderApp', () => {
|
|
it('fails loud when the sessions service is unavailable', () => {
|
|
expect(() => buildRenderApp({ ctx: new Context() })).toThrow('sessions service unavailable')
|
|
})
|
|
|
|
it('renders the root slot tree through the one ctx-level renderSlot call', async () => {
|
|
const b = await bench()
|
|
const view = render(<>{b.renderApp()}</>)
|
|
expect(view.getByTestId('frame')).toBeTruthy()
|
|
})
|
|
|
|
it('projects the current session durable title and falls back to the product title', async () => {
|
|
document.title = 'Product'
|
|
const b = await bench()
|
|
render(<>{b.renderApp()}</>)
|
|
// No current session: the product title stands.
|
|
expect(document.title).toBe('Product')
|
|
await b.runtime.sessions.add({ id: 's1', summary: { title: 'First' } })
|
|
expect(document.title).toBe('First — Product')
|
|
await b.runtime.sessions.setCurrent(undefined)
|
|
expect(document.title).toBe('Product')
|
|
// A session without a durable title keeps the product title.
|
|
await b.runtime.sessions.add({ id: 's2' })
|
|
expect(document.title).toBe('Product')
|
|
})
|
|
|
|
it('a current id without a list row falls back (selection/list arbitration transient)', async () => {
|
|
document.title = 'Product'
|
|
const b = await bench()
|
|
await b.runtime.sessions.add({ id: 's1', summary: { title: 'First' } })
|
|
render(<>{b.renderApp()}</>)
|
|
expect(document.title).toBe('First — Product')
|
|
b.runtime.sessions.list.update((draft) => { draft.current = 'ghost' as SessionId })
|
|
await b.runtime.flush()
|
|
expect(document.title).toBe('Product')
|
|
})
|
|
})
|