From 166ef2dffa993cb1ed010654060a3a1ec0c556a7 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Fri, 4 Dec 2026 13:40:15 +0800 Subject: [PATCH] test(e2e): fix the main branch's failing layout and caret key specs (#7945) caretKeysEverywhere bound "Control+H", which is not a key stroke, so Move Caret Left was never bound; it passed on macOS only because Ctrl+H deletes backward there. compactMode expects the 30px status bar, toolbarCustomization measures the first visible item after the Center group, the commit check spec accepts a sub-pixel clip, and codeLensLayout waits for the editor to measure. --- e2e/caretKeysEverywhere.spec.ts | 4 +++- e2e/codeLensLayout.spec.ts | 8 ++++++-- e2e/commit.spec.ts | 3 ++- e2e/compactMode.spec.ts | 2 +- e2e/toolbarCustomization.spec.ts | 5 ++++- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/e2e/caretKeysEverywhere.spec.ts b/e2e/caretKeysEverywhere.spec.ts index e1ffab26d4..3d01ab7060 100644 --- a/e2e/caretKeysEverywhere.spec.ts +++ b/e2e/caretKeysEverywhere.spec.ts @@ -10,7 +10,7 @@ test("rebound caret keys move the project tree, Go to File's list and text field overrides: { "editor.up": ["Meta+K"], "editor.down": ["Meta+J"], - "editor.left": ["Control+H"], + "editor.left": ["Ctrl+H"], "editor.lineStart": ["Meta+H"], }, }); @@ -48,6 +48,8 @@ test("rebound caret keys move the project tree, Go to File's list and text field await page.keyboard.press("Meta+k"); await expect(lead).toHaveText(first!); await page.keyboard.press("Control+h"); + // Moved, not deleted: macOS also maps ⌃H to Delete Backward in text fields. + await expect(field).toHaveValue("Order"); expect(await field.evaluate((el: HTMLInputElement) => [el.selectionStart, el.selectionEnd])).toEqual([4, 4]); await page.keyboard.press("Meta+h"); expect(await field.evaluate((el: HTMLInputElement) => [el.selectionStart, el.selectionEnd])).toEqual([0, 0]); diff --git a/e2e/codeLensLayout.spec.ts b/e2e/codeLensLayout.spec.ts index a6e8fccb98..6c7dca594f 100644 --- a/e2e/codeLensLayout.spec.ts +++ b/e2e/codeLensLayout.spec.ts @@ -42,8 +42,12 @@ test("a Code Vision row fits CJK hints at a large editor font", async ({ workben // The editor measured the taller row: the lines below it still sit beside their numbers. const line = editor.locator(".cm-line", { hasText: "class OrderController" }); const number = editor.locator(".cm-lineNumbers .cm-gutterElement", { hasText: /^8$/ }); - const [lineTop, numberTop] = [(await line.boundingBox())!.y, (await number.boundingBox())!.y]; - expect(Math.abs(lineTop - numberTop)).toBeLessThanOrEqual(1); + await expect + .poll(async () => { + const [lineBox, numberBox] = await Promise.all([line.boundingBox(), number.boundingBox()]); + return Math.abs(lineBox!.y - numberBox!.y); + }) + .toBeLessThanOrEqual(1); }); test("a Code Vision row keeps its height at the default editor font", async ({ workbench: page }) => { diff --git a/e2e/commit.spec.ts b/e2e/commit.spec.ts index 31c7b78d4f..52d5d14a90 100644 --- a/e2e/commit.spec.ts +++ b/e2e/commit.spec.ts @@ -843,7 +843,8 @@ test("commit check text scrolls independently of its status icon and retry actio expect((await icon.boundingBox())!.y).toBeCloseTo(statusTop, 0); expect((await retry.boundingBox())!.y).toBeCloseTo(retryTop, 0); const details = feedback.getByRole("button", { name: "Review final check", exact: true }); - await expect(details).toBeInViewport({ ratio: 1 }); + // Scrolled to the end of a list with a fractional height: at most a sub-pixel sliver stays clipped. + await expect(details).toBeInViewport({ ratio: 0.99 }); await expect(icon).toBeInViewport({ ratio: 1 }); await expect(retry).toBeInViewport({ ratio: 1 }); await expect(commitAnyway).toBeInViewport({ ratio: 1 }); diff --git a/e2e/compactMode.spec.ts b/e2e/compactMode.spec.ts index 33ebe2bea9..da250abeb3 100644 --- a/e2e/compactMode.spec.ts +++ b/e2e/compactMode.spec.ts @@ -2,7 +2,7 @@ import { expect, test } from "./fixtures"; /** Heights IDEA's Islands theme uses in compact mode (`*.compact` keys), against the defaults. */ const SIZES = { - normal: { titleBar: 40, treeRow: 24, stripeIcon: 20, statusBar: 34, runButton: 30 }, + normal: { titleBar: 40, treeRow: 24, stripeIcon: 20, statusBar: 30, runButton: 30 }, compact: { titleBar: 32, treeRow: 22, stripeIcon: 16, statusBar: 24, runButton: 26 }, }; diff --git a/e2e/toolbarCustomization.spec.ts b/e2e/toolbarCustomization.spec.ts index 606172aa93..22c9783f05 100644 --- a/e2e/toolbarCustomization.spec.ts +++ b/e2e/toolbarCustomization.spec.ts @@ -108,7 +108,10 @@ test("the Center group is centred in the main toolbar", async ({ workbench: page } // The old 900px width: no room to centre, so the group is pushed left of the right group, never over it. await page.setViewportSize({ width: 900, height: 700 }); - const rightGroup = bar.locator("[data-toolbar-center] ~ :not([data-toolbar-spacer])").first(); + const rightGroup = bar + .locator("[data-toolbar-center] ~ :not([data-toolbar-spacer])") + .filter({ visible: true }) + .first(); await expect(async () => { const [barBox, groupBox, rightBox] = await Promise.all([ bar.boundingBox(),