Machine-produced by `pnpm run rescope-vendor --apply` plus the regeneration it prints: `pnpm install` for the lockfile, `pnpm run gen-third-party-notices`, `verify-translation-pairing --write` for the touched bilingual pairs, `gen-doc-graphs`, and one typert snapshot whose ids embed character offsets. `pnpm run rescope-vendor --check` verifies the result. Renames nine vendored packages (cordis, cosmokit, schemastery and the six @cordisjs plugins) and every reference that resolves them: manifest names and dependency keys, module specifiers including declare-module merges, cordis.yml plugin names, tsconfig paths, every Markdown fence, and `docs/` prose. Directory names, upstream versions, and dependency ranges are unchanged, so vendor/README.md still reads as an upstream snapshot; its manifest table gains an upstream-name column so THIRD_PARTY_NOTICES keeps MIT attribution pointed at each fork's origin. The tutorial tier follows the rename end to end: its yaml fences named plugins the Loader can no longer resolve, its `ts ignore-check` fences disagreed with the compiled fences beside them, and its prose quoted both. The contracts that told readers to keep upstream names — the root convention and the vendoring cookbook's tree comment and manifest invariant — now say to rescope instead. Two rules read `@deepseek-ai/` as "another workspace plugin": the client bundle purity gate now names the vendored libraries a browser bundle inlines, and the files where a bare `cordis` is an agent-preset id keep that product data.
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')
|
|
})
|
|
})
|