test(design): cover chat quote handoff
This commit is contained in:
@@ -14,6 +14,7 @@ import { useImageWorkspaceStore } from '@/stores/image-workspace';
|
||||
import {
|
||||
designBootstrapFixture,
|
||||
designFormFixture,
|
||||
designQuoteFixture,
|
||||
designSummaryFixture,
|
||||
designWorkspaceFixture,
|
||||
} from '../fixtures/design-workspace-v2';
|
||||
@@ -688,6 +689,135 @@ describe('V2 Living Form store', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps the Quote created immediately after a committed generation chat', async () => {
|
||||
const source = await loadedStore();
|
||||
const message = '开始生成';
|
||||
const quoteForm = designFormFixture({
|
||||
directionRevision: 6,
|
||||
rawTurnSequence: 2,
|
||||
workspaceViewRevision: 8,
|
||||
activeQuotes: [designQuoteFixture()],
|
||||
});
|
||||
const canonical = designWorkspaceFixture({
|
||||
form: quoteForm,
|
||||
turns: [
|
||||
...designWorkspaceFixture().turns,
|
||||
{
|
||||
turnId: 'turn-2',
|
||||
rawTurnSequence: 2,
|
||||
userMessage: message,
|
||||
assistantMessage: '我先检查制作方案。准备好后需要你确认一次,确认后才会开始生成。',
|
||||
},
|
||||
],
|
||||
});
|
||||
fetchProjectMock.mockResolvedValue(canonical);
|
||||
useImageWorkspaceStore.setState({
|
||||
chatDraft: message,
|
||||
pendingOperations: {
|
||||
'operation-1': {
|
||||
id: 'operation-1',
|
||||
label: '发送创作想法',
|
||||
command: {
|
||||
kind: 'apply_input',
|
||||
workspaceId: 'workspace-1',
|
||||
sessionId: 'session-1',
|
||||
expectedDirectionRevision: 4,
|
||||
clientOperationId: 'operation-1',
|
||||
input: { kind: 'chat', message },
|
||||
},
|
||||
status: 'submitting',
|
||||
error: null,
|
||||
clearDraftPaths: [],
|
||||
clearChatDraft: true,
|
||||
baseRawTurnSequence: 1,
|
||||
},
|
||||
},
|
||||
assistantActivities: {
|
||||
'operation-1': {
|
||||
workspaceId: 'workspace-1',
|
||||
directionId: 'direction-1',
|
||||
status: 'submitting',
|
||||
turnId: null,
|
||||
steps: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
source.emit('design.direction.updated', {
|
||||
id: 'session-1:19',
|
||||
type: 'design.direction.updated',
|
||||
clientOperationId: 'operation-1',
|
||||
replayed: false,
|
||||
operation: {
|
||||
operationKind: 'chat',
|
||||
interactionId: 'interaction-2',
|
||||
baseDirectionRevision: 4,
|
||||
newDirectionRevision: 5,
|
||||
rawTurnSequence: 2,
|
||||
specificationRevision: 3,
|
||||
specificationRevisionId: 'specification-revision-3',
|
||||
workspaceViewRevision: 7,
|
||||
specificationRevisionCreated: false,
|
||||
meaningChanged: false,
|
||||
changeSet: { interaction_id: 'interaction-2', changes: [] },
|
||||
turnId: 'turn-2',
|
||||
assistantMessage: '我先检查制作方案。准备好后需要你确认一次,确认后才会开始生成。',
|
||||
createdDecisionPromptIds: [],
|
||||
resolvedDecisionPromptId: null,
|
||||
supersededDecisionPromptIds: [],
|
||||
supersededQuoteCount: 0,
|
||||
quoteId: null,
|
||||
generationTaskId: null,
|
||||
},
|
||||
form: designFormFixture({
|
||||
directionRevision: 5,
|
||||
rawTurnSequence: 2,
|
||||
workspaceViewRevision: 7,
|
||||
}),
|
||||
});
|
||||
source.emit('design.direction.updated', {
|
||||
id: 'session-1:20',
|
||||
type: 'design.direction.updated',
|
||||
clientOperationId: 'operation-1',
|
||||
replayed: false,
|
||||
operation: {
|
||||
operationKind: 'quote_request',
|
||||
interactionId: 'interaction-quote-1',
|
||||
baseDirectionRevision: 5,
|
||||
newDirectionRevision: 6,
|
||||
rawTurnSequence: 2,
|
||||
specificationRevision: 3,
|
||||
specificationRevisionId: 'specification-revision-3',
|
||||
workspaceViewRevision: 8,
|
||||
specificationRevisionCreated: false,
|
||||
meaningChanged: false,
|
||||
changeSet: { interaction_id: 'interaction-quote-1', changes: [] },
|
||||
turnId: null,
|
||||
assistantMessage: null,
|
||||
createdDecisionPromptIds: [],
|
||||
resolvedDecisionPromptId: null,
|
||||
supersededDecisionPromptIds: [],
|
||||
supersededQuoteCount: 0,
|
||||
quoteId: 'quote-1',
|
||||
generationTaskId: null,
|
||||
},
|
||||
form: quoteForm,
|
||||
});
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(useImageWorkspaceStore.getState()).toMatchObject({
|
||||
chatDraft: '',
|
||||
pendingOperations: {},
|
||||
workspace: { form: { directionRevision: 6 } },
|
||||
});
|
||||
});
|
||||
expect(useImageWorkspaceStore.getState().workspace?.form.activeQuotes)
|
||||
.toEqual([designQuoteFixture()]);
|
||||
expect(useImageWorkspaceStore.getState().assistantActivities).toMatchObject({
|
||||
'operation-1': { status: 'completed', turnId: 'turn-2' },
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps the optimistic chat until a terminal success is visible in the canonical Workspace', async () => {
|
||||
const source = await loadedStore();
|
||||
const message = '画一只在月球踢球的熊猫';
|
||||
|
||||
Reference in New Issue
Block a user