mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
feat(editor): Support partial executions of tool nodes (#14945)
This commit is contained in:
@@ -4,12 +4,21 @@ import CanvasNodeToolbar from '@/components/canvas/elements/nodes/CanvasNodeTool
|
||||
import { createComponentRenderer } from '@/__tests__/render';
|
||||
import { createCanvasNodeProvide, createCanvasProvide } from '@/__tests__/data';
|
||||
import { CanvasNodeRenderType } from '@/types';
|
||||
import { createPinia, setActivePinia, type Pinia } from 'pinia';
|
||||
|
||||
const renderComponent = createComponentRenderer(CanvasNodeToolbar);
|
||||
|
||||
describe('CanvasNodeToolbar', () => {
|
||||
let pinia: Pinia;
|
||||
|
||||
beforeEach(() => {
|
||||
pinia = createPinia();
|
||||
setActivePinia(pinia);
|
||||
});
|
||||
|
||||
it('should render execute node button when renderType is not configuration', async () => {
|
||||
const { getByTestId } = renderComponent({
|
||||
pinia,
|
||||
global: {
|
||||
provide: {
|
||||
...createCanvasNodeProvide(),
|
||||
@@ -23,6 +32,7 @@ describe('CanvasNodeToolbar', () => {
|
||||
|
||||
it('should render disabled execute node button when canvas is executing', () => {
|
||||
const { getByTestId } = renderComponent({
|
||||
pinia,
|
||||
global: {
|
||||
provide: {
|
||||
...createCanvasNodeProvide(),
|
||||
@@ -38,6 +48,7 @@ describe('CanvasNodeToolbar', () => {
|
||||
|
||||
it('should render disabled execute node button when node is deactivated', async () => {
|
||||
const { getByTestId, getByRole } = renderComponent({
|
||||
pinia,
|
||||
global: {
|
||||
provide: {
|
||||
...createCanvasNodeProvide({
|
||||
@@ -96,6 +107,7 @@ describe('CanvasNodeToolbar', () => {
|
||||
|
||||
it('should emit "toggle" when disable node button is clicked', async () => {
|
||||
const { getByTestId, emitted } = renderComponent({
|
||||
pinia,
|
||||
global: {
|
||||
provide: {
|
||||
...createCanvasNodeProvide(),
|
||||
@@ -111,6 +123,7 @@ describe('CanvasNodeToolbar', () => {
|
||||
|
||||
it('should emit "delete" when delete node button is clicked', async () => {
|
||||
const { getByTestId, emitted } = renderComponent({
|
||||
pinia,
|
||||
global: {
|
||||
provide: {
|
||||
...createCanvasNodeProvide(),
|
||||
@@ -126,6 +139,7 @@ describe('CanvasNodeToolbar', () => {
|
||||
|
||||
it('should emit "open:contextmenu" when overflow node button is clicked', async () => {
|
||||
const { getByTestId, emitted } = renderComponent({
|
||||
pinia,
|
||||
global: {
|
||||
provide: {
|
||||
...createCanvasNodeProvide(),
|
||||
@@ -141,6 +155,7 @@ describe('CanvasNodeToolbar', () => {
|
||||
|
||||
it('should emit "update" when sticky note color is changed', async () => {
|
||||
const { getAllByTestId, getByTestId, emitted } = renderComponent({
|
||||
pinia,
|
||||
global: {
|
||||
provide: {
|
||||
...createCanvasNodeProvide({
|
||||
@@ -164,6 +179,7 @@ describe('CanvasNodeToolbar', () => {
|
||||
|
||||
it('should have "forceVisible" class when hovered', async () => {
|
||||
const { getByTestId } = renderComponent({
|
||||
pinia,
|
||||
global: {
|
||||
provide: {
|
||||
...createCanvasNodeProvide(),
|
||||
@@ -181,6 +197,7 @@ describe('CanvasNodeToolbar', () => {
|
||||
|
||||
it('should have "forceVisible" class when sticky color picker is visible', async () => {
|
||||
const { getByTestId } = renderComponent({
|
||||
pinia,
|
||||
global: {
|
||||
provide: {
|
||||
...createCanvasNodeProvide({
|
||||
|
||||
@@ -4,6 +4,8 @@ import { useI18n } from '@/composables/useI18n';
|
||||
import { useCanvasNode } from '@/composables/useCanvasNode';
|
||||
import { CanvasNodeRenderType } from '@/types';
|
||||
import { useCanvas } from '@/composables/useCanvas';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
|
||||
const emit = defineEmits<{
|
||||
delete: [];
|
||||
@@ -21,7 +23,15 @@ const $style = useCssModule();
|
||||
const i18n = useI18n();
|
||||
|
||||
const { isExecuting } = useCanvas();
|
||||
const { isDisabled, render } = useCanvasNode();
|
||||
const { isDisabled, render, name } = useCanvasNode();
|
||||
|
||||
const workflowsStore = useWorkflowsStore();
|
||||
const nodeTypesStore = useNodeTypesStore();
|
||||
|
||||
const node = computed(() => !!name.value && workflowsStore.getNodeByName(name.value));
|
||||
const isNodesAsToolNode = computed(
|
||||
() => !!node.value && nodeTypesStore.isNodesAsToolNode(node.value.type),
|
||||
);
|
||||
|
||||
const nodeDisabledTitle = computed(() => {
|
||||
return isDisabled.value ? i18n.baseText('node.enable') : i18n.baseText('node.disable');
|
||||
@@ -41,7 +51,7 @@ const isExecuteNodeVisible = computed(() => {
|
||||
!props.readOnly &&
|
||||
render.value.type === CanvasNodeRenderType.Default &&
|
||||
'configuration' in render.value.options &&
|
||||
!render.value.options.configuration
|
||||
(!render.value.options.configuration || isNodesAsToolNode.value)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user