From f5ab012925aeaa194d1206108068ea3a56e7f326 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 13 Jul 2026 05:14:28 +0200 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E8=A1=A5=E9=BD=90=20iframe=20?= =?UTF-8?q?=E4=B8=8E=E5=88=86=E6=A0=8F=E4=BA=A4=E4=BA=92=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/SplitWorkspaceLayout.test.ts | 72 ++++++++++++++++++ .../layout/SplitWorkspaceLayout.vue | 33 +++++++++ .../views/opencode/OpenCodeFrameView.test.ts | 73 +++++++++++++++++++ .../src/views/opencode/OpenCodeFrameView.vue | 58 ++++++++++++--- .../specs/opencode-split-a11y.spec.ts | 48 ++++++++++++ 5 files changed, 275 insertions(+), 9 deletions(-) create mode 100644 web/hwlab-cloud-web/src/components/layout/SplitWorkspaceLayout.test.ts create mode 100644 web/hwlab-cloud-web/src/views/opencode/OpenCodeFrameView.test.ts create mode 100644 web/hwlab-cloud-web/tests/workbench-e2e/specs/opencode-split-a11y.spec.ts diff --git a/web/hwlab-cloud-web/src/components/layout/SplitWorkspaceLayout.test.ts b/web/hwlab-cloud-web/src/components/layout/SplitWorkspaceLayout.test.ts new file mode 100644 index 00000000..abc0d2c0 --- /dev/null +++ b/web/hwlab-cloud-web/src/components/layout/SplitWorkspaceLayout.test.ts @@ -0,0 +1,72 @@ +// @vitest-environment jsdom +// SPEC: PJ2026-010405 云端控制台. +// Implementation reference: draft-2026-07-13-p0-cloud-console. +// Responsibility: 验证 bounded split workspace separator 的 ARIA 合同与键盘宽度调整。 + +import { mount } from "@vue/test-utils"; +import { describe, expect, test, vi } from "vitest"; +import SplitWorkspaceLayout from "./SplitWorkspaceLayout.vue"; + +describe("SplitWorkspaceLayout", () => { + test("exposes bounded vertical separator values", () => { + const wrapper = mount(SplitWorkspaceLayout, { + props: { + rightOpen: true, + leftWidth: 28, + rightWidth: 52, + minLeftWidth: 18, + maxLeftWidth: 36, + minRightWidth: 30, + maxRightWidth: 70 + } + }); + const separators = wrapper.findAll("[role='separator']"); + + expect(separators).toHaveLength(2); + expect(separators[0].attributes()).toMatchObject({ + tabindex: "0", + "aria-orientation": "vertical", + "aria-valuemin": "18", + "aria-valuemax": "36", + "aria-valuenow": "28" + }); + expect(separators[1].attributes()).toMatchObject({ + tabindex: "0", + "aria-orientation": "vertical", + "aria-valuemin": "30", + "aria-valuemax": "70", + "aria-valuenow": "52" + }); + }); + + test("moves each separator by two percentage points with arrow keys", async () => { + const onLeftWidth = vi.fn(); + const onRightWidth = vi.fn(); + const wrapper = mount(SplitWorkspaceLayout, { props: { rightOpen: true, leftWidth: 30, rightWidth: 50, "onUpdate:leftWidth": onLeftWidth, "onUpdate:rightWidth": onRightWidth } }); + const separators = wrapper.findAll("[role='separator']"); + + await separators[0].trigger("keydown", { key: "ArrowRight" }); + await separators[1].trigger("keydown", { key: "ArrowLeft" }); + + expect(onLeftWidth).toHaveBeenCalledWith(32); + expect(onRightWidth).toHaveBeenCalledWith(52); + }); + + test("clamps keyboard changes and removes collapsed separators from tab order", async () => { + const onLeftWidth = vi.fn(); + const onRightWidth = vi.fn(); + const wrapper = mount(SplitWorkspaceLayout, { + props: { rightOpen: true, leftWidth: 18, rightWidth: 70, leftCollapsed: true, rightCollapsed: true, "onUpdate:leftWidth": onLeftWidth, "onUpdate:rightWidth": onRightWidth } + }); + const separators = wrapper.findAll("[role='separator']"); + + expect(separators[0].attributes("tabindex")).toBe("-1"); + expect(separators[1].attributes("tabindex")).toBe("-1"); + + await wrapper.setProps({ leftCollapsed: false, rightCollapsed: false }); + await separators[0].trigger("keydown", { key: "ArrowLeft" }); + await separators[1].trigger("keydown", { key: "ArrowLeft" }); + expect(onLeftWidth).toHaveBeenCalledWith(18); + expect(onRightWidth).toHaveBeenCalledWith(70); + }); +}); diff --git a/web/hwlab-cloud-web/src/components/layout/SplitWorkspaceLayout.vue b/web/hwlab-cloud-web/src/components/layout/SplitWorkspaceLayout.vue index c6eacd7c..a5d49f0c 100644 --- a/web/hwlab-cloud-web/src/components/layout/SplitWorkspaceLayout.vue +++ b/web/hwlab-cloud-web/src/components/layout/SplitWorkspaceLayout.vue @@ -1,3 +1,5 @@ + +