fix(editor): Prevent setting sticky node as active node on new canvas (no-changelog) (#11141)

This commit is contained in:
Alex Grozav 2024-10-07 16:12:23 +03:00 committed by GitHub
parent 9539504eaf
commit 0321582c11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 4 deletions

View file

@ -22,7 +22,7 @@ import { useCredentialsStore } from '@/stores/credentials.store';
import { waitFor } from '@testing-library/vue';
import { createTestingPinia } from '@pinia/testing';
import { mockedStore } from '@/__tests__/utils';
import { SET_NODE_TYPE, STORES } from '@/constants';
import { SET_NODE_TYPE, STICKY_NODE_TYPE, STORES } from '@/constants';
import type { Connection } from '@vue-flow/core';
import { useClipboard } from '@/composables/useClipboard';
@ -252,6 +252,24 @@ describe('useCanvasOperations', () => {
await waitFor(() => expect(ndvStore.setActiveNodeName).toHaveBeenCalledWith('Test Name'));
});
it('should not set sticky node type as active node', async () => {
const ndvStore = useNDVStore();
const nodeTypeDescription = mockNodeTypeDescription({ name: STICKY_NODE_TYPE });
const { addNode } = useCanvasOperations({ router });
addNode(
{
type: STICKY_NODE_TYPE,
typeVersion: 1,
name: 'Test Name',
},
nodeTypeDescription,
{ openNDV: true },
);
await waitFor(() => expect(ndvStore.setActiveNodeName).not.toHaveBeenCalled());
});
});
describe('resolveNodePosition', () => {

View file

@ -610,10 +610,10 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
if (nodeData.type !== STICKY_NODE_TYPE) {
void externalHooks.run('nodeView.addNodeButton', { nodeTypeName: nodeData.type });
}
if (options.openNDV && !preventOpeningNDV) {
ndvStore.setActiveNodeName(nodeData.name);
if (options.openNDV && !preventOpeningNDV) {
ndvStore.setActiveNodeName(nodeData.name);
}
}
});