Skip to content

Commit 3e850b2

Browse files
committed
test(tables): cover the generic undo metadata snapshot
The delete-column undo snapshot moved from one flattened field per metadata key to `typeMetadataOf(column)` whole; the test still built the old shape. Adds a currency case, which the flattened form would have dropped.
1 parent caaf511 commit 3e850b2

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

apps/sim/hooks/use-table-undo.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ describe('useTableUndo – restoring a deleted select column', () => {
248248
columnPosition: 0,
249249
columnUnique: false,
250250
columnRequired: false,
251-
columnOptions: [{ id: 'opt_open', name: 'Open' }],
252-
columnMultiple: true,
251+
columnMetadata: { options: [{ id: 'opt_open', name: 'Open' }], multiple: true },
253252
cellData: [],
254253
previousOrder: null,
255254
previousWidth: null,
@@ -271,4 +270,22 @@ describe('useTableUndo – restoring a deleted select column', () => {
271270
expect(payload.multiple).toBe(true)
272271
expect(payload.id).toBe('col_status')
273272
})
273+
274+
it('restores EVERY type-specific key, not a hand-listed subset', () => {
275+
// The snapshot used to carry one flattened field per key, so each new
276+
// metadata key was silently dropped by undo until someone remembered to
277+
// add it. It now captures `typeMetadataOf(column)` whole.
278+
const currencyAction: TableUndoAction = {
279+
...selectAction,
280+
columnName: 'amount',
281+
columnId: 'col_amount',
282+
columnType: 'currency' as const,
283+
columnMetadata: { currencyCode: 'EUR' },
284+
}
285+
mockPopUndo.mockReturnValueOnce(makeEntry(currencyAction))
286+
const { undo } = TestHook()
287+
;(undo as () => void)()
288+
289+
expect(mockMutate.mock.calls[0][0].currencyCode).toBe('EUR')
290+
})
274291
})

0 commit comments

Comments
 (0)