Skip to content

Commit 9e13625

Browse files
committed
PLU-488 [FIND-MULTIPLE-ROWS-5]: Get Excel column values dynamically (#1025)
## TL;DR Refactored to dynamically obtain column values for the `getTableRows` action instead of storing them in the execution step’s `dataOut`, to avoid duplicate data — since the values are already stored in the row data. **Note to reviewers** The modal that displays the list of rows in table format will be updated in a subsequent PR. As of now, the test result can still be verified in the output after testing the step. ## What changed? * Restructured output to align with Tiles multiple row output: * `rows.rowData` to `data.rows` for better semantic clarity\ * Removed unnecessary consolidated column metadata as it is already available within the `data` * Removed unnecessary `tableRowIndex` and `sheetRowNumber` * Added explicit value paths (`data.rows.*.data.<hex-encoded-column-name>`) to column definitions for dynamic data access * Changed the type in metadata from 'array' to 'multiple-row-object' to better represent the data structure ## How to test? Set up the find table rows action and test the following: - [ ] Number of rows returned is correct - [ ] Test result shows the correct number of columns with: - `id`: Tile column id (uuid) - `name`: Tile column name - `value`: step variable-like string in this format `data.rows.*.data.<hex-encoded-column-name>` ## Screenshots ![Screenshot 2025-06-02 at 9.47.25 AM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/Wrwhm8Mmhv1Z2GwlSb7V/03295d11-07dc-47dd-8e91-2f764d210330.png) ![Screenshot 2025-06-02 at 9.47.36 AM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/Wrwhm8Mmhv1Z2GwlSb7V/45d33307-5712-4da2-af52-ee77c789b5b9.png) ![Screenshot 2025-06-02 at 9.47.43 AM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/Wrwhm8Mmhv1Z2GwlSb7V/0b208bd5-5ad4-4359-a67c-e7337acb2c12.png)
1 parent 567ce00 commit 9e13625

File tree

6 files changed

+352
-276
lines changed

6 files changed

+352
-276
lines changed

packages/backend/src/apps/m365-excel/__tests__/actions/get-table-rows-metadata.test.ts

Lines changed: 62 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,40 @@ import { describe, expect, it, vi } from 'vitest'
44

55
import getDataOutMetadata from '../../actions/get-table-rows/get-data-out-metadata'
66

7+
const DEFAULT_SUCCESS_EXECUTION_STEP = {
8+
dataOut: {
9+
rowsFound: 2,
10+
data: {
11+
rows: [
12+
{
13+
data: {
14+
'436f6c756d6e31': 'value1',
15+
'436f6c756d6e32': 'value2',
16+
},
17+
},
18+
{
19+
data: {
20+
'436f6c756d6e31': 'value3',
21+
'436f6c756d6e32': 'value4',
22+
},
23+
},
24+
],
25+
columns: [
26+
{
27+
id: '436f6c756d6e31',
28+
name: 'Column1',
29+
value: `data.rows.*.${Buffer.from('Column1').toString('hex')}`,
30+
},
31+
{
32+
id: '436f6c756d6e32',
33+
name: 'Column2',
34+
value: `data.rows.*.${Buffer.from('Column2').toString('hex')}`,
35+
},
36+
],
37+
},
38+
},
39+
} as unknown as IExecutionStep
40+
741
describe('getTableRows getDataOutMetadata', () => {
842
it('should return null if no dataOut is provided', async () => {
943
const executionStep = { dataOut: null } as unknown as IExecutionStep
@@ -15,120 +49,63 @@ describe('getTableRows getDataOutMetadata', () => {
1549
const executionStep = {
1650
dataOut: {
1751
rowsFound: 0,
52+
data: {
53+
rows: [],
54+
columns: [
55+
{
56+
id: '436f6c756d6e31',
57+
name: 'Column1',
58+
value: `data.rows.*.${Buffer.from('Column1').toString('hex')}`,
59+
},
60+
],
61+
},
1862
},
1963
} as unknown as IExecutionStep
20-
2164
const result = await getDataOutMetadata(executionStep)
2265

2366
expect(result).toEqual({
24-
rows: {
25-
label: 'List of row(s) found',
26-
displayedValue: 'Preview 0 row(s)',
27-
order: 1,
28-
type: 'array',
29-
},
3067
rowsFound: {
3168
label: 'Number of rows found',
3269
order: 2,
3370
},
34-
columns: [],
71+
data: {
72+
label: 'List of row(s) found',
73+
displayedValue: 'Preview 0 row(s)',
74+
order: 1,
75+
type: 'multiple-row-object',
76+
},
3577
})
3678
})
3779

3880
it('should return metadata for foundRows: true with row data', async () => {
39-
const executionStep = {
40-
dataOut: {
41-
rowsFound: 2,
42-
rowData: [
43-
{
44-
tableRowIndex: 0,
45-
sheetRowNumber: 2,
46-
row: {
47-
'436f6c756d6e31': { value: 'value1', columnName: 'Column1' },
48-
'436f6c756d6e32': { value: 'value2', columnName: 'Column2' },
49-
},
50-
},
51-
{
52-
tableRowIndex: 1,
53-
sheetRowNumber: 3,
54-
row: {
55-
'436f6c756d6e31': { value: 'value3', columnName: 'Column1' },
56-
'436f6c756d6e32': { value: 'value4', columnName: 'Column2' },
57-
},
58-
},
59-
],
60-
columns: [
61-
{
62-
id: Buffer.from('Column1').toString('hex'),
63-
name: 'Column1',
64-
value: 'value1, value3',
65-
},
66-
{
67-
id: Buffer.from('Column2').toString('hex'),
68-
name: 'Column2',
69-
value: 'value2, value4',
70-
},
71-
],
72-
numRows: 2,
73-
},
74-
} as unknown as IExecutionStep
75-
76-
const result = await getDataOutMetadata(executionStep)
81+
const result = await getDataOutMetadata(DEFAULT_SUCCESS_EXECUTION_STEP)
7782

7883
expect(result).toEqual({
79-
rows: {
80-
label: 'List of row(s) found',
81-
displayedValue: 'Preview 2 row(s)',
82-
order: 1,
83-
type: 'array',
84-
},
8584
rowsFound: {
8685
label: 'Number of rows found',
8786
order: 2,
8887
},
89-
columns: [
90-
{
91-
id: { isHidden: true },
92-
name: { isHidden: true },
93-
value: {
94-
label: 'Column1',
95-
},
96-
},
97-
{
98-
id: { isHidden: true },
99-
name: { isHidden: true },
100-
value: {
101-
label: 'Column2',
102-
},
103-
},
104-
],
88+
data: {
89+
label: 'List of row(s) found',
90+
displayedValue: 'Preview 2 row(s)',
91+
order: 1,
92+
type: 'multiple-row-object',
93+
},
10594
})
10695
})
10796

10897
it('should handle missing columns in dataOut', async () => {
10998
const executionStep = {
11099
dataOut: {
111100
rowsFound: 0,
112-
rows: [],
113-
// columns is missing
101+
data: {
102+
rows: [],
103+
// columns is missing
104+
},
114105
},
115106
} as unknown as IExecutionStep
116107

117-
const result = await getDataOutMetadata(executionStep)
118-
119-
expect(result).toEqual({
120-
rows: {
121-
label: 'List of row(s) found',
122-
displayedValue: 'Preview 0 row(s)',
123-
order: 1,
124-
type: 'array',
125-
},
126-
rowsFound: {
127-
label: 'Number of rows found',
128-
order: 2,
129-
},
130-
columns: [],
131-
})
108+
await expect(getDataOutMetadata(executionStep)).rejects.toThrow()
132109
})
133110

134111
it('should handle invalid dataOut format gracefully', async () => {

0 commit comments

Comments
 (0)