From 02b393934f7e45a99ff5ccfc3bf04c99df79b907 Mon Sep 17 00:00:00 2001 From: Devessier Date: Fri, 23 Aug 2024 16:33:54 +0200 Subject: [PATCH] lint: fix linting issues --- .../__tests__/generateWorkflowDiagram.test.ts | 66 ++++----- .../getWorkflowLastDiagramVersion.test.ts | 138 +++++++++--------- 2 files changed, 101 insertions(+), 103 deletions(-) diff --git a/packages/twenty-front/src/modules/workflow/utils/__tests__/generateWorkflowDiagram.test.ts b/packages/twenty-front/src/modules/workflow/utils/__tests__/generateWorkflowDiagram.test.ts index 6ed8d7eae6df..0716aa29bb83 100644 --- a/packages/twenty-front/src/modules/workflow/utils/__tests__/generateWorkflowDiagram.test.ts +++ b/packages/twenty-front/src/modules/workflow/utils/__tests__/generateWorkflowDiagram.test.ts @@ -19,9 +19,9 @@ describe('generateWorkflowDiagram', () => { expect(result.nodes[0]).toMatchObject({ data: { label: trigger.settings.eventName, - nodeType: "trigger" + nodeType: 'trigger', }, - }) + }); }); it('should generate a diagram with nodes and edges corresponding to the steps', () => { @@ -32,30 +32,30 @@ describe('generateWorkflowDiagram', () => { }, }; const steps: WorkflowStep[] = [ - { - id: 'step1', - name: 'Step 1', - type: 'CODE_ACTION', - valid: true, + { + id: 'step1', + name: 'Step 1', + type: 'CODE_ACTION', + valid: true, settings: { errorHandlingOptions: { retryOnFailure: { value: true }, - continueOnFailure: { value: false } + continueOnFailure: { value: false }, }, - serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997' + serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997', }, }, - { - id: 'step2', - name: 'Step 2', - type: 'CODE_ACTION', - valid: true, + { + id: 'step2', + name: 'Step 2', + type: 'CODE_ACTION', + valid: true, settings: { errorHandlingOptions: { retryOnFailure: { value: true }, - continueOnFailure: { value: false } + continueOnFailure: { value: false }, }, - serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997' + serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997', }, }, ]; @@ -65,12 +65,12 @@ describe('generateWorkflowDiagram', () => { expect(result.nodes).toHaveLength(steps.length + 1); // All steps + trigger expect(result.edges).toHaveLength(steps.length - 1 + 1); // Edges are one less than nodes + the edge from the trigger to the first node - expect(result.nodes[0].data.nodeType).toBe("trigger") + expect(result.nodes[0].data.nodeType).toBe('trigger'); - const stepNodes = result.nodes.slice(1) + const stepNodes = result.nodes.slice(1); for (const [index, step] of steps.entries()) { - expect(stepNodes[index].data.nodeType).toBe("action"); + expect(stepNodes[index].data.nodeType).toBe('action'); expect(stepNodes[index].data.label).toBe(step.name); } }); @@ -83,30 +83,30 @@ describe('generateWorkflowDiagram', () => { }, }; const steps: WorkflowStep[] = [ - { - id: 'step1', - name: 'Step 1', - type: 'CODE_ACTION', - valid: true, + { + id: 'step1', + name: 'Step 1', + type: 'CODE_ACTION', + valid: true, settings: { errorHandlingOptions: { retryOnFailure: { value: true }, - continueOnFailure: { value: false } + continueOnFailure: { value: false }, }, - serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997' + serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997', }, }, - { - id: 'step2', - name: 'Step 2', - type: 'CODE_ACTION', - valid: true, + { + id: 'step2', + name: 'Step 2', + type: 'CODE_ACTION', + valid: true, settings: { errorHandlingOptions: { retryOnFailure: { value: true }, - continueOnFailure: { value: false } + continueOnFailure: { value: false }, }, - serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997' + serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997', }, }, ]; diff --git a/packages/twenty-front/src/modules/workflow/utils/__tests__/getWorkflowLastDiagramVersion.test.ts b/packages/twenty-front/src/modules/workflow/utils/__tests__/getWorkflowLastDiagramVersion.test.ts index 58cf5787f0c5..20c41c085bb1 100644 --- a/packages/twenty-front/src/modules/workflow/utils/__tests__/getWorkflowLastDiagramVersion.test.ts +++ b/packages/twenty-front/src/modules/workflow/utils/__tests__/getWorkflowLastDiagramVersion.test.ts @@ -2,80 +2,78 @@ import { Workflow } from '@/workflow/types/Workflow'; import { getWorkflowLastDiagramVersion } from '../getWorkflowLastDiagramVersion'; describe('getWorkflowLastDiagramVersion', () => { - it('returns an empty diagram if the provided workflow is undefined', () => { - const result = getWorkflowLastDiagramVersion(undefined); - - expect(result).toEqual({ nodes: [], edges: [] }); - }); - - it('returns an empty diagram if the provided workflow has no versions', () => { - const result = getWorkflowLastDiagramVersion({ - __typename: 'Workflow', - id: 'aa', - name: 'aa', - publishedVersionId: '', - versions: [], - }); - - expect(result).toEqual({ nodes: [], edges: [] }); - }); - - it('returns the diagram for the last version', () => { - const workflow: Workflow = { - __typename: 'Workflow', - id: 'aa', - name: 'aa', - publishedVersionId: '', - versions: [ - { - __typename: 'WorkflowVersion', - createdAt: '', - id: '1', - name: '', - steps: [], - trigger: { - settings: { eventName: 'company.created' }, - type: 'DATABASE_EVENT', - }, - updatedAt: '', - workflowId: '', - }, + it('returns an empty diagram if the provided workflow is undefined', () => { + const result = getWorkflowLastDiagramVersion(undefined); + + expect(result).toEqual({ nodes: [], edges: [] }); + }); + + it('returns an empty diagram if the provided workflow has no versions', () => { + const result = getWorkflowLastDiagramVersion({ + __typename: 'Workflow', + id: 'aa', + name: 'aa', + publishedVersionId: '', + versions: [], + }); + + expect(result).toEqual({ nodes: [], edges: [] }); + }); + + it('returns the diagram for the last version', () => { + const workflow: Workflow = { + __typename: 'Workflow', + id: 'aa', + name: 'aa', + publishedVersionId: '', + versions: [ + { + __typename: 'WorkflowVersion', + createdAt: '', + id: '1', + name: '', + steps: [], + trigger: { + settings: { eventName: 'company.created' }, + type: 'DATABASE_EVENT', + }, + updatedAt: '', + workflowId: '', + }, + { + __typename: 'WorkflowVersion', + createdAt: '', + id: '1', + name: '', + steps: [ { - __typename: 'WorkflowVersion', - createdAt: '', - id: '1', + id: 'step-1', name: '', - steps: [ - { - id: 'step-1', - name: '', - settings: { - errorHandlingOptions: { - retryOnFailure: { value: true }, - continueOnFailure: { value: false }, - }, - serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997', - }, - type: 'CODE_ACTION', - valid: true, + settings: { + errorHandlingOptions: { + retryOnFailure: { value: true }, + continueOnFailure: { value: false }, }, - ], - trigger: { - settings: { eventName: 'company.created' }, - type: 'DATABASE_EVENT', + serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997', }, - updatedAt: '', - workflowId: '', + type: 'CODE_ACTION', + valid: true, }, ], - }; - - const result = getWorkflowLastDiagramVersion(workflow); - - // Corresponds to the trigger + 1 step - expect(result.nodes).toHaveLength(2); - expect(result.edges).toHaveLength(1); - }); - - + trigger: { + settings: { eventName: 'company.created' }, + type: 'DATABASE_EVENT', + }, + updatedAt: '', + workflowId: '', + }, + ], + }; + + const result = getWorkflowLastDiagramVersion(workflow); + + // Corresponds to the trigger + 1 step + expect(result.nodes).toHaveLength(2); + expect(result.edges).toHaveLength(1); + }); });