mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 15:15:24 +00:00
feat: per host layout for the terminal panel bar
This commit is contained in:
1 parent
d8c686177b
commit
ea50dc349a
9 files changed
+165
-3
No files matched your search
@@ -2,9 +2,12 @@ import { afterEach, describe, expect, it } from "vitest";
|
||||
import { act, fireEvent, render, screen } from "@testing-library/react";
|
||||
import type { Tab } from "@/types/ui-types";
|
||||
import {
|
||||
arrangeCompanions,
|
||||
companionApplies,
|
||||
getCompanionState,
|
||||
registerCompanionDef,
|
||||
registerCompanionLayoutDef,
|
||||
resetCompanionLayouts,
|
||||
resetCompanions,
|
||||
resetCompanionStates,
|
||||
toggleCompanion,
|
||||
@@ -74,3 +77,35 @@ describe("companions", () => {
|
||||
expect(getCompanionState("t1").openId).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("companion layout", () => {
|
||||
it("hides a companion and the whole bar by host layout", () => {
|
||||
registerCompanionLayoutDef({
|
||||
id: "layout",
|
||||
tabTypes: ["terminal"],
|
||||
resolve: (host) =>
|
||||
(host as unknown as { off?: boolean }).off
|
||||
? { enabled: false }
|
||||
: { hidden: ["b"] },
|
||||
});
|
||||
const a = { id: "a", component: () => null };
|
||||
const b = { id: "b", component: () => null };
|
||||
expect(companionApplies(a, tab())).toBe(true);
|
||||
expect(companionApplies(b, tab())).toBe(false);
|
||||
expect(
|
||||
companionApplies(a, tab({ host: { id: 1, off: true } as never })),
|
||||
).toBe(false);
|
||||
resetCompanionLayouts();
|
||||
expect(companionApplies(b, tab())).toBe(true);
|
||||
});
|
||||
|
||||
it("orders by the saved list and keeps unknown ones after", () => {
|
||||
const defs = [{ id: "a" }, { id: "b" }, { id: "c" }];
|
||||
expect(arrangeCompanions(defs, ["c", "a"]).map((d) => d.id)).toEqual([
|
||||
"c",
|
||||
"a",
|
||||
"b",
|
||||
]);
|
||||
expect(arrangeCompanions(defs, undefined)).toBe(defs);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user