mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
# Conflicts: # .agents/notes/implemented/architecture/2026-07-05-reconstructable-requests.i18n.yaml # .agents/notes/implemented/architecture/2026-07-05-reconstructable-requests.md # .agents/notes/implemented/architecture/2026-07-05-reconstructable-requests.zh.md # .agents/notes/implemented/architecture/2026-07-25-web-input-machine-and-slash-pipeline.i18n.yaml # .agents/notes/implemented/architecture/2026-07-25-web-input-machine-and-slash-pipeline.md # .agents/notes/implemented/architecture/2026-07-25-web-input-machine-and-slash-pipeline.zh.md # THIRD_PARTY_NOTICES.md # apps/cli/composition.md # apps/cli/config/base.cordis.yml # apps/cli/package.json # apps/cli/src/app-cli-entry.ts # apps/cli/src/bin.ts # apps/cli/tests/args.spec.ts # apps/web/tests/built-boot.snapshot.ts # apps/web/tests/navigation-panes.e2e.ts # docs/architecture.i18n.yaml # docs/architecture.md # docs/architecture.zh.md # docs/config-catalog.md # docs/cordis-catalog/services.md # docs/core-data-structures/core.i18n.yaml # docs/core-data-structures/llm-streaming.i18n.yaml # docs/event-producer-consumer.md # docs/module-graph.md # examples/acp-agent/tests/snapshots/cordis-inspect-jsdoc/session.jsonl # packages/README.i18n.yaml # packages/bundle/README.i18n.yaml # packages/client/connection/README.i18n.yaml # packages/client/connection/README.md # packages/client/connection/README.zh.md # packages/client/connection/src/client/fixture.ts # packages/client/connection/src/http-bridge.ts # packages/client/connection/src/index.ts # packages/client/connection/tests/fixture.spec.ts # packages/client/connection/tests/node-half.spec.ts # packages/client/runtime/README.i18n.yaml # packages/client/runtime/README.md # packages/client/runtime/README.zh.md # packages/client/runtime/src/client/contract/session.ts # packages/client/runtime/src/client/sessions/session.ts # packages/client/ui-conversation/README.i18n.yaml # packages/client/ui-conversation/README.md # packages/client/ui-conversation/README.zh.md # packages/client/ui-conversation/src/client/apply.ts # packages/client/ui-conversation/src/client/chat/AssistantMarkdown.tsx # packages/client/ui-conversation/src/client/chat/ChatView.tsx # packages/client/ui-conversation/src/client/chat/MessageItem.module.css # packages/client/ui-conversation/src/client/chat/MessageItem.tsx # packages/client/ui-conversation/src/client/contract/slots.ts # packages/client/ui-conversation/src/client/index.ts # packages/client/ui-conversation/src/client/input/contract.ts # packages/client/ui-conversation/src/client/input/facade.ts # packages/client/ui-conversation/src/client/input/hub.ts # packages/client/ui-conversation/src/client/locales.ts # packages/client/ui-conversation/src/client/service.ts # packages/client/ui-conversation/src/client/skeleton/ConversationSession.tsx # packages/client/ui-conversation/src/client/skeleton/InputBar.tsx # packages/client/ui-conversation/tests/apply-inject.spec.tsx # packages/client/ui-conversation/tests/input-bar.spec.tsx # packages/client/ui-conversation/tests/input-matrix.spec.tsx # packages/client/ui-conversation/tests/input-scenarios.spec.tsx # packages/client/ui-conversation/tests/service-orchestration.spec.ts # packages/client/ui-conversation/tests/skeleton.spec.tsx # packages/client/ui-trajectory/tests/views.spec.tsx # packages/compact/compact-basic/README.i18n.yaml # packages/cordis/tool-cordis/src/api-catalog.ts # packages/host/apiproxy/README.i18n.yaml # packages/host/apiproxy/README.md # packages/host/apiproxy/README.zh.md # packages/host/apiproxy/src/api-proxy.ts # packages/host/apiproxy/src/api/rpc.ts # packages/host/apiproxy/src/api/sessions.ts # packages/host/apiproxy/src/index.ts # packages/host/apiproxy/tests/api-proxy-models.spec.ts # packages/host/apiproxy/tests/rpc-schemas.spec.ts # packages/llm/llm-pi-ai/README.i18n.yaml # packages/llm/llm-pi-ai/README.md # packages/llm/llm-pi-ai/README.zh.md # packages/llm/llm-pi-ai/src/adapter.ts # packages/llm/llm/README.i18n.yaml # packages/ui/tui/README.md # packages/ui/tui/README.zh.md # packages/ui/tui/src/components/content.ts # packages/ui/tui/src/components/transcript.ts # packages/ui/tui/tests/tui.spec.ts # pnpm-lock.yaml
139 lines
5.9 KiB
TypeScript
139 lines
5.9 KiB
TypeScript
// @vitest-environment jsdom
|
|
// Multimodal image surfaces over the BUILT client graph (the code-mode-fixture
|
|
// idiom: real bundles via AppWebEntry, keyless FixtureApiClient transport).
|
|
// Opens the fixture history session whose turn 71 carries an image in BOTH a
|
|
// user message and an assistant message, and pins the product surfaces: the
|
|
// history ImageGallery loading real fixture bytes through the authorized
|
|
// sessions.attachment route, the double-click ImageLightbox, and the composer
|
|
// intake chain (paste → ordered thumbnail rail → image-only send enablement → remove).
|
|
import { fireEvent, screen, waitFor, within } from '@testing-library/react'
|
|
import { expect, it } from 'vitest'
|
|
import { installAssembledBootEnv, mountAssembledApp } from './assembled-boot.ts'
|
|
|
|
installAssembledBootEnv()
|
|
|
|
/** Open the fixture history session (the alpha log carrying the turn-71 image pair) and wait for its gallery. */
|
|
async function openFixtureSession(): Promise<void> {
|
|
const tree = await screen.findByRole('tree', { name: '会话' }, { timeout: 10_000 })
|
|
const group = (await within(tree).findAllByText('fixture'))
|
|
.map(el => el.closest<HTMLElement>('[role="treeitem"]'))
|
|
.find(el => el?.getAttribute('aria-expanded') !== null)
|
|
if (group === null || group === undefined) throw new Error('fixture Workspace group missing')
|
|
if (group.getAttribute('aria-expanded') === 'false') {
|
|
fireEvent.click(within(group).getByText('fixture'))
|
|
await waitFor(() => {
|
|
expect(group.getAttribute('aria-expanded')).toBe('true')
|
|
})
|
|
}
|
|
const session = await within(tree).findByText('Fixture 历史会话')
|
|
fireEvent.click(session)
|
|
await waitFor(() => {
|
|
expect(document.querySelectorAll('[data-align] img').length).toBeGreaterThan(0)
|
|
}, { timeout: 10_000 })
|
|
}
|
|
|
|
it('renders the history image pair through the authorized attachment route and opens the lightbox', async () => {
|
|
localStorage.setItem('dsh.locale', 'zh')
|
|
mountAssembledApp()
|
|
await openFixtureSession()
|
|
|
|
// Both the user-side (align=end) and assistant-side (align=start) galleries
|
|
// load real fixture bytes over sessions.attachment. jsdom provides
|
|
// createObjectURL, so this environment MUST take the object-URL path — a
|
|
// data: src here would mean the fallback ran where it should not.
|
|
await waitFor(() => {
|
|
if (document.querySelector('[data-align="end"] img') === null
|
|
|| document.querySelector('[data-align="start"] img') === null) {
|
|
throw new Error('history image galleries missing')
|
|
}
|
|
}, { timeout: 10_000 })
|
|
const galleryShape = (align: string) => [...document.querySelectorAll(`[data-align="${align}"] img`)]
|
|
.map(img => ({ alt: img.getAttribute('alt'), scheme: img.getAttribute('src')?.split(':')[0] }))
|
|
expect({ user: galleryShape('end'), assistant: galleryShape('start') }).toMatchInlineSnapshot(`
|
|
{
|
|
"assistant": [
|
|
{
|
|
"alt": "fixture-image.png",
|
|
"scheme": "blob",
|
|
},
|
|
],
|
|
"user": [
|
|
{
|
|
"alt": "fixture-image.png",
|
|
"scheme": "blob",
|
|
},
|
|
],
|
|
}
|
|
`)
|
|
const userImage = document.querySelector<HTMLElement>('[data-align="end"] img')!
|
|
|
|
// Double-click opens the original-size lightbox; Escape/close dismisses it.
|
|
const frame = userImage.closest('button')
|
|
if (frame === null) throw new Error('image frame button missing')
|
|
fireEvent.doubleClick(frame)
|
|
const lightbox = await screen.findByRole('dialog')
|
|
expect(within(lightbox).getByRole('img').getAttribute('src')?.split(':')[0]).toBe('blob')
|
|
fireEvent.click(within(lightbox).getByRole('button', { name: /关闭/ }))
|
|
await waitFor(() => {
|
|
expect(screen.queryByRole('dialog')).toBeNull()
|
|
})
|
|
})
|
|
|
|
it('accepts pasted images into the composer rail in order and removes them', async () => {
|
|
localStorage.setItem('dsh.locale', 'zh')
|
|
mountAssembledApp()
|
|
|
|
const tree = await screen.findByRole('tree', { name: '会话' }, { timeout: 10_000 })
|
|
const start = tree.querySelector<HTMLButtonElement>('button[aria-label="在“fixture”中新建会话"]')
|
|
if (start === null) throw new Error('fixture Workspace new-session action missing')
|
|
fireEvent.click(start)
|
|
|
|
// Image-only send arming is pinned at package level (input-bar.spec.tsx);
|
|
// this assembled lane pins the intake chain over the built graph.
|
|
const textarea = await screen.findByPlaceholderText('描述你想要构建的内容', {}, { timeout: 10_000 })
|
|
const image = new File([new Uint8Array([137, 80, 78, 71])], 'pasted.png', { type: 'image/png' })
|
|
fireEvent.paste(textarea, {
|
|
clipboardData: {
|
|
items: [{ kind: 'file', type: 'image/png', getAsFile: () => image }],
|
|
getData: () => '',
|
|
},
|
|
})
|
|
|
|
// The rail is an accessible group holding the draft thumbnail (queried via
|
|
// DOM: jsdom's a11y-visibility computation hides the composer subtree).
|
|
const rail = await waitFor(() => {
|
|
const el = document.querySelector('[role="group"][aria-label="待发送图片"]')
|
|
if (el === null) throw new Error('attachment rail missing')
|
|
return el
|
|
}, { timeout: 5_000 })
|
|
expect([...rail.querySelectorAll('img')].map(img => ({
|
|
alt: img.getAttribute('alt'), scheme: img.getAttribute('src')?.split(':')[0],
|
|
}))).toMatchInlineSnapshot(`
|
|
[
|
|
{
|
|
"alt": "pasted.png",
|
|
"scheme": "blob",
|
|
},
|
|
]
|
|
`)
|
|
|
|
const second = new File([new Uint8Array([137, 80, 78, 71])], 'second.png', { type: 'image/png' })
|
|
fireEvent.paste(textarea, {
|
|
clipboardData: {
|
|
items: [{ kind: 'file', type: 'image/png', getAsFile: () => second }],
|
|
getData: () => '',
|
|
},
|
|
})
|
|
await waitFor(() => {
|
|
expect([...rail.querySelectorAll('img')].map(img => img.getAttribute('alt')))
|
|
.toEqual(['pasted.png', 'second.png'])
|
|
})
|
|
|
|
const remove = [...rail.querySelectorAll('button[aria-label^="移除图片"]')]
|
|
if (remove.length !== 2) throw new Error('remove buttons missing')
|
|
for (const button of remove) fireEvent.click(button)
|
|
await waitFor(() => {
|
|
expect(document.querySelector('[role="group"][aria-label="待发送图片"]')).toBeNull()
|
|
})
|
|
})
|