Skip to content

Commit

Permalink
lint: fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Devessier committed Aug 23, 2024
1 parent b1b24c1 commit 02b3939
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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',
},
},
];
Expand All @@ -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);
}
});
Expand All @@ -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',
},
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 02b3939

Please sign in to comment.