mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor(editor): Migrate n8nRootStore to use composition API (no-changelog) (#9770)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useRunWorkflow } from '@/composables/useRunWorkflow';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { setActivePinia } from 'pinia';
|
||||
@@ -10,10 +10,6 @@ import { useRouter } from 'vue-router';
|
||||
import { ExpressionError, type IPinData, type IRunData, type Workflow } from 'n8n-workflow';
|
||||
import type * as router from 'vue-router';
|
||||
|
||||
vi.mock('@/stores/n8nRoot.store', () => ({
|
||||
useRootStore: vi.fn().mockReturnValue({ pushConnectionActive: true }),
|
||||
}));
|
||||
|
||||
vi.mock('@/stores/workflows.store', () => ({
|
||||
useWorkflowsStore: vi.fn().mockReturnValue({
|
||||
runWorkflow: vi.fn(),
|
||||
@@ -95,7 +91,7 @@ describe('useRunWorkflow({ router })', () => {
|
||||
let workflowHelpers: ReturnType<typeof useWorkflowHelpers>;
|
||||
|
||||
beforeAll(() => {
|
||||
const pinia = createTestingPinia();
|
||||
const pinia = createTestingPinia({ stubActions: false });
|
||||
|
||||
setActivePinia(pinia);
|
||||
|
||||
@@ -110,7 +106,8 @@ describe('useRunWorkflow({ router })', () => {
|
||||
describe('runWorkflowApi()', () => {
|
||||
it('should throw an error if push connection is not active', async () => {
|
||||
const { runWorkflowApi } = useRunWorkflow({ router });
|
||||
rootStore.pushConnectionActive = false;
|
||||
|
||||
rootStore.setPushConnectionInactive();
|
||||
|
||||
await expect(runWorkflowApi({} as IStartRunData)).rejects.toThrow(
|
||||
'workflowRun.noActiveConnectionToTheServer',
|
||||
@@ -119,7 +116,8 @@ describe('useRunWorkflow({ router })', () => {
|
||||
|
||||
it('should successfully run a workflow', async () => {
|
||||
const { runWorkflowApi } = useRunWorkflow({ router });
|
||||
rootStore.pushConnectionActive = true;
|
||||
|
||||
rootStore.setPushConnectionActive();
|
||||
|
||||
const mockResponse = { executionId: '123', waitingForWebhook: false };
|
||||
vi.mocked(workflowsStore).runWorkflow.mockResolvedValue(mockResponse);
|
||||
@@ -135,7 +133,7 @@ describe('useRunWorkflow({ router })', () => {
|
||||
it('should handle workflow run failure', async () => {
|
||||
const { runWorkflowApi } = useRunWorkflow({ router });
|
||||
|
||||
rootStore.pushConnectionActive = true;
|
||||
rootStore.setPushConnectionActive();
|
||||
vi.mocked(workflowsStore).runWorkflow.mockRejectedValue(new Error('Failed to run workflow'));
|
||||
|
||||
await expect(runWorkflowApi({} as IStartRunData)).rejects.toThrow('Failed to run workflow');
|
||||
@@ -145,7 +143,7 @@ describe('useRunWorkflow({ router })', () => {
|
||||
it('should set waitingForWebhook if response indicates waiting', async () => {
|
||||
const { runWorkflowApi } = useRunWorkflow({ router });
|
||||
|
||||
rootStore.pushConnectionActive = true;
|
||||
rootStore.setPushConnectionActive();
|
||||
const mockResponse = { executionId: '123', waitingForWebhook: true };
|
||||
vi.mocked(workflowsStore).runWorkflow.mockResolvedValue(mockResponse);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user