11import { randomUUID } from 'crypto'
22import { describe , expect , it } from 'vitest'
33
4- import { FOR_EACH_ITERATION_KEY } from '../.. /common/constants'
4+ import { FOR_EACH_ITERATION_KEY } from '@/apps/toolbox /common/constants'
55import {
66 isCheckboxItems ,
77 processItems ,
8- } from '../.. /common/get-for-each-variables'
8+ } from '@/apps/toolbox /common/get-for-each-variables'
99
1010describe ( 'get-for-each-variables' , ( ) => {
1111 describe ( 'isCheckboxItems' , ( ) => {
@@ -74,8 +74,8 @@ describe('get-for-each-variables', () => {
7474 } ,
7575 ] ,
7676 columns : [
77- { id : col1Id , name : 'Column 1' } ,
78- { id : col2Id , name : 'Column 2' } ,
77+ { id : col1Id , name : 'Column 1' , value : `data.rows.*.data. ${ col1Id } ` } ,
78+ { id : col2Id , name : 'Column 2' , value : `data.rows.*.data. ${ col2Id } ` } ,
7979 ] ,
8080 }
8181
@@ -118,8 +118,8 @@ describe('get-for-each-variables', () => {
118118 } ,
119119 ] ,
120120 columns : [
121- { id : col1Id , name : 'Column 1' } ,
122- { id : col2Id , name : 'Column 2' } ,
121+ { id : col1Id , name : 'Column 1' , value : `data.rows.*.data. ${ col1Id } ` } ,
122+ { id : col2Id , name : 'Column 2' , value : `data.rows.*.data. ${ col2Id } ` } ,
123123 ] ,
124124 }
125125
@@ -164,8 +164,16 @@ describe('get-for-each-variables', () => {
164164 } ,
165165 ] ,
166166 columns : [
167- { id : 'col1' , name : 'Excel Column 1' } ,
168- { id : 'col2' , name : 'Excel Column 2' } ,
167+ {
168+ id : 'col1' ,
169+ name : 'Excel Column 1' ,
170+ value : `data.rows.*.data.col1` ,
171+ } ,
172+ {
173+ id : 'col2' ,
174+ name : 'Excel Column 2' ,
175+ value : `data.rows.*.data.col2` ,
176+ } ,
169177 ] ,
170178 }
171179
@@ -192,7 +200,9 @@ describe('get-for-each-variables', () => {
192200 const col1Id = randomUUID ( )
193201 const mockData = {
194202 rows : [ ] as any [ ] ,
195- columns : [ { id : col1Id , name : 'Column 1' } ] ,
203+ columns : [
204+ { id : col1Id , name : 'Column 1' , value : `data.rows.*.data.${ col1Id } ` } ,
205+ ] ,
196206 }
197207
198208 const result = processItems ( mockData )
@@ -217,7 +227,9 @@ describe('get-for-each-variables', () => {
217227 it ( 'should handle empty rows' , ( ) => {
218228 const mockData = {
219229 rows : [ ] as any [ ] ,
220- columns : [ { id : 'col1' , name : 'Column 1' } ] ,
230+ columns : [
231+ { id : 'col1' , name : 'Column 1' , value : `data.rows.*.data.col1` } ,
232+ ] ,
221233 }
222234
223235 const result = processItems ( mockData )
@@ -264,7 +276,13 @@ describe('get-for-each-variables', () => {
264276 rowId : 'single-row' ,
265277 } ,
266278 ] ,
267- columns : [ { id : colId , name : 'Single Column' } ] ,
279+ columns : [
280+ {
281+ id : colId ,
282+ name : 'Single Column' ,
283+ value : `data.rows.*.data.${ colId } ` ,
284+ } ,
285+ ] ,
268286 }
269287
270288 const result = processItems ( mockData )
@@ -290,22 +308,40 @@ describe('get-for-each-variables', () => {
290308 const uuidCol = randomUUID ( )
291309 const tilesData = {
292310 rows : [ { data : { [ uuidCol ] : 'test' } , rowId : 'test' } ] ,
293- columns : [ { id : uuidCol , name : 'UUID Column' } ] ,
311+ columns : [
312+ {
313+ id : uuidCol ,
314+ name : 'UUID Column' ,
315+ value : `data.rows.*.data.${ uuidCol } ` ,
316+ } ,
317+ ] ,
294318 }
295319 expect ( processItems ( tilesData ) . inputSource ) . toBe ( 'tiles' )
296320
297321 // Test with tiles (ULID column IDs)
298322 const ulidCol = '01ARZ3NDEKTSV4RRFFQ69G5FAV'
299323 const ulidData = {
300324 rows : [ { data : { [ ulidCol ] : 'test' } , rowId : 'test' } ] ,
301- columns : [ { id : ulidCol , name : 'ULID Column' } ] ,
325+ columns : [
326+ {
327+ id : ulidCol ,
328+ name : 'ULID Column' ,
329+ value : `data.rows.*.data.${ ulidCol } ` ,
330+ } ,
331+ ] ,
302332 }
303333 expect ( processItems ( ulidData ) . inputSource ) . toBe ( 'tiles' )
304334
305335 // Test with m365-excel (regular column IDs)
306336 const excelData = {
307337 rows : [ { data : { col1 : 'test' } } ] ,
308- columns : [ { id : 'col1' , name : 'Regular Column' } ] ,
338+ columns : [
339+ {
340+ id : 'col1' ,
341+ name : 'Regular Column' ,
342+ value : `data.rows.*.data.col1` ,
343+ } ,
344+ ] ,
309345 }
310346 expect ( processItems ( excelData ) . inputSource ) . toBe ( 'm365-excel' )
311347 } )
0 commit comments