| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import { readFileSync } from "node:fs";
- import { resolve } from "node:path";
- import { describe, expect, it } from "vitest";
- function readSource(path: string) {
- return readFileSync(resolve(process.cwd(), path), "utf8");
- }
- describe("workspace main view drag region", () => {
- it("keeps a desktop-only drag strip when automations or plugins hide WorkspaceHeader", () => {
- const layoutSource = readSource(
- "packages/ui/src/app-shell/WorkspaceShellLayout.tsx",
- );
- const frameSource = readSource(
- "packages/ui/src/settings/AutomationsMainBreadcrumbFrame.tsx",
- );
- // 断言语义不绑定排版:条件可被格式化换行。
- // task-dispatch 主视图与 automations/plugin-store 同规则隐藏 WorkspaceHeader(M2 接线)。
- expect(layoutSource).toMatch(
- /workspaceMainView !== "automations"\s*&&\s*workspaceMainView !== "task-dispatch"\s*&&\s*workspaceMainView !== "plugin-store"/,
- );
- expect(frameSource).toContain('data-testid="automations-main-drag-region"');
- expect(frameSource).toContain("h-12 shrink-0 [app-region:drag]");
- expect(frameSource).toContain("isDesktop ? (");
- expect(layoutSource).toContain(
- "min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]",
- );
- expect(
- layoutSource.match(/<AutomationsMainBreadcrumbFrame/gu)?.length,
- ).toBe(6);
- expect(
- frameSource.match(/data-testid="automations-main-drag-region"/gu)?.length,
- ).toBe(1);
- });
- it("reserves scrollbar space in automations and plugins shell layouts", () => {
- const layoutSource = readSource(
- "packages/ui/src/app-shell/WorkspaceShellLayout.tsx",
- );
- const stableScrollerCount =
- layoutSource.match(
- /min-h-0 flex-1 overflow-y-auto \[scrollbar-gutter:stable\]/gu,
- )?.length ?? 0;
- // automations / plugins / task-dispatch 主视图外壳在手机远控(chatContent 槽)与
- // 桌面(ResizablePanel 链)两条渲染链各一份 = 6;新增同构主视图时同步维护。
- expect(stableScrollerCount).toBe(6);
- });
- });
|