mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix: Enable Assistant on other credential views (#10931)
This commit is contained in:
parent
eae4e30aee
commit
557db9c170
|
@ -13,7 +13,7 @@ import { useSettingsStore } from '@/stores/settings.store';
|
|||
import { defaultSettings } from '../../__tests__/defaults';
|
||||
import { merge } from 'lodash-es';
|
||||
import { DEFAULT_POSTHOG_SETTINGS } from './posthog.test';
|
||||
import { AI_ASSISTANT_EXPERIMENT } from '@/constants';
|
||||
import { AI_ASSISTANT_EXPERIMENT, VIEWS } from '@/constants';
|
||||
import { reactive } from 'vue';
|
||||
import * as chatAPI from '@/api/assistant';
|
||||
import * as telemetryModule from '@/composables/useTelemetry';
|
||||
|
@ -41,12 +41,13 @@ const setAssistantEnabled = (enabled: boolean) => {
|
|||
);
|
||||
};
|
||||
|
||||
let currentRouteName = ENABLED_VIEWS[0];
|
||||
vi.mock('vue-router', () => ({
|
||||
useRoute: vi.fn(() =>
|
||||
reactive({
|
||||
path: '/',
|
||||
params: {},
|
||||
name: ENABLED_VIEWS[0],
|
||||
name: currentRouteName,
|
||||
}),
|
||||
),
|
||||
useRouter: vi.fn(),
|
||||
|
@ -309,6 +310,30 @@ describe('AI Assistant store', () => {
|
|||
expect(assistantStore.canShowAssistantButtonsOnCanvas).toBe(true);
|
||||
});
|
||||
|
||||
it('should not show assistant if on a settings page', () => {
|
||||
currentRouteName = VIEWS.SSO_SETTINGS;
|
||||
const assistantStore = useAssistantStore();
|
||||
|
||||
setAssistantEnabled(true);
|
||||
mockPostHogVariant('variant');
|
||||
expect(assistantStore.isAssistantEnabled).toBe(true);
|
||||
expect(assistantStore.canShowAssistant).toBe(false);
|
||||
expect(assistantStore.canShowAssistantButtonsOnCanvas).toBe(false);
|
||||
});
|
||||
|
||||
[VIEWS.PROJECTS_CREDENTIALS, VIEWS.TEMPLATE_SETUP, VIEWS.CREDENTIALS].forEach((view) => {
|
||||
it(`should show assistant if on ${view} page`, () => {
|
||||
currentRouteName = VIEWS.PROJECTS_CREDENTIALS;
|
||||
const assistantStore = useAssistantStore();
|
||||
|
||||
setAssistantEnabled(true);
|
||||
mockPostHogVariant('variant');
|
||||
expect(assistantStore.isAssistantEnabled).toBe(true);
|
||||
expect(assistantStore.canShowAssistant).toBe(true);
|
||||
expect(assistantStore.canShowAssistantButtonsOnCanvas).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('should initialize assistant chat session on node error', async () => {
|
||||
const context: ChatRequest.ErrorContext = {
|
||||
error: {
|
||||
|
|
|
@ -46,6 +46,10 @@ export const ENABLED_VIEWS = [
|
|||
VIEWS.EXECUTION_PREVIEW,
|
||||
VIEWS.WORKFLOWS,
|
||||
VIEWS.CREDENTIALS,
|
||||
VIEWS.PROJECTS_CREDENTIALS,
|
||||
VIEWS.PROJECTS_WORKFLOWS,
|
||||
VIEWS.PROJECT_SETTINGS,
|
||||
VIEWS.TEMPLATE_SETUP,
|
||||
];
|
||||
const READABLE_TYPES = ['code-diff', 'text', 'block'];
|
||||
|
||||
|
|
Loading…
Reference in a new issue