Fix sidebar and tab overflow navigation
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { strict as assert } from "node:assert";
|
||||
import test from "node:test";
|
||||
import { canTreeNodeExpand, canTreeNodeShowExpander, treeItemPaddingLeft } from "../../apps/desktop/src/lib/sidebarTreeItemLayout.ts";
|
||||
import {
|
||||
canTreeNodeExpand,
|
||||
canTreeNodeShowExpander,
|
||||
treeItemPaddingLeft,
|
||||
usesFullWidthTreeLabel,
|
||||
} from "../../apps/desktop/src/lib/sidebarTreeItemLayout.ts";
|
||||
|
||||
test("treeItemPaddingLeft converts tree depth to sidebar indentation", () => {
|
||||
assert.equal(treeItemPaddingLeft(0), "8px");
|
||||
@@ -31,3 +36,13 @@ test("canTreeNodeShowExpander hides empty saved SQL containers", () => {
|
||||
assert.equal(canTreeNodeShowExpander({ type: "saved-sql-root", childCount: 1 }), true);
|
||||
assert.equal(canTreeNodeShowExpander({ type: "saved-sql-folder", childCount: 1 }), true);
|
||||
});
|
||||
|
||||
test("usesFullWidthTreeLabel only expands object names that users need to read horizontally", () => {
|
||||
assert.equal(usesFullWidthTreeLabel("table"), true);
|
||||
assert.equal(usesFullWidthTreeLabel("view"), true);
|
||||
assert.equal(usesFullWidthTreeLabel("mongo-collection"), true);
|
||||
|
||||
assert.equal(usesFullWidthTreeLabel("connection"), false);
|
||||
assert.equal(usesFullWidthTreeLabel("schema"), false);
|
||||
assert.equal(usesFullWidthTreeLabel("column"), false);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { strict as assert } from "node:assert";
|
||||
import test from "node:test";
|
||||
import {
|
||||
colorForTabGroupKey,
|
||||
shouldShowTabOverflowControls,
|
||||
tabGroupColor,
|
||||
tabGroupKey,
|
||||
} from "../../apps/desktop/src/lib/tabPresentation.ts";
|
||||
|
||||
test("tab overflow controls only show when there are hidden tabs to reach", () => {
|
||||
assert.equal(shouldShowTabOverflowControls(0, true, true, true), false);
|
||||
assert.equal(shouldShowTabOverflowControls(3, false, false, false), false);
|
||||
assert.equal(shouldShowTabOverflowControls(3, true, false, false), true);
|
||||
assert.equal(shouldShowTabOverflowControls(3, false, true, false), true);
|
||||
assert.equal(shouldShowTabOverflowControls(3, false, false, true), true);
|
||||
});
|
||||
|
||||
test("tab group key and color are stable per connection database pair", () => {
|
||||
const first = { connectionId: "local", database: "orders" };
|
||||
const same = { connectionId: "local", database: "orders" };
|
||||
const other = { connectionId: "local", database: "billing" };
|
||||
|
||||
assert.equal(tabGroupKey(first), "local::orders");
|
||||
assert.equal(tabGroupKey(first), tabGroupKey(same));
|
||||
assert.notEqual(tabGroupKey(first), tabGroupKey(other));
|
||||
assert.equal(tabGroupColor(first), tabGroupColor(same));
|
||||
assert.equal(colorForTabGroupKey(tabGroupKey(first)), tabGroupColor(first));
|
||||
});
|
||||
Reference in New Issue
Block a user