mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-31 08:46:58 +02:00
fix: Show Builder's Ask Admin tooltip just for owner (#20246)
This commit is contained in:
parent
c518574131
commit
c221833414
|
|
@ -6,6 +6,7 @@ interface VueComponentInstance {
|
|||
__vueParentComponent?: {
|
||||
setupState?: {
|
||||
onUserMessage?: (message: string) => Promise<void>;
|
||||
showAskOwnerTooltip?: boolean;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -94,6 +95,7 @@ import { mockedStore } from '@/__tests__/utils';
|
|||
import { STORES } from '@n8n/stores';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import type { INodeUi } from '@/Interface';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
|
||||
vi.mock('@/event-bus', () => ({
|
||||
nodeViewEventBus: {
|
||||
|
|
@ -213,6 +215,32 @@ describe('AskAssistantBuild', () => {
|
|||
expect(builderStore.sendChatMessage).not.toHaveBeenCalled();
|
||||
expect(builderStore.addAssistantMessages).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should show ask owner tooltip when user is not instance owner', () => {
|
||||
const usersStore = mockedStore(useUsersStore);
|
||||
usersStore.isInstanceOwner = false;
|
||||
|
||||
const { container } = renderComponent();
|
||||
|
||||
// Get the component instance
|
||||
const vm = (container.firstElementChild as VueComponentInstance)?.__vueParentComponent;
|
||||
const showAskOwnerTooltip = vm?.setupState?.showAskOwnerTooltip;
|
||||
|
||||
expect(showAskOwnerTooltip).toBe(true);
|
||||
});
|
||||
|
||||
it('should not show ask owner tooltip when user is instance owner', () => {
|
||||
const usersStore = mockedStore(useUsersStore);
|
||||
usersStore.isInstanceOwner = true;
|
||||
|
||||
const { container } = renderComponent();
|
||||
|
||||
// Get the component instance
|
||||
const vm = (container.firstElementChild as VueComponentInstance)?.__vueParentComponent;
|
||||
const showAskOwnerTooltip = vm?.setupState?.showAskOwnerTooltip;
|
||||
|
||||
expect(showAskOwnerTooltip).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('user message handling', () => {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ const showExecuteMessage = computed(() => {
|
|||
});
|
||||
const creditsQuota = computed(() => builderStore.creditsQuota);
|
||||
const creditsRemaining = computed(() => builderStore.creditsRemaining);
|
||||
const showAskOwnerTooltip = computed(() => usersStore.isInstanceOwner);
|
||||
const showAskOwnerTooltip = computed(() => !usersStore.isInstanceOwner);
|
||||
|
||||
async function onUserMessage(content: string) {
|
||||
const isNewWorkflow = workflowsStore.isNewWorkflow;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user