quality / commitlint (push) Skipped
quality / changes (push) Successful in 6s
quality / go (push) Skipped
quality / bird2 (push) Skipped
quality / docker-check (push) Skipped
quality / openapi (push) Successful in 23s
quality / web (push) Successful in 1m4s
CD / quality (push) Successful in 1m36s
CD / publish (push) Successful in 2m55s
- Introduced `KIT_ACTION_COLUMN_SIZE` for consistent action column sizing across data grids. - Updated `applyKitActionColumn` to enforce action column properties such as fixed size, no sorting, and no resizing. - Enhanced `kitColumnPinning` logic to conditionally enable pinning based on horizontal scrolling. - Added tests for `applyKitActionColumn` and `kitColumnPinning` to ensure expected behavior. - Adjusted `AccessApiKeysGrid`, `ScheduleModulesGrid`, and `ResourcePageFiltered` components to utilize new action column features.
99 lines
3.1 KiB
TypeScript
99 lines
3.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
||
|
||
import {
|
||
applyKitActionColumn,
|
||
KIT_ACTION_COLUMN_SIZE,
|
||
kitColumnPinning,
|
||
kitDataGridTableClassNames,
|
||
kitDataGridTableLayout,
|
||
} from './frame-data-grid'
|
||
|
||
describe('kitDataGridTableLayout', () => {
|
||
it('filtering-2 defaults: dense, headerBackground false, width fixed', () => {
|
||
const layout = kitDataGridTableLayout()
|
||
expect(layout.dense).toBe(true)
|
||
expect(layout.headerBackground).toBe(false)
|
||
expect(layout.width).toBe('fixed')
|
||
expect(layout.headerSticky).toBe(false)
|
||
expect('stripped' in layout ? layout.stripped : undefined).toBeUndefined()
|
||
expect(layout.columnsPinnable).toBe(false)
|
||
})
|
||
|
||
it('kit tableClassNames совпадает с filtering-2 edgeCell', () => {
|
||
expect(kitDataGridTableClassNames.edgeCell).toBe('first:ps-3 last:pe-3')
|
||
expect(kitDataGridTableClassNames.base).toBe(
|
||
'[&_[data-pinned]]:bg-(--frame-panel-bg)',
|
||
)
|
||
})
|
||
|
||
it('именованные opts: auto + pin', () => {
|
||
const layout = kitDataGridTableLayout({
|
||
width: 'auto',
|
||
columnsPinnable: true,
|
||
})
|
||
expect(layout.width).toBe('auto')
|
||
expect(layout.columnsPinnable).toBe(true)
|
||
expect(layout.headerBackground).toBe(false)
|
||
})
|
||
})
|
||
|
||
describe('applyKitActionColumn', () => {
|
||
it('locks filtering-2 size on id=actions', () => {
|
||
const [name, actions] = applyKitActionColumn([
|
||
{ id: 'name', header: 'Name' },
|
||
{ id: 'actions', header: () => null, cell: () => 'x' },
|
||
])
|
||
expect(name?.id).toBe('name')
|
||
expect(actions?.size).toBe(KIT_ACTION_COLUMN_SIZE)
|
||
expect(actions?.minSize).toBe(KIT_ACTION_COLUMN_SIZE)
|
||
expect(actions?.maxSize).toBe(KIT_ACTION_COLUMN_SIZE)
|
||
expect(actions?.enableSorting).toBe(false)
|
||
expect(actions?.enableResizing).toBe(false)
|
||
})
|
||
|
||
it('keeps explicit size (data-grid-base-7 text button)', () => {
|
||
const [actions] = applyKitActionColumn([
|
||
{ id: 'actions', size: 104, cell: () => 'x' },
|
||
])
|
||
expect(actions?.size).toBe(104)
|
||
expect(actions?.minSize).toBe(104)
|
||
expect(actions?.maxSize).toBe(104)
|
||
})
|
||
|
||
it('does not rewrite a non-actions last column', () => {
|
||
const [col] = applyKitActionColumn([{ id: 'name', header: 'Name' }])
|
||
expect(col?.size).toBeUndefined()
|
||
expect(col?.enableResizing).toBeUndefined()
|
||
})
|
||
|
||
it('applies DNA when pinLastColumn even without id=actions', () => {
|
||
const [col] = applyKitActionColumn([{ id: 'other', cell: () => 'x' }], {
|
||
pinLastColumn: true,
|
||
})
|
||
expect(col?.size).toBe(KIT_ACTION_COLUMN_SIZE)
|
||
expect(col?.maxSize).toBe(KIT_ACTION_COLUMN_SIZE)
|
||
})
|
||
})
|
||
|
||
describe('kitColumnPinning', () => {
|
||
it('does not end-pin without horizontalScroll', () => {
|
||
const result = kitColumnPinning({
|
||
pinLastColumn: true,
|
||
lastColId: 'actions',
|
||
})
|
||
expect(result.enablePinning).toBe(false)
|
||
expect(result.columnPinning.end).toEqual([])
|
||
})
|
||
|
||
it('end-pins only with horizontalScroll', () => {
|
||
const result = kitColumnPinning({
|
||
pinLastColumn: true,
|
||
horizontalScroll: true,
|
||
lastColId: 'actions',
|
||
})
|
||
expect(result.enablePinning).toBe(true)
|
||
expect(result.columnPinning.end).toEqual(['actions'])
|
||
})
|
||
})
|
||
|