Files
homarr/packages/widgets/src/definition.spec.ts
T
Bergashaandajnart 002381d294 feat(v2 docker widget): Fixes column-resize squashing (#6646)
* fix(dataTable): resizing a column no longer squashes the others

mantine-datatable's built-in column resize keeps the table's total
width fixed by shrinking every other column to compensate, which
collapses columns toward zero in a narrow widget (open upstream
issue, no fix: icflorescu/mantine-datatable#discussions-757).

Replaced it with our own resize handle that only ever changes the
width of the column being dragged - the table grows and scrolls
horizontally instead. Shared via usePersistedTableLayout, so docker,
downloads, and beszel-system-table all get it.

* feat(docker): enable hold-Shift advanced focus preview

The widget already renders differently for displayMode="advanced",
but was missing supportsAdvancedFocus: true, so the board never
offered the hold-Shift preview for it - matching downloads and
media-server, which both set this flag.

* style(docker): tighten row density, decouple icon size from row height

Circular avatar, denser row/footer padding, and action icons rendered
larger than their button via absolute positioning so they don't
inflate row height (the button stays small and fixed - it repeats
once per row, so any growth there multiplies across every visible
container).

* fix(data-table): harden shared column resizing

* fix(data-table): account for board scaling

* fix(data-table): compact shared headers

* fix(data-table): fit columns to widget

* fix(downloads): simplify advanced details

* test(widgets): align Docker advanced focus

* fix(downloads): widen expanded details

---------

Co-authored-by: ajnart <thomas@ajnart.dev>
2026-08-21 15:12:31 +02:00

55 lines
2.2 KiB
TypeScript

import { describe, expect, test } from "vitest";
import { definition as appDefinition } from "./app";
import { definition as beszelAlertsDefinition } from "./beszel-alerts";
import { definition as beszelSystemGridDefinition } from "./beszel-system-grid";
import { definition as beszelSystemStatsDefinition } from "./beszel-system-stats";
import { definition as beszelSystemTableDefinition } from "./beszel-system-table";
import { definition as clockDefinition } from "./clock";
import { definition as customApiDefinition } from "./custom-api";
import { getWidgetQueryKeys, supportsAdvancedFocus } from "./definition";
import { definition as dockerDefinition } from "./docker";
import { definition as downloadsDefinition } from "./downloads";
import { definition as indexerManagerDefinition } from "./indexer-manager";
import { definition as notebookDefinition } from "./notebook";
describe("getWidgetQueryKeys", () => {
test("falls back to the widget router namespace", () => {
expect(getWidgetQueryKeys({ kind: "example" })).toEqual([[["widget", "example"]]]);
});
test("wraps a singular explicit key", () => {
expect(getWidgetQueryKeys({ kind: "example", queryKey: [["app", "byId"]] })).toEqual([[["app", "byId"]]]);
});
test("preserves every explicit key for multi-root widgets", () => {
const queryKeys = [
[["widget", "audioStats", "getStats"]],
[["widget", "mediaServer", "getCurrentStreams"]],
] as const;
expect(getWidgetQueryKeys({ kind: "audioStats", queryKeys })).toBe(queryKeys);
});
});
describe("supportsAdvancedFocus", () => {
test.each([
appDefinition,
beszelAlertsDefinition,
beszelSystemGridDefinition,
beszelSystemStatsDefinition,
beszelSystemTableDefinition,
customApiDefinition,
indexerManagerDefinition,
notebookDefinition,
])("keeps non-enhanced widgets compact", (widgetDefinition) => {
expect(supportsAdvancedFocus(widgetDefinition)).toBe(false);
});
test("requires an explicit opt-in", () => {
expect(supportsAdvancedFocus({})).toBe(false);
expect(supportsAdvancedFocus(clockDefinition)).toBe(true);
expect(supportsAdvancedFocus(dockerDefinition)).toBe(true);
expect(supportsAdvancedFocus(downloadsDefinition)).toBe(true);
});
});