diff --git a/packages/design-system/src/components/AskAssistantChat/AskAssistantChat.vue b/packages/design-system/src/components/AskAssistantChat/AskAssistantChat.vue index 1acffa82fa..78b4ccbf51 100644 --- a/packages/design-system/src/components/AskAssistantChat/AskAssistantChat.vue +++ b/packages/design-system/src/components/AskAssistantChat/AskAssistantChat.vue @@ -226,6 +226,16 @@ async function onCopyButtonClick(content: string, e: MouseEvent) { data-test-id="chat-message-system" > ⚠️ {{ message.content }} + + {{ t('generic.retry') }} +
{ }); expect(container).toMatchSnapshot(); }); + + it('renders error message correctly with retry button', () => { + const wrapper = render(AskAssistantChat, { + global: { + directives: { + n8nHtml, + }, + stubs, + }, + props: { + user: { firstName: 'Kobi', lastName: 'Dog' }, + messages: [ + { + id: '1', + role: 'assistant', + type: 'error', + content: 'This is an error message.', + read: false, + // Button is not shown without a retry function + retry: async () => {}, + }, + ], + }, + }); + expect(wrapper.container).toMatchSnapshot(); + expect(wrapper.getByTestId('error-retry-button')).toBeInTheDocument(); + }); + + it('does not render retry button if no error is present', () => { + const wrapper = render(AskAssistantChat, { + global: { + directives: { + n8nHtml, + }, + stubs, + }, + props: { + user: { firstName: 'Kobi', lastName: 'Dog' }, + messages: [ + { + id: '1', + type: 'text', + role: 'assistant', + content: + 'Hi Max! Here is my top solution to fix the error in your **Transform data** node👇', + read: false, + }, + ], + }, + }); + + expect(wrapper.container).toMatchSnapshot(); + expect(wrapper.queryByTestId('error-retry-button')).not.toBeInTheDocument(); + }); }); diff --git a/packages/design-system/src/components/AskAssistantChat/__tests__/__snapshots__/AskAssistantChat.spec.ts.snap b/packages/design-system/src/components/AskAssistantChat/__tests__/__snapshots__/AskAssistantChat.spec.ts.snap index 891c10abf6..c26913e405 100644 --- a/packages/design-system/src/components/AskAssistantChat/__tests__/__snapshots__/AskAssistantChat.spec.ts.snap +++ b/packages/design-system/src/components/AskAssistantChat/__tests__/__snapshots__/AskAssistantChat.spec.ts.snap @@ -1,5 +1,179 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html +exports[`AskAssistantChat > does not render retry button if no error is present 1`] = ` +
+
+
+
+
+ + + + + + + + + + + + AI Assistant + +
+
+ beta +
+
+
+ +
+
+
+
+ +
+
+
+ + + + + + + + + + +
+ + Assistant + +
+
+
+

+ Hi Max! Here is my top solution to fix the error in your + + Transform data + + node👇 +

+ + +
+ + +
+ +
+ +
+ +
+
+