Skip to content

Commit f4799bd

Browse files
authored
Release v1.46.0 (#1106)
* feat: for-each BETA * chore: convert import to js for plumber admin
2 parents fb963f4 + d1908b8 commit f4799bd

File tree

127 files changed

+8650
-513
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+8650
-513
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,5 @@
106106
"tsconfig-paths": "^4.2.0",
107107
"type-fest": "4.10.3"
108108
},
109-
"version": "1.45.3"
109+
"version": "1.46.0"
110110
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import { IExecutionStep } from '@plumber/types'
2+
3+
import { describe, expect, it, vi } from 'vitest'
4+
5+
import { FOR_EACH_INPUT_SOURCE } from '@/apps/toolbox/common/constants'
6+
7+
import getDataOutMetadata from '../../actions/get-table-rows/get-data-out-metadata'
8+
9+
const DEFAULT_SUCCESS_EXECUTION_STEP = {
10+
dataOut: {
11+
rowsFound: 2,
12+
data: {
13+
rows: [
14+
{
15+
data: {
16+
'436f6c756d6e31': 'value1',
17+
'436f6c756d6e32': 'value2',
18+
},
19+
},
20+
{
21+
data: {
22+
'436f6c756d6e31': 'value3',
23+
'436f6c756d6e32': 'value4',
24+
},
25+
},
26+
],
27+
columns: [
28+
{
29+
id: '436f6c756d6e31',
30+
name: 'Column1',
31+
value: `data.rows.*.${Buffer.from('Column1').toString('hex')}`,
32+
},
33+
{
34+
id: '436f6c756d6e32',
35+
name: 'Column2',
36+
value: `data.rows.*.${Buffer.from('Column2').toString('hex')}`,
37+
},
38+
],
39+
inputSource: FOR_EACH_INPUT_SOURCE.M365_EXCEL,
40+
},
41+
},
42+
} as unknown as IExecutionStep
43+
44+
describe('getTableRows getDataOutMetadata', () => {
45+
it('should return null if no dataOut is provided', async () => {
46+
const executionStep = { dataOut: null } as unknown as IExecutionStep
47+
const result = await getDataOutMetadata(executionStep)
48+
expect(result).toBeNull()
49+
})
50+
51+
it('should return metadata for 0 rows found', async () => {
52+
const executionStep = {
53+
dataOut: {
54+
rowsFound: 0,
55+
data: {
56+
rows: [],
57+
columns: [
58+
{
59+
id: '436f6c756d6e31',
60+
name: 'Column1',
61+
value: `data.rows.*.${Buffer.from('Column1').toString('hex')}`,
62+
},
63+
],
64+
inputSource: FOR_EACH_INPUT_SOURCE.M365_EXCEL,
65+
},
66+
},
67+
} as unknown as IExecutionStep
68+
const result = await getDataOutMetadata(executionStep)
69+
70+
expect(result).toEqual({
71+
rowsFound: {
72+
label: 'Number of rows found',
73+
order: 2,
74+
},
75+
data: {
76+
label: 'Row(s) found',
77+
displayedValue: 'Preview 0 row(s)',
78+
order: 1,
79+
type: 'table',
80+
},
81+
})
82+
})
83+
84+
it('should return metadata for foundRows: true with row data', async () => {
85+
const result = await getDataOutMetadata(DEFAULT_SUCCESS_EXECUTION_STEP)
86+
87+
expect(result).toEqual({
88+
rowsFound: {
89+
label: 'Number of rows found',
90+
order: 2,
91+
},
92+
data: {
93+
label: 'Row(s) found',
94+
displayedValue: 'Preview 2 row(s)',
95+
order: 1,
96+
type: 'table',
97+
},
98+
})
99+
})
100+
101+
it('should handle missing columns in dataOut', async () => {
102+
const executionStep = {
103+
dataOut: {
104+
rowsFound: 0,
105+
data: {
106+
rows: [],
107+
// columns is missing
108+
},
109+
},
110+
} as unknown as IExecutionStep
111+
112+
await expect(getDataOutMetadata(executionStep)).rejects.toThrow()
113+
})
114+
115+
it('should handle invalid dataOut format gracefully', async () => {
116+
// This test verifies that the function doesn't throw when dataOut doesn't match the schema
117+
// In a real scenario, the zod schema would throw, but we're testing the error handling
118+
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(vi.fn())
119+
120+
const executionStep = {
121+
dataOut: {
122+
// Missing the required rowsFound field
123+
someOtherField: true,
124+
},
125+
} as unknown as IExecutionStep
126+
127+
// The function should throw when parsing invalid dataOut
128+
await expect(getDataOutMetadata(executionStep)).rejects.toThrow()
129+
130+
consoleSpy.mockRestore()
131+
})
132+
})

0 commit comments

Comments
 (0)