feat: add creative welcome and external works square links

This commit is contained in:
鲨鱼辣椒 committed 2026-09-29 15:37:37 +08:00
1 parent 4199cadd1e
commit f8a7880da3
18 files changed
+428 -41

No files matched your search

+13 -2
View File
@@ -340,7 +340,7 @@ describe('CodingChatPanel first Conversation', () => {
await waitFor(() => expect(codingConversationStore.getState().selectedConversationId).toBe(conversation.id));
fireEvent.keyDown(menu, { key: 'Enter' });
fireEvent.click(await screen.findByRole('menuitem', { name: '归档(任务继续运行)' }));
await screen.findByTestId('coding-conversation-pending');
await screen.findByRole('heading', { name: '今天,你想创造什么?' });
expect(projectApi.create).not.toHaveBeenCalled();
expect(conversationApi.abort).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole('button', { name: '查看归档对话' }));
@@ -434,13 +434,15 @@ describe('CodingChatPanel first Conversation', () => {
expect(onOpenProjectSettings).not.toHaveBeenCalled();
});
it('keeps an empty project editable without creating a conversation until first send', async () => {
it('keeps an empty project and its draft mounted across community visits until first send', async () => {
projectApi.list.mockResolvedValue({ projects: [project], activeProjectId: project.id });
projectApi.config.mockResolvedValue({ project, config });
projectApi.conversations.mockResolvedValue([]);
projectApi.create.mockResolvedValue(conversation);
conversationApi.events.mockResolvedValue(new FakeEventSource() as unknown as EventSource);
const { CodingChatPanel } = await import('@/pages/Chat/CodingChatPanel');
const api = await import('@/lib/api-client');
const external = vi.spyOn(api, 'invokeIpc').mockResolvedValue(undefined);
const { createLocalConversationSnapshot } = await import('@/pages/Chat/coding-chat-snapshot');
conversationApi.snapshot.mockResolvedValue(createLocalConversationSnapshot(project.id, conversation));
render(<CodingChatPanel />);
@@ -448,8 +450,17 @@ describe('CodingChatPanel first Conversation', () => {
expect(projectApi.create).not.toHaveBeenCalled();
expect(conversationApi.snapshot).not.toHaveBeenCalled();
fireEvent.change(textbox, {target:{value:'First prompt'}});
fireEvent.click(screen.getByRole('button', { name: '去作品广场逛逛' }));
await waitFor(() => expect(external).toHaveBeenCalledWith('shell:openExternal', 'https://square.nianxx.cn/#explore'));
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
expect(screen.getByRole('textbox')).toBe(textbox);
expect(textbox).toHaveValue('First prompt');
expect(projectApi.create).not.toHaveBeenCalled();
expect(conversationApi.submit).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole('button',{name:'发送'}));
await waitFor(()=>expect(projectApi.create).toHaveBeenCalledOnce());
await waitFor(() => expect(screen.queryByTestId('community-invitation')).not.toBeInTheDocument());
expect(screen.getByRole('textbox')).toBe(textbox);
});
it('rehydrates a preselected stale Conversation when the programming view mounts', async () => {