backgroundBashSidePane.test.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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(
  21. getVisibleSidePaneTabs(first.tabs, {
  22. workspaceKey: first.tabs[0]!.workspaceKey ?? null,
  23. ownerTaskId: "root",
  24. }),
  25. ).toHaveLength(1);
  26. expect(
  27. getVisibleSidePaneTabs(first.tabs, {
  28. workspaceKey: first.tabs[0]!.workspaceKey ?? null,
  29. ownerTaskId: "other",
  30. }),
  31. ).toHaveLength(0);
  32. expect(first.tabs[0]).toMatchObject({
  33. type: "bash-output",
  34. workspaceKey: "ssh:a",
  35. sessionId: "child",
  36. rootSessionId: "root",
  37. });
  38. });
  39. });