Files
windmill/frontend/src/lib/components/s3TableOps.test.ts
T
8064fa8fb6 feat: show s3 csv and parquet results in the db table with filters (#12712)
* feat: filter a db table from its column headers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: accept column filters, header row and separator on app s3 table routes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: show s3 csv and parquet results in the db table with filters

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: apply db table header filters as you type and widen filterable columns

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: harden db table header filters, column widths and narrow s3 tables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: point ee ref at the unknown filter column fix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: compare postgres arrays as text, ignore stale s3 table counts, clearable separator

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
2026-11-30 21:58:26 +01:00

49 lines
1.8 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { datatypeOf, jsonTableRows, serverTableFormat } from './s3TableOps'
import { dbColumnKind } from './dbTableFilters'
describe('serverTableFormat', () => {
it('pages delimited text and newline-delimited JSON through the csv reader', () => {
expect(serverTableFormat('a/b.parquet')).toBe('parquet')
for (const key of ['a.csv', 'a.TSV', 'a.jsonl', 'a.ndjson']) {
expect(serverTableFormat(key)).toBe('csv')
}
})
it('leaves plain JSON to the browser', () => {
expect(serverTableFormat('a.json')).toBeUndefined()
expect(serverTableFormat('a.txt')).toBeUndefined()
})
it('leaves an upper-case parquet extension to the download card', () => {
expect(serverTableFormat('a.PARQUET')).toBeUndefined()
})
})
describe('datatypeOf', () => {
it('maps Arrow types to the kinds the grid filters by', () => {
expect(dbColumnKind(datatypeOf('Int64'))).toBe('number')
expect(dbColumnKind(datatypeOf('UInt8'))).toBe('number')
expect(dbColumnKind(datatypeOf('Float64'))).toBe('number')
expect(dbColumnKind(datatypeOf('Decimal128(21, 1)'))).toBe('number')
expect(dbColumnKind(datatypeOf('Boolean'))).toBe('boolean')
expect(dbColumnKind(datatypeOf('Utf8View'))).toBe('text')
})
it('names a nested type without its field list', () => {
expect(datatypeOf('List(Field { name: "item", data_type: Utf8 })')).toBe('list')
expect(datatypeOf('Timestamp(Microsecond, None)')).toBe('timestamp')
})
})
describe('jsonTableRows', () => {
it('keeps objects and wraps other elements in a value column', () => {
expect(jsonTableRows([{ a: 1 }, 2, null])).toEqual([{ a: 1 }, { value: 2 }, { value: null }])
})
it('has no table for an empty array or a non-array', () => {
expect(jsonTableRows([])).toBeUndefined()
expect(jsonTableRows({ a: 1 })).toBeUndefined()
})
})