backgroundBashSidePane.test.ts 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import { describe, expect, it } from "vitest";
  2. import { getVisibleSidePaneTabs, openBackgroundBashSidePane } from "@/lib/workspaceSidePane.js";
  3. describe("background Bash tabs", () => {
  4. const target = {
  5. workspacePath: "/project",
  6. workspaceIdentity: "ssh:a",
  7. remoteSessionId: "remote-a",
  8. rootSessionId: "root",
  9. sessionId: "child",
  10. workId: "work",
  11. title: "build",
  12. };
  13. it("reuses the same task and isolates identical paths/ids in different scopes", () => {
  14. const first = openBackgroundBashSidePane(null, target);
  15. expect(openBackgroundBashSidePane(first, target).tabs).toHaveLength(1);
  16. const other = openBackgroundBashSidePane(first, { ...target, remoteSessionId: "remote-b" });
  17. expect(other.tabs).toHaveLength(2);
  18. const foreign = openBackgroundBashSidePane(other, { ...target, workspaceIdentity: "ssh:b" });
  19. expect(foreign.tabs).toHaveLength(3);
  20. expect(getVisibleSidePaneTabs(first, "root")).toHaveLength(1);
  21. expect(getVisibleSidePaneTabs(first, "other")).toHaveLength(0);
  22. expect(first.tabs[0]).toMatchObject({
  23. type: "bash-output",
  24. workspaceKey: "ssh:a",
  25. sessionId: "child",
  26. rootSessionId: "root",
  27. });
  28. });
  29. });