feat: use new service

This commit is contained in:
Shivam Mishra
2025-12-17 16:57:32 +05:30
parent ffc621b6e6
commit 2f81fcee8c
3 changed files with 5 additions and 103 deletions
@@ -5,12 +5,12 @@ import {
useMapGetter,
} from 'dashboard/composables/store';
import { useI18n } from 'vue-i18n';
import OpenAPI from 'dashboard/api/integrations/openapi';
import EditorAPI from 'dashboard/api/captain/editor';
import analyticsHelper from 'dashboard/helper/AnalyticsHelper/index';
vi.mock('dashboard/composables/store');
vi.mock('vue-i18n');
vi.mock('dashboard/api/integrations/openapi');
vi.mock('dashboard/api/captain/editor');
vi.mock('dashboard/helper/AnalyticsHelper/index', async importOriginal => {
const actual = await importOriginal();
actual.default = {
@@ -94,7 +94,7 @@ describe('useAI', () => {
});
it('fetches label suggestions', async () => {
OpenAPI.processEvent.mockResolvedValue({
EditorAPI.processEvent.mockResolvedValue({
data: { message: 'label1, label2' },
});
@@ -111,9 +111,8 @@ describe('useAI', () => {
const { fetchLabelSuggestions } = useAI();
const result = await fetchLabelSuggestions();
expect(OpenAPI.processEvent).toHaveBeenCalledWith({
expect(EditorAPI.processEvent).toHaveBeenCalledWith({
type: 'label_suggestion',
hookId: 'hook1',
conversationId: '123',
});
@@ -7,7 +7,6 @@ import {
import { useAlert, useTrack } from 'dashboard/composables';
import { useI18n } from 'vue-i18n';
import { OPEN_AI_EVENTS } from 'dashboard/helper/AnalyticsHelper/events';
import OpenAPI from 'dashboard/api/integrations/openapi';
import EditorAPI from 'dashboard/api/captain/editor';
/**
@@ -78,12 +77,6 @@ export function useAI() {
*/
const isFetchingAppIntegrations = computed(() => uiFlags.value.isFetching);
/**
* Computed property for the hook ID.
* @type {import('vue').ComputedRef<string|undefined>}
*/
const hookId = computed(() => aiIntegration.value?.id);
/**
* Computed property for the conversation ID.
* @type {import('vue').ComputedRef<string|undefined>}
@@ -140,9 +133,8 @@ export function useAI() {
if (!conversationId.value) return [];
try {
const result = await OpenAPI.processEvent({
const result = await EditorAPI.processEvent({
type: 'label_suggestion',
hookId: hookId.value,
conversationId: conversationId.value,
});