feat(editor): Remove AI Error Debugging (#9337)
This commit is contained in:
committed by
GitHub
parent
f64a41d617
commit
cda062bde6
@@ -1,77 +0,0 @@
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import { useAIStore } from '@/stores/ai.store';
|
||||
import * as aiApi from '@/api/ai';
|
||||
|
||||
vi.mock('@/api/ai', () => ({
|
||||
debugError: vi.fn(),
|
||||
generateCurl: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/stores/n8nRoot.store', () => ({
|
||||
useRootStore: () => ({
|
||||
getRestApiContext: {
|
||||
/* Mocked context */
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@/stores/settings.store', () => ({
|
||||
useSettingsStore: () => ({
|
||||
settings: {
|
||||
ai: {
|
||||
features: {
|
||||
errorDebugging: false,
|
||||
generateCurl: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
describe('useAIStore', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia());
|
||||
});
|
||||
|
||||
describe('isErrorDebuggingEnabled', () => {
|
||||
it('reflects error debugging setting from settingsStore', () => {
|
||||
const aiStore = useAIStore();
|
||||
expect(aiStore.isErrorDebuggingEnabled).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('debugError()', () => {
|
||||
it('calls aiApi.debugError with correct parameters and returns expected result', async () => {
|
||||
const mockResult = { message: 'This is an example' };
|
||||
const aiStore = useAIStore();
|
||||
const payload = {
|
||||
error: new Error('Test error'),
|
||||
};
|
||||
|
||||
vi.mocked(aiApi.debugError).mockResolvedValue(mockResult);
|
||||
|
||||
const result = await aiStore.debugError(payload);
|
||||
|
||||
expect(aiApi.debugError).toHaveBeenCalledWith({}, payload);
|
||||
expect(result).toEqual(mockResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe('debugError()', () => {
|
||||
it('calls aiApi.debugError with correct parameters and returns expected result', async () => {
|
||||
const mockResult = { curl: 'curl -X GET https://n8n.io', metadata: {} };
|
||||
const aiStore = useAIStore();
|
||||
const payload = {
|
||||
service: 'OpenAI',
|
||||
request: 'Create user message saying "Hello World"',
|
||||
};
|
||||
|
||||
vi.mocked(aiApi.generateCurl).mockResolvedValue(mockResult);
|
||||
|
||||
const result = await aiStore.generateCurl(payload);
|
||||
|
||||
expect(aiApi.generateCurl).toHaveBeenCalledWith({}, payload);
|
||||
expect(result).toEqual(mockResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import * as aiApi from '@/api/ai';
|
||||
import type { DebugErrorPayload, GenerateCurlPayload } from '@/api/ai';
|
||||
import type { GenerateCurlPayload } from '@/api/ai';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
@@ -35,7 +35,6 @@ export const useAIStore = defineStore('ai', () => {
|
||||
position: [0, 0] as XYPosition,
|
||||
});
|
||||
const latestConnectionInfo: Ref<AIAssistantConnectionInfo | null> = ref(null);
|
||||
const isErrorDebuggingEnabled = computed(() => settingsStore.settings.ai.features.errorDebugging);
|
||||
const isGenerateCurlEnabled = computed(() => settingsStore.settings.ai.features.generateCurl);
|
||||
const isAssistantExperimentEnabled = computed(
|
||||
() => posthogStore.getVariant(AI_ASSISTANT_EXPERIMENT.name) === AI_ASSISTANT_EXPERIMENT.variant,
|
||||
@@ -51,17 +50,11 @@ export const useAIStore = defineStore('ai', () => {
|
||||
nextStepPopupConfig.open = false;
|
||||
}
|
||||
|
||||
async function debugError(payload: DebugErrorPayload) {
|
||||
return await aiApi.debugError(rootStore.getRestApiContext, payload);
|
||||
}
|
||||
|
||||
async function generateCurl(payload: GenerateCurlPayload) {
|
||||
return await aiApi.generateCurl(rootStore.getRestApiContext, payload);
|
||||
}
|
||||
|
||||
return {
|
||||
isErrorDebuggingEnabled,
|
||||
debugError,
|
||||
assistantChatOpen,
|
||||
nextStepPopupConfig,
|
||||
openNextStepPopup,
|
||||
|
||||
Reference in New Issue
Block a user