diff --git a/packages/editor-ui/src/composables/useExecutionHelpers.test.ts b/packages/editor-ui/src/composables/useExecutionHelpers.test.ts index 465abeb173..fc33853588 100644 --- a/packages/editor-ui/src/composables/useExecutionHelpers.test.ts +++ b/packages/editor-ui/src/composables/useExecutionHelpers.test.ts @@ -3,6 +3,17 @@ import type { ExecutionSummary } from 'n8n-workflow'; import { i18n } from '@/plugins/i18n'; import { convertToDisplayDate } from '@/utils/formatters/dateFormatter'; +const { resolve } = vi.hoisted(() => ({ + resolve: vi.fn(), +})); + +vi.mock('vue-router', () => ({ + useRouter: () => ({ + resolve, + }), + RouterLink: vi.fn(), +})); + describe('useExecutionHelpers()', () => { describe('getUIDetails()', () => { it.each([ @@ -68,4 +79,18 @@ describe('useExecutionHelpers()', () => { ).toEqual(false); }); }); + + describe('openExecutionInNewTab', () => { + const executionId = '123'; + const workflowId = 'xyz'; + const href = 'test.com'; + global.window.open = vi.fn(); + + it('opens execution in new tab', () => { + const { openExecutionInNewTab } = useExecutionHelpers(); + resolve.mockReturnValue({ href }); + openExecutionInNewTab(executionId, workflowId); + expect(window.open).toHaveBeenCalledWith(href, '_blank'); + }); + }); });