automationsMainDragRegion.test.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. expect(layoutSource).toMatch(
  17. /workspaceMainView !== "automations"\s*&&\s*workspaceMainView !== "plugin-store"/,
  18. );
  19. expect(frameSource).toContain('data-testid="automations-main-drag-region"');
  20. expect(frameSource).toContain("h-12 shrink-0 [app-region:drag]");
  21. expect(frameSource).toContain("isDesktop ? (");
  22. expect(layoutSource).toContain(
  23. "min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]",
  24. );
  25. expect(
  26. layoutSource.match(/<AutomationsMainBreadcrumbFrame/gu)?.length,
  27. ).toBe(4);
  28. expect(
  29. frameSource.match(/data-testid="automations-main-drag-region"/gu)?.length,
  30. ).toBe(1);
  31. });
  32. it("reserves scrollbar space in automations and plugins shell layouts", () => {
  33. const layoutSource = readSource(
  34. "packages/ui/src/app-shell/WorkspaceShellLayout.tsx",
  35. );
  36. const stableScrollerCount =
  37. layoutSource.match(
  38. /min-h-0 flex-1 overflow-y-auto \[scrollbar-gutter:stable\]/gu,
  39. )?.length ?? 0;
  40. expect(stableScrollerCount).toBe(4);
  41. });
  42. });