Skip to content

Commit 5b6c58a

Browse files
committed
3923 client - Add tests
1 parent fd5baf1 commit 5b6c58a

File tree

5 files changed

+598
-0
lines changed

5 files changed

+598
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import {describe, expect, it} from 'vitest';
2+
3+
import {WorkflowExecutionKeys} from '../workflowExecutions.queries';
4+
5+
describe('workflowExecutions.queries (embedded)', () => {
6+
describe('WorkflowExecutionKeys', () => {
7+
it('generates correct base key for workflow executions', () => {
8+
expect(WorkflowExecutionKeys.workflowExecutions).toEqual(['integrationWorkflowExecutions']);
9+
});
10+
11+
it('generates correct key for workflow execution by id', () => {
12+
const result = WorkflowExecutionKeys.workflowExecution(123);
13+
14+
expect(result).toEqual(['integrationWorkflowExecutions', 123]);
15+
});
16+
17+
it('generates correct key for filtered workflow executions', () => {
18+
const request = {
19+
integrationId: 1,
20+
pageNumber: 0,
21+
pageSize: 10,
22+
};
23+
24+
const result = WorkflowExecutionKeys.filteredWorkflowExecutions(request);
25+
26+
expect(result).toEqual(['integrationWorkflowExecutions', request]);
27+
});
28+
29+
it('generates unique keys for different workflow execution ids', () => {
30+
const key1 = WorkflowExecutionKeys.workflowExecution(1);
31+
const key2 = WorkflowExecutionKeys.workflowExecution(2);
32+
33+
expect(key1).not.toEqual(key2);
34+
expect(key1).toEqual(['integrationWorkflowExecutions', 1]);
35+
expect(key2).toEqual(['integrationWorkflowExecutions', 2]);
36+
});
37+
38+
it('generates unique keys for different filter requests', () => {
39+
const request1 = {integrationId: 1, pageNumber: 0};
40+
const request2 = {integrationId: 2, pageNumber: 0};
41+
42+
const key1 = WorkflowExecutionKeys.filteredWorkflowExecutions(request1);
43+
const key2 = WorkflowExecutionKeys.filteredWorkflowExecutions(request2);
44+
45+
expect(key1).not.toEqual(key2);
46+
});
47+
48+
it('workflow execution key includes base workflow executions key', () => {
49+
const executionKey = WorkflowExecutionKeys.workflowExecution(123);
50+
51+
expect(executionKey[0]).toBe(WorkflowExecutionKeys.workflowExecutions[0]);
52+
});
53+
54+
it('filtered workflow executions key includes base workflow executions key', () => {
55+
const filteredKey = WorkflowExecutionKeys.filteredWorkflowExecutions({pageNumber: 0});
56+
57+
expect(filteredKey[0]).toBe(WorkflowExecutionKeys.workflowExecutions[0]);
58+
});
59+
});
60+
});
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import {TaskExecution} from '@/shared/middleware/platform/workflow/execution';
2+
import {render, screen} from '@/shared/util/test-utils';
3+
import {describe, expect, it} from 'vitest';
4+
5+
import WorkflowTaskExecutionItem from '../WorkflowTaskExecutionItem';
6+
7+
function createTaskExecution(overrides: Partial<TaskExecution> = {}): TaskExecution {
8+
return {
9+
priority: 1,
10+
startDate: new Date('2024-01-01T10:00:00'),
11+
status: 'COMPLETED',
12+
title: 'Test Task',
13+
workflowTask: {
14+
label: 'Test Task Label',
15+
name: 'testTask',
16+
type: 'test/v1/testAction',
17+
},
18+
...overrides,
19+
} as TaskExecution;
20+
}
21+
22+
describe('WorkflowTaskExecutionItem', () => {
23+
describe('status icon integration', () => {
24+
it('should render status icon from utility for completed task', () => {
25+
const taskExecution = createTaskExecution({
26+
endDate: new Date('2024-01-01T10:00:05'),
27+
status: 'COMPLETED',
28+
});
29+
30+
const {container} = render(<WorkflowTaskExecutionItem taskExecution={taskExecution} />);
31+
32+
expect(container.querySelector('.text-success')).toBeInTheDocument();
33+
});
34+
35+
it('should render status icon from utility for started task', () => {
36+
const taskExecution = createTaskExecution({
37+
endDate: undefined,
38+
status: 'STARTED',
39+
});
40+
41+
const {container} = render(<WorkflowTaskExecutionItem taskExecution={taskExecution} />);
42+
43+
expect(container.querySelector('.animate-spin.text-primary')).toBeInTheDocument();
44+
});
45+
46+
it('should render status icon from utility for failed task', () => {
47+
const taskExecution = createTaskExecution({
48+
endDate: new Date('2024-01-01T10:00:05'),
49+
status: 'FAILED',
50+
});
51+
52+
const {container} = render(<WorkflowTaskExecutionItem taskExecution={taskExecution} />);
53+
54+
expect(container.querySelector('.text-destructive')).toBeInTheDocument();
55+
});
56+
});
57+
58+
describe('task details display', () => {
59+
it('should display task label from workflowTask', () => {
60+
const taskExecution = createTaskExecution({
61+
title: 'Fallback Title',
62+
workflowTask: {
63+
label: 'Task Label',
64+
name: 'taskName',
65+
type: 'test/v1/action',
66+
},
67+
});
68+
69+
render(<WorkflowTaskExecutionItem taskExecution={taskExecution} />);
70+
71+
expect(screen.getByText('Task Label')).toBeInTheDocument();
72+
});
73+
74+
it('should display title when workflowTask label is not available', () => {
75+
const taskExecution = createTaskExecution({
76+
title: 'Fallback Title',
77+
workflowTask: {
78+
name: 'taskName',
79+
type: 'test/v1/action',
80+
},
81+
});
82+
83+
render(<WorkflowTaskExecutionItem taskExecution={taskExecution} />);
84+
85+
expect(screen.getByText('Fallback Title')).toBeInTheDocument();
86+
});
87+
88+
it('should display duration when start and end dates are provided', () => {
89+
const taskExecution = createTaskExecution({
90+
endDate: new Date('2024-01-01T10:00:05'),
91+
startDate: new Date('2024-01-01T10:00:00'),
92+
status: 'COMPLETED',
93+
});
94+
95+
render(<WorkflowTaskExecutionItem taskExecution={taskExecution} />);
96+
97+
expect(screen.getByText('5000ms')).toBeInTheDocument();
98+
});
99+
100+
it('should display 0ms when end date is not available', () => {
101+
const taskExecution = createTaskExecution({
102+
endDate: undefined,
103+
startDate: new Date('2024-01-01T10:00:00'),
104+
status: 'STARTED',
105+
});
106+
107+
render(<WorkflowTaskExecutionItem taskExecution={taskExecution} />);
108+
109+
expect(screen.getByText('0ms')).toBeInTheDocument();
110+
});
111+
});
112+
});
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import {TriggerExecution} from '@/shared/middleware/automation/workflow/execution';
2+
import {render, screen} from '@/shared/util/test-utils';
3+
import {describe, expect, it} from 'vitest';
4+
5+
import WorkflowTriggerExecutionItem from '../WorkflowTriggerExecutionItem';
6+
7+
function createTriggerExecution(overrides: Partial<TriggerExecution> = {}): TriggerExecution {
8+
return {
9+
priority: 1,
10+
startDate: new Date('2024-01-01T10:00:00'),
11+
status: 'COMPLETED',
12+
title: 'Test Trigger',
13+
workflowTrigger: {
14+
label: 'Test Trigger Label',
15+
name: 'testTrigger',
16+
type: 'test/v1/testTrigger',
17+
},
18+
...overrides,
19+
} as TriggerExecution;
20+
}
21+
22+
describe('WorkflowTriggerExecutionItem', () => {
23+
describe('status icon integration', () => {
24+
it('should render status icon from utility for completed trigger', () => {
25+
const triggerExecution = createTriggerExecution({
26+
endDate: new Date('2024-01-01T10:00:05'),
27+
status: 'COMPLETED',
28+
});
29+
30+
const {container} = render(<WorkflowTriggerExecutionItem triggerExecution={triggerExecution} />);
31+
32+
expect(container.querySelector('.text-success')).toBeInTheDocument();
33+
});
34+
35+
it('should render status icon from utility for started trigger', () => {
36+
const triggerExecution = createTriggerExecution({
37+
endDate: undefined,
38+
status: 'STARTED',
39+
});
40+
41+
const {container} = render(<WorkflowTriggerExecutionItem triggerExecution={triggerExecution} />);
42+
43+
expect(container.querySelector('.animate-spin.text-primary')).toBeInTheDocument();
44+
});
45+
46+
it('should render status icon from utility for failed trigger', () => {
47+
const triggerExecution = createTriggerExecution({
48+
endDate: new Date('2024-01-01T10:00:05'),
49+
status: 'FAILED',
50+
});
51+
52+
const {container} = render(<WorkflowTriggerExecutionItem triggerExecution={triggerExecution} />);
53+
54+
expect(container.querySelector('.text-destructive')).toBeInTheDocument();
55+
});
56+
});
57+
58+
describe('trigger details display', () => {
59+
it('should display trigger label from workflowTrigger', () => {
60+
const triggerExecution = createTriggerExecution({
61+
title: 'Fallback Title',
62+
workflowTrigger: {
63+
label: 'Trigger Label',
64+
name: 'triggerName',
65+
type: 'test/v1/trigger',
66+
},
67+
});
68+
69+
render(<WorkflowTriggerExecutionItem triggerExecution={triggerExecution} />);
70+
71+
expect(screen.getByText('Trigger Label')).toBeInTheDocument();
72+
});
73+
74+
it('should display title when workflowTrigger label is not available', () => {
75+
const triggerExecution = createTriggerExecution({
76+
title: 'Fallback Title',
77+
workflowTrigger: {
78+
name: 'triggerName',
79+
type: 'test/v1/trigger',
80+
},
81+
});
82+
83+
render(<WorkflowTriggerExecutionItem triggerExecution={triggerExecution} />);
84+
85+
expect(screen.getByText('Fallback Title')).toBeInTheDocument();
86+
});
87+
88+
it('should display duration when start and end dates are provided', () => {
89+
const triggerExecution = createTriggerExecution({
90+
endDate: new Date('2024-01-01T10:00:05'),
91+
startDate: new Date('2024-01-01T10:00:00'),
92+
status: 'COMPLETED',
93+
});
94+
95+
render(<WorkflowTriggerExecutionItem triggerExecution={triggerExecution} />);
96+
97+
expect(screen.getByText('5000ms')).toBeInTheDocument();
98+
});
99+
100+
it('should display 0ms when end date is not available', () => {
101+
const triggerExecution = createTriggerExecution({
102+
endDate: undefined,
103+
startDate: new Date('2024-01-01T10:00:00'),
104+
status: 'STARTED',
105+
});
106+
107+
render(<WorkflowTriggerExecutionItem triggerExecution={triggerExecution} />);
108+
109+
expect(screen.getByText('0ms')).toBeInTheDocument();
110+
});
111+
});
112+
});

0 commit comments

Comments
 (0)