-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathutils.test.ts
More file actions
77 lines (71 loc) · 1.76 KB
/
Copy pathutils.test.ts
File metadata and controls
77 lines (71 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* @vitest-environment node
*/
import { beforeEach, describe, expect, it } from 'vitest'
import { useVariablesStore } from '@/stores/variables/store'
import { applyWorkflowVariablesToStore } from '@/stores/workflow-diff/utils'
describe('applyWorkflowVariablesToStore', () => {
beforeEach(() => {
useVariablesStore.setState({
variables: {},
isLoading: false,
error: null,
isEditing: null,
})
})
it('hydrates variables for the target workflow and preserves other workflows', () => {
useVariablesStore.setState({
variables: {
old: {
id: 'old',
workflowId: 'workflow-a',
name: 'oldValue',
type: 'plain',
value: 'stale',
},
other: {
id: 'other',
workflowId: 'workflow-b',
name: 'otherValue',
type: 'plain',
value: 'kept',
},
},
})
applyWorkflowVariablesToStore('workflow-a', {
next: {
id: 'next',
name: 'nextValue',
type: 'number',
value: 42,
},
})
expect(useVariablesStore.getState().variables).toEqual({
other: {
id: 'other',
workflowId: 'workflow-b',
name: 'otherValue',
type: 'plain',
value: 'kept',
},
next: {
id: 'next',
workflowId: 'workflow-a',
name: 'nextValue',
type: 'number',
value: 42,
},
})
})
it('preserves null variable values from persisted workflow state', () => {
applyWorkflowVariablesToStore('workflow-a', {
next: {
id: 'next',
name: 'nullableValue',
type: 'object',
value: null,
},
})
expect(useVariablesStore.getState().variables.next.value).toBeNull()
})
})