fix(captain): use display IDs for FAQ source links

This commit is contained in:
aakashb95
2026-07-22 23:35:22 +05:30
parent 63d765b14b
commit 2ec33da5cd
3 changed files with 44 additions and 4 deletions
@@ -1,8 +1,9 @@
import { flushPromises, shallowMount } from '@vue/test-utils';
import FaqSuggestionReviewDialog from './FaqSuggestionReviewDialog.vue';
const { dispatch, uiFlags } = vi.hoisted(() => ({
const { dispatch, push, uiFlags } = vi.hoisted(() => ({
dispatch: vi.fn(),
push: vi.fn(),
uiFlags: {
value: {
fetchingItem: false,
@@ -24,10 +25,11 @@ vi.mock('vue-i18n', () => ({
}));
vi.mock('vue-router', () => ({
useRouter: () => ({ push: vi.fn() }),
useRouter: () => ({ push }),
}));
const DialogStub = {
methods: { close: vi.fn() },
template: `
<div>
<slot name="description" />
@@ -71,4 +73,42 @@ describe('FaqSuggestionReviewDialog', () => {
'CAPTAIN.FAQ_SUGGESTIONS.DETAILS.NO_SOURCES'
);
});
it('opens source conversations using their display ID', async () => {
dispatch.mockResolvedValueOnce({
observations: [
{
id: 1,
generated_question: 'How do I enable the feature?',
created_at: 1,
conversation: { id: 99, display_id: 42 },
},
],
});
const wrapper = shallowMount(FaqSuggestionReviewDialog, {
props: {
suggestion: {
id: 1,
question: 'How do I enable the feature?',
answer: 'Turn it on in settings.',
source_count: 1,
assistant: { name: 'Support assistant' },
language: 'en',
},
},
global: {
mocks: { $t: key => key },
stubs: { Dialog: DialogStub },
},
});
await flushPromises();
await wrapper.get('section button').trigger('click');
expect(push).toHaveBeenCalledWith({
name: 'inbox_conversation',
params: { conversation_id: 42 },
});
});
});
@@ -220,7 +220,7 @@ defineExpose({ dialogRef });
:key="observation.id"
type="button"
class="flex w-full flex-col gap-1.5 rounded-lg border border-n-weak bg-n-solid-2 p-3 text-start transition-colors hover:border-n-brand"
@click="openConversation(observation.conversation.id)"
@click="openConversation(observation.conversation.display_id)"
>
<span class="flex items-center justify-between gap-2">
<span class="text-xs font-medium text-n-blue-11">