refactor(editor): Migrate workflows store to setup function with composition API (no-changelog) (#9270)

This commit is contained in:
Alex Grozav
2024-05-08 14:35:29 +03:00
committed by GitHub
parent 6b6e8dfc33
commit f64a41d617
9 changed files with 2002 additions and 1543 deletions

View File

@@ -1,9 +1,8 @@
import type { INodeUi } from '@/Interface';
import { useContextMenu } from '@/composables/useContextMenu';
import { BASIC_CHAIN_NODE_TYPE, NO_OP_NODE_TYPE, STICKY_NODE_TYPE, STORES } from '@/constants';
import { BASIC_CHAIN_NODE_TYPE, NO_OP_NODE_TYPE, STICKY_NODE_TYPE } from '@/constants';
import { faker } from '@faker-js/faker';
import { createTestingPinia } from '@pinia/testing';
import { setActivePinia } from 'pinia';
import { createPinia, setActivePinia } from 'pinia';
import { useSourceControlStore } from '@/stores/sourceControl.store';
import { useUIStore } from '@/stores/ui.store';
import { useWorkflowsStore } from '@/stores/workflows.store';
@@ -27,21 +26,18 @@ describe('useContextMenu', () => {
const selectedNodes = nodes.slice(0, 2);
beforeAll(() => {
setActivePinia(
createTestingPinia({
initialState: {
[STORES.UI]: { selectedNodes },
[STORES.WORKFLOWS]: { workflow: { nodes } },
},
}),
);
setActivePinia(createPinia());
sourceControlStore = useSourceControlStore();
uiStore = useUIStore();
workflowsStore = useWorkflowsStore();
vi.spyOn(uiStore, 'isReadOnlyView', 'get').mockReturnValue(false);
vi.spyOn(sourceControlStore, 'preferences', 'get').mockReturnValue({
branchReadOnly: false,
} as never);
uiStore = useUIStore();
uiStore.selectedNodes = selectedNodes;
vi.spyOn(uiStore, 'isReadOnlyView', 'get').mockReturnValue(false);
workflowsStore = useWorkflowsStore();
workflowsStore.workflow.nodes = nodes;
vi.spyOn(workflowsStore, 'getCurrentWorkflow').mockReturnValue({
nodes,
getNode: (_: string) => {