mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-11 20:17:46 +00:00
feat(ui): add customizable download table columns
Add persisted column reordering, positional alignment, animated drag feedback, and resize cleanup for the download table. Keep row actions at the trailing edge, preserve RTL/LTR behavior, and include localized column controls and sidebar alignment fixes.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
DEFAULT_COLUMN_ALIGNMENTS,
|
||||
DEFAULT_COLUMN_ORDER,
|
||||
normalizeColumnAlignments,
|
||||
normalizeColumnOrder,
|
||||
normalizeColumnWidths,
|
||||
} from './downloadTableColumns';
|
||||
|
||||
describe('download table column preferences', () => {
|
||||
it('normalizes a persisted order without losing or duplicating columns', () => {
|
||||
expect(normalizeColumnOrder(['Status', 'Status', 'not-a-column', 'File Name'])).toEqual([
|
||||
'Status',
|
||||
'File Name',
|
||||
'Size',
|
||||
'Speed',
|
||||
'ETA',
|
||||
'Date Added',
|
||||
]);
|
||||
});
|
||||
|
||||
it('clamps persisted widths to column minimums and restores malformed entries', () => {
|
||||
expect(normalizeColumnWidths([10, 70, Number.POSITIVE_INFINITY, 80, '48', 140])).toEqual([
|
||||
160,
|
||||
70,
|
||||
220,
|
||||
80,
|
||||
80,
|
||||
140,
|
||||
]);
|
||||
|
||||
expect(normalizeColumnWidths([0, 100, 220, 100, 80, 170])[0]).toBe(160);
|
||||
});
|
||||
|
||||
it('keeps only supported positional alignment values', () => {
|
||||
expect(normalizeColumnAlignments({
|
||||
'File Name': 'center',
|
||||
Size: 'right',
|
||||
Status: 'invalid',
|
||||
Speed: 'left',
|
||||
})).toEqual({
|
||||
...DEFAULT_COLUMN_ALIGNMENTS,
|
||||
'File Name': 'center',
|
||||
Size: 'right',
|
||||
Speed: 'left',
|
||||
});
|
||||
});
|
||||
|
||||
it('restores the default order for malformed persisted data', () => {
|
||||
expect(normalizeColumnOrder(null)).toEqual([...DEFAULT_COLUMN_ORDER]);
|
||||
expect(normalizeColumnAlignments(null)).toEqual(DEFAULT_COLUMN_ALIGNMENTS);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user