automationsMainDragRegion.test.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { readFileSync } from "node:fs";
  2. import { resolve } from "node:path";
  3. import { describe, expect, it } from "vitest";
  4. function readSource(path: string) {
  5. return readFileSync(resolve(process.cwd(), path), "utf8");
  6. }
  7. describe("workspace main view drag region", () => {
  8. it("keeps a desktop-only drag strip when automations or plugins hide WorkspaceHeader", () => {
  9. const layoutSource = readSource(
  10. "packages/ui/src/app-shell/WorkspaceShellLayout.tsx",
  11. );
  12. const frameSource = readSource(
  13. "packages/ui/src/settings/AutomationsMainBreadcrumbFrame.tsx",
  14. );
  15. // 断言语义不绑定排版:条件可被格式化换行。
  16. // task-dispatch 主视图与 automations/plugin-store 同规则隐藏 WorkspaceHeader(M2 接线)。
  17. expect(layoutSource).toMatch(
  18. /workspaceMainView !== "automations"\s*&&\s*workspaceMainView !== "task-dispatch"\s*&&\s*workspaceMainView !== "plugin-store"/,
  19. );
  20. expect(frameSource).toContain('data-testid="automations-main-drag-region"');
  21. expect(frameSource).toContain("h-12 shrink-0 [app-region:drag]");
  22. expect(frameSource).toContain("isDesktop ? (");
  23. expect(layoutSource).toContain(
  24. "min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]",
  25. );
  26. expect(
  27. layoutSource.match(/<AutomationsMainBreadcrumbFrame/gu)?.length,
  28. ).toBe(6);
  29. expect(
  30. frameSource.match(/data-testid="automations-main-drag-region"/gu)?.length,
  31. ).toBe(1);
  32. });
  33. it("reserves scrollbar space in automations and plugins shell layouts", () => {
  34. const layoutSource = readSource(
  35. "packages/ui/src/app-shell/WorkspaceShellLayout.tsx",
  36. );
  37. const stableScrollerCount =
  38. layoutSource.match(
  39. /min-h-0 flex-1 overflow-y-auto \[scrollbar-gutter:stable\]/gu,
  40. )?.length ?? 0;
  41. // automations / plugins / task-dispatch 主视图外壳在手机远控(chatContent 槽)与
  42. // 桌面(ResizablePanel 链)两条渲染链各一份 = 6;新增同构主视图时同步维护。
  43. expect(stableScrollerCount).toBe(6);
  44. });
  45. });