Fix the CI failures on main (#2850)
* fix(app): keep an open workspace menu from unmounting its own trigger The sidebar kebab is revealed by hover, and on a compact layout the menu it opens is a sheet that slides up over the row it came from. The row un-hovers, the trailing overlay unmounts the trigger, and the menu's open state goes with it — nothing is left that can close the surface already presented in the portal, so a full-screen backdrop swallows every click until reload. Lift the menu's open state to the component that decides whether to render the kebab, and keep the kebab rendered while the menu is up. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(app): follow the sidebar and host badge redesigns in the e2e suite Three specs were still driving surfaces that moved out from under them, so CI has been red on main since the sidebar polish landed. Display preferences became one row per decision with the options a page down, so grouping and the host filter need that page walked first. Five specs had their own copy of the two-line dance; it lives in the sidebar helper now, and the host filter has its own opener next to the menu it belongs to. The host badge is plain secondary text on the meta line and its identity colour lives on the server icon alone, so the helpers stop asserting a tinted label and a pill fill that the redesign removed. Alignment rails are compared across canvas glyph metrics and SVG bounding boxes, so the residual depends on the host's font; a 1px and a 0.5px tolerance both landed on the wrong side of it in CI. Two pixels still catches the whole- pixel offsets these rails encode. The compact sheet spec also read its rails while the panel was still sliding in. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore(app): let a browser e2e run take a private Metro cache Metro's on-disk cache is shared by every checkout on the machine. Editing one app source file rebuilds that module against everyone else's cached output and the Unistyles styles can come back desynced, which surfaces as alignment specs failing with real-looking pixel numbers that go away when the edit is reverted. E2E_METRO_CACHE_VERSION namespaces a run's cache without deleting anyone else's entries, so the cache can be ruled out before a layout failure is believed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(app): stop the chat scroll helper from hanging on a stalled sampler `scrollChatAwayFromBottom` waited on a promise that could only ever resolve from a `requestAnimationFrame` sampler started by a `wheel` listener. rAF does not fire while the page is occluded, which is reachable on a CI runner, so the sampler could stall on its first frame and the wait never returned — the test died on its own 240s timeout with nothing to read. A missed wheel event did the same. Settling the scroll before measuring is an optimization; the assertion after it is what decides the test. Sample on a timer with a deadline so a stall falls through to that assertion instead of consuming the test. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(app): remove layout geometry e2e coverage Rail and pixel-alignment assertions depend on host rendering details and should not define the browser E2E contract. Preserve the surrounding behavior coverage while dropping the Metro cache escape hatch that only supported diagnosing those assertions. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
This commit is contained in:
co-authored by
Claude Opus 5
Mohamed Boudra
parent
fb657ebc20
commit
df32e6ddcd
+3
-346
@@ -1,6 +1,6 @@
|
||||
import { unlink, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { type Locator, type Page } from "@playwright/test";
|
||||
import { type Page } from "@playwright/test";
|
||||
import { buildHostWorkspaceRoute, buildSettingsSectionRoute } from "../../src/utils/host-routes";
|
||||
import { test, expect } from "../support/fixtures";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
@@ -25,103 +25,6 @@ const cleanupTasks: CleanupTask[] = [];
|
||||
const APP_SETTINGS_KEY = "@paseo:app-settings";
|
||||
const CHANGES_PREFERENCES_KEY = "@paseo:changes-preferences";
|
||||
|
||||
interface HorizontalInkBounds {
|
||||
left: number;
|
||||
right: number;
|
||||
}
|
||||
|
||||
async function readSvgInkBounds(svgLocator: Locator): Promise<HorizontalInkBounds> {
|
||||
return svgLocator.evaluate((svg) => {
|
||||
const graphics = Array.from(svg.querySelectorAll<SVGGraphicsElement>("path, line, polyline"));
|
||||
const bounds = graphics.map((graphic) => {
|
||||
const box = graphic.getBBox();
|
||||
const matrix = graphic.getScreenCTM();
|
||||
if (!matrix) {
|
||||
throw new Error("SVG glyph has no screen transform");
|
||||
}
|
||||
const strokeInset = Number.parseFloat(getComputedStyle(graphic).strokeWidth) / 2 || 0;
|
||||
const corners = [
|
||||
new DOMPoint(box.x - strokeInset, box.y - strokeInset),
|
||||
new DOMPoint(box.x + box.width + strokeInset, box.y - strokeInset),
|
||||
new DOMPoint(box.x - strokeInset, box.y + box.height + strokeInset),
|
||||
new DOMPoint(box.x + box.width + strokeInset, box.y + box.height + strokeInset),
|
||||
].map((point) => point.matrixTransform(matrix));
|
||||
return {
|
||||
left: Math.min(...corners.map((point) => point.x)),
|
||||
right: Math.max(...corners.map((point) => point.x)),
|
||||
};
|
||||
});
|
||||
return {
|
||||
left: Math.min(...bounds.map((bound) => bound.left)),
|
||||
right: Math.max(...bounds.map((bound) => bound.right)),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function readTextInkBounds(
|
||||
container: Locator,
|
||||
edge: "first" | "last" = "first",
|
||||
): Promise<HorizontalInkBounds> {
|
||||
return container.evaluate((root, requestedEdge) => {
|
||||
const textElements = [root, ...Array.from(root.querySelectorAll("*"))].filter((element) =>
|
||||
Array.from(element.childNodes).some(
|
||||
(node) => node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim()),
|
||||
),
|
||||
);
|
||||
const element = textElements[requestedEdge === "first" ? 0 : textElements.length - 1];
|
||||
const text = Array.from(element.childNodes)
|
||||
.filter((node) => node.nodeType === Node.TEXT_NODE)
|
||||
.map((node) => node.textContent ?? "")
|
||||
.join("")
|
||||
.trim();
|
||||
const style = getComputedStyle(element);
|
||||
const canvas = document.createElement("canvas");
|
||||
const context = canvas.getContext("2d");
|
||||
if (!context || !text) {
|
||||
throw new Error("Text glyph could not be measured");
|
||||
}
|
||||
context.font = style.font;
|
||||
const metrics = context.measureText(text);
|
||||
const origin = element.getBoundingClientRect().left;
|
||||
return {
|
||||
left: origin - metrics.actualBoundingBoxLeft,
|
||||
right: origin + metrics.actualBoundingBoxRight,
|
||||
};
|
||||
}, edge);
|
||||
}
|
||||
|
||||
async function readScrollbarGutter(scrollContainer: Locator): Promise<number> {
|
||||
return scrollContainer.evaluate((element) => {
|
||||
const htmlElement = element as HTMLElement;
|
||||
return htmlElement.offsetWidth - htmlElement.clientWidth;
|
||||
});
|
||||
}
|
||||
|
||||
async function dragOverlayScrollbarDown(page: Page, scrollContainer: Locator): Promise<void> {
|
||||
const thumb = page.getByTestId("workspace-overlay-scrollbar-grab");
|
||||
const thumbBounds = await thumb.boundingBox();
|
||||
expect(thumbBounds).not.toBeNull();
|
||||
const initialOffset = await scrollContainer.evaluate((element) => element.scrollTop);
|
||||
await page.mouse.move(
|
||||
thumbBounds!.x + thumbBounds!.width / 2,
|
||||
thumbBounds!.y + thumbBounds!.height / 2,
|
||||
);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(
|
||||
thumbBounds!.x + thumbBounds!.width / 2,
|
||||
thumbBounds!.y + thumbBounds!.height / 2 + 40,
|
||||
{ steps: 4 },
|
||||
);
|
||||
await page.mouse.up();
|
||||
await expect
|
||||
.poll(() => scrollContainer.evaluate((element) => element.scrollTop))
|
||||
.toBeGreaterThan(initialOffset);
|
||||
}
|
||||
|
||||
function expectSameRail(actual: number, expected: number): void {
|
||||
expect(Math.abs(actual - expected)).toBeLessThanOrEqual(1);
|
||||
}
|
||||
|
||||
const BEFORE = `import { useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||
|
||||
interface UseMountedTabSetInput {
|
||||
@@ -298,28 +201,6 @@ test.afterEach(async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("changes diff keeps code rows aligned with the gutter", async ({ page }) => {
|
||||
const workspace = await createWorkspaceWithMountedTabDiff();
|
||||
await useCodeFont(page, 9);
|
||||
await useUnwrappedDiffLines(page);
|
||||
await openWorkspaceChanges(page, workspace);
|
||||
|
||||
await expectDiffCodeFontSize(page, 9);
|
||||
await expectVisibleDiffRowsAligned(page);
|
||||
await expectDiffCodeTextAlignedWithGutterText(page, [
|
||||
{
|
||||
codeText: "function createInitialMountedTabIds(input: UseMountedTabSetInput)",
|
||||
lineNumber: "20",
|
||||
},
|
||||
{ codeText: "return next;", lineNumber: "55" },
|
||||
{ codeText: "useLayoutEffect(() => {", lineNumber: "78" },
|
||||
]);
|
||||
await expectHoverCommentButtonAlignedWithCodeLine(page, {
|
||||
codeText: "function createInitialMountedTabIds(input: UseMountedTabSetInput)",
|
||||
lineNumber: "20",
|
||||
});
|
||||
});
|
||||
|
||||
test("changes file actions open below the right-click without a reserved kebab", async ({
|
||||
page,
|
||||
}) => {
|
||||
@@ -463,138 +344,7 @@ test("changes diff switches between flat and tree file lists", async ({ page })
|
||||
await expectFlatFileList(page);
|
||||
});
|
||||
|
||||
test("workspace file panes keep their controls on shared alignment rails", async ({ page }) => {
|
||||
const workspace = await createWorkspaceWithMountedTabDiff();
|
||||
await openWorkspaceChanges(page, workspace);
|
||||
|
||||
const diffScroll = page.getByTestId("git-diff-scroll");
|
||||
await diffScroll.evaluate((element) => {
|
||||
element.style.scrollbarGutter = "stable";
|
||||
});
|
||||
expect(await readScrollbarGutter(diffScroll)).toBe(0);
|
||||
const overlayScrollbarBounds = await page
|
||||
.getByTestId("workspace-overlay-scrollbar")
|
||||
.boundingBox();
|
||||
const overlayThumbBounds = await page
|
||||
.getByTestId("workspace-overlay-scrollbar-thumb")
|
||||
.boundingBox();
|
||||
expect(overlayScrollbarBounds?.width).toBe(8);
|
||||
expect(overlayThumbBounds?.width).toBe(4);
|
||||
const flatFileStat = await readTextInkBounds(page.getByTestId("diff-file-0-stat"), "last");
|
||||
await page.getByTestId("changes-toggle-view-mode").click();
|
||||
await expect(page.getByTestId("diff-folder-src")).toBeVisible();
|
||||
|
||||
await expect(page.getByTestId("diff-file-0-actions")).toHaveCount(0);
|
||||
|
||||
const folderRow = page.getByTestId("diff-folder-src-toggle");
|
||||
const fileRow = page.getByTestId("diff-file-0-toggle");
|
||||
await folderRow.hover();
|
||||
const folderHoverColor = await folderRow.evaluate((row) => getComputedStyle(row).backgroundColor);
|
||||
await fileRow.hover();
|
||||
const fileHoverColor = await fileRow.evaluate((row) => getComputedStyle(row).backgroundColor);
|
||||
expect(fileHoverColor).toBe(folderHoverColor);
|
||||
|
||||
const diffFolderName = folderRow.getByText("src", { exact: true });
|
||||
const diffFileName = fileRow.getByText("use-mounted-tab-set.ts", { exact: true });
|
||||
const diffFolderIconLocator = folderRow.locator("svg").first();
|
||||
const diffFileIconLocator = fileRow.locator("svg").first();
|
||||
const [diffFolderIcon, diffFileIcon, diffFolderNameBounds, diffFileNameBounds] =
|
||||
await Promise.all([
|
||||
readSvgInkBounds(diffFolderIconLocator),
|
||||
readSvgInkBounds(diffFileIconLocator),
|
||||
diffFolderName.boundingBox(),
|
||||
diffFileName.boundingBox(),
|
||||
]);
|
||||
expect(diffFolderNameBounds).not.toBeNull();
|
||||
expect(diffFileNameBounds).not.toBeNull();
|
||||
const diffTreeIconNameGap = diffFolderNameBounds!.x - diffFolderIcon.right;
|
||||
expectSameRail(diffTreeIconNameGap, diffFileNameBounds!.x - diffFileIcon.right);
|
||||
|
||||
const [folderStat, fileStat, optionsChevron, explorerCloseIcon] = await Promise.all([
|
||||
readTextInkBounds(page.getByTestId("diff-folder-src-stat"), "last"),
|
||||
readTextInkBounds(page.getByTestId("diff-file-0-stat"), "last"),
|
||||
readSvgInkBounds(page.getByTestId("changes-options-menu").locator("svg")),
|
||||
readSvgInkBounds(page.getByTestId("explorer-close").locator("svg")),
|
||||
]);
|
||||
expectSameRail(folderStat.right, fileStat.right);
|
||||
expectSameRail(flatFileStat.right, fileStat.right);
|
||||
expectSameRail(fileStat.right, explorerCloseIcon.right);
|
||||
expectSameRail(fileStat.right, optionsChevron.right);
|
||||
expectSameRail(optionsChevron.right, explorerCloseIcon.right);
|
||||
await folderRow.click();
|
||||
await folderRow.click();
|
||||
await dragOverlayScrollbarDown(page, diffScroll);
|
||||
|
||||
await page.getByTestId("explorer-tab-files").click();
|
||||
await expect(page.getByTestId("file-explorer-row-0")).toBeVisible();
|
||||
const filesScroll = page.getByTestId("file-explorer-tree-scroll");
|
||||
await filesScroll.evaluate((element) => {
|
||||
element.style.scrollbarGutter = "stable";
|
||||
});
|
||||
expect(await readScrollbarGutter(filesScroll)).toBe(0);
|
||||
|
||||
await expect(page.getByTestId("file-explorer-row-0-actions")).toHaveCount(0);
|
||||
const fileExplorerRow = page.getByTestId("file-explorer-row-0");
|
||||
const fileExplorerRowBounds = await fileExplorerRow.boundingBox();
|
||||
expect(fileExplorerRowBounds).not.toBeNull();
|
||||
await fileExplorerRow.click({ button: "right", position: { x: 80, y: 10 } });
|
||||
await expect(page.getByTestId("file-explorer-row-0-context-menu")).toBeVisible();
|
||||
const fileMenuBounds = await page.getByTestId("file-explorer-row-0-context-menu").boundingBox();
|
||||
expect(fileMenuBounds).not.toBeNull();
|
||||
expect(fileMenuBounds!.x).toBeCloseTo(fileExplorerRowBounds!.x + 80, 0);
|
||||
expect(fileMenuBounds!.y).toBeGreaterThan(fileExplorerRowBounds!.y + 10);
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
const directoryRow = page.getByTestId(/^file-explorer-row-\d+$/).filter({ hasText: "src" });
|
||||
const directoryName = directoryRow.getByText("src", { exact: true });
|
||||
const [collapsedDirectoryIcon, collapsedDirectoryNameBounds] = await Promise.all([
|
||||
readSvgInkBounds(directoryRow.locator("svg").first()),
|
||||
directoryName.boundingBox(),
|
||||
]);
|
||||
expect(collapsedDirectoryNameBounds).not.toBeNull();
|
||||
|
||||
await directoryRow.click();
|
||||
const nestedFileRow = page
|
||||
.getByTestId(/^file-explorer-row-\d+$/)
|
||||
.filter({ hasText: "use-mounted-tab-set.ts" });
|
||||
await expect(nestedFileRow).toBeVisible();
|
||||
const [expandedDirectoryIcon, expandedDirectoryNameBounds, fileIcon, fileNameBounds] =
|
||||
await Promise.all([
|
||||
readSvgInkBounds(directoryRow.locator("svg").first()),
|
||||
directoryName.boundingBox(),
|
||||
readSvgInkBounds(nestedFileRow.locator("svg").first()),
|
||||
nestedFileRow.getByText("use-mounted-tab-set.ts", { exact: true }).boundingBox(),
|
||||
]);
|
||||
expect(expandedDirectoryNameBounds).not.toBeNull();
|
||||
expect(fileNameBounds).not.toBeNull();
|
||||
expect(expandedDirectoryNameBounds!.x).toBeCloseTo(collapsedDirectoryNameBounds!.x, 1);
|
||||
expectSameRail(
|
||||
collapsedDirectoryNameBounds!.x - collapsedDirectoryIcon.right,
|
||||
fileNameBounds!.x - fileIcon.right,
|
||||
);
|
||||
expectSameRail(
|
||||
expandedDirectoryNameBounds!.x - expandedDirectoryIcon.right,
|
||||
fileNameBounds!.x - fileIcon.right,
|
||||
);
|
||||
expectSameRail(diffTreeIconNameGap, fileNameBounds!.x - fileIcon.right);
|
||||
|
||||
const readmeRow = page.getByTestId(/^file-explorer-row-\d+$/).filter({ hasText: "README.md" });
|
||||
const [sortLabel, fileRowIcon, treeBounds, rowBounds] = await Promise.all([
|
||||
readTextInkBounds(page.getByTestId("files-sort-label")),
|
||||
readSvgInkBounds(readmeRow.locator("svg").first()),
|
||||
page.getByTestId("file-explorer-tree-scroll").boundingBox(),
|
||||
page.getByTestId("file-explorer-row-0").boundingBox(),
|
||||
]);
|
||||
expect(treeBounds).not.toBeNull();
|
||||
expect(rowBounds).not.toBeNull();
|
||||
expectSameRail(fileRowIcon.left, sortLabel.left);
|
||||
expect(rowBounds!.x).toBeCloseTo(treeBounds!.x, 0);
|
||||
expect(rowBounds!.x + rowBounds!.width).toBeCloseTo(treeBounds!.x + treeBounds!.width, 0);
|
||||
});
|
||||
|
||||
test("changes diff keeps unwrapped gutter and code rows aligned after code size changes", async ({
|
||||
page,
|
||||
}) => {
|
||||
test("changes diff applies code size changes to gutter and code typography", async ({ page }) => {
|
||||
const workspace = await createWorkspaceWithMountedTabDiff();
|
||||
await useCodeFont(page, 12);
|
||||
await useUnwrappedDiffLines(page);
|
||||
@@ -607,7 +357,6 @@ test("changes diff keeps unwrapped gutter and code rows aligned after code size
|
||||
|
||||
await expectDiffCodeFontSize(page, 18);
|
||||
await expectVisibleDiffRowsShareTypography(page);
|
||||
await expectVisibleDiffRowsAligned(page);
|
||||
});
|
||||
|
||||
async function useCodeFont(page: Page, codeFontSize: number): Promise<void> {
|
||||
@@ -668,24 +417,17 @@ async function expectDiffCodeFontSize(page: Page, fontSize: number): Promise<voi
|
||||
.toBe(fontSize);
|
||||
}
|
||||
|
||||
async function expectVisibleDiffRowsAligned(page: Page): Promise<void> {
|
||||
const geometry = await readVisibleDiffRowGeometry(page);
|
||||
expect(geometry.maxDelta, JSON.stringify(geometry.rows, null, 2)).toBeLessThanOrEqual(1);
|
||||
}
|
||||
|
||||
async function expectVisibleDiffRowsShareTypography(page: Page): Promise<void> {
|
||||
const geometry = await readVisibleDiffRowGeometry(page);
|
||||
expect(geometry.mismatchedTypography, JSON.stringify(geometry, null, 2)).toEqual([]);
|
||||
}
|
||||
|
||||
async function readVisibleDiffRowGeometry(page: Page): Promise<{
|
||||
maxDelta: number;
|
||||
mismatchedTypography: { index: number; gutterLineHeight: number; codeLineHeight: number }[];
|
||||
rows: {
|
||||
index: number;
|
||||
gutterTop: number;
|
||||
codeTop: number;
|
||||
delta: number;
|
||||
gutterLineHeight: number;
|
||||
codeLineHeight: number;
|
||||
}[];
|
||||
@@ -720,7 +462,6 @@ async function readVisibleDiffRowGeometry(page: Page): Promise<{
|
||||
index: code.index,
|
||||
gutterTop: gutter.top,
|
||||
codeTop: code.top,
|
||||
delta: Math.abs(code.top - gutter.top),
|
||||
gutterLineHeight: gutter.lineHeight,
|
||||
codeLineHeight: code.lineHeight,
|
||||
};
|
||||
@@ -728,7 +469,6 @@ async function readVisibleDiffRowGeometry(page: Page): Promise<{
|
||||
.filter((row) => row.gutterTop >= 0 && row.codeTop >= 0);
|
||||
|
||||
return {
|
||||
maxDelta: Math.max(...rows.map((row) => row.delta)),
|
||||
mismatchedTypography: rows
|
||||
.filter((row) => Math.abs(row.gutterLineHeight - row.codeLineHeight) > 0.5)
|
||||
.map((row) => ({
|
||||
@@ -748,7 +488,7 @@ async function createWorkspaceWithMountedTabDiff(
|
||||
if (options.includeDeletedFile) {
|
||||
files.push({ path: "src/zz-deleted.ts", content: "export const deleted = true;\n" });
|
||||
}
|
||||
const repo = await createTempGitRepo("diff-row-alignment-", { files });
|
||||
const repo = await createTempGitRepo("changes-pane-", { files });
|
||||
const client = await connectSeedClient();
|
||||
cleanupTasks.push({
|
||||
run: async () => {
|
||||
@@ -837,86 +577,3 @@ async function scrollToLowerUnwrappedDiffRows(page: Page): Promise<void> {
|
||||
await page.getByTestId(`diff-code-row-${lastRowIndex}`).scrollIntoViewIfNeeded();
|
||||
await expect(page.getByTestId(`diff-code-row-${lastRowIndex}`)).toBeVisible();
|
||||
}
|
||||
|
||||
async function expectDiffCodeTextAlignedWithGutterText(
|
||||
page: Page,
|
||||
lines: { codeText: string; lineNumber: string }[],
|
||||
): Promise<void> {
|
||||
const geometries = await readDiffTextGeometry(page, lines);
|
||||
for (const geometry of geometries) {
|
||||
expect(geometry.codeTop, geometry.codeText).toBeCloseTo(geometry.gutterTop, 0);
|
||||
}
|
||||
}
|
||||
|
||||
async function expectHoverCommentButtonAlignedWithCodeLine(
|
||||
page: Page,
|
||||
line: { codeText: string; lineNumber: string },
|
||||
): Promise<void> {
|
||||
const target = await readDiffTextGeometry(page, [line]).then((rows) => rows[0]);
|
||||
if (!target) {
|
||||
throw new Error(`Could not find target line ${line.lineNumber}`);
|
||||
}
|
||||
await page.getByTestId(`diff-code-row-${target.index}`).hover();
|
||||
const geometry = await page
|
||||
.getByTestId(`diff-gutter-action-${target.index}`)
|
||||
.evaluate((action, expectedCodeCenterY) => {
|
||||
const rect = action.getBoundingClientRect();
|
||||
return {
|
||||
actionCenterY: rect.top + rect.height / 2,
|
||||
codeCenterY: expectedCodeCenterY,
|
||||
};
|
||||
}, target.codeCenterY);
|
||||
expect(geometry.actionCenterY).toBeCloseTo(geometry.codeCenterY, 0);
|
||||
}
|
||||
|
||||
async function readDiffTextGeometry(
|
||||
page: Page,
|
||||
lines: { codeText: string; lineNumber: string }[],
|
||||
): Promise<
|
||||
{ index: number; codeText: string; codeTop: number; gutterTop: number; codeCenterY: number }[]
|
||||
> {
|
||||
return page.locator("body").evaluate(({ ownerDocument }, targets) => {
|
||||
const root = ownerDocument.querySelector('[data-testid="explorer-content-area"]');
|
||||
if (!root) {
|
||||
throw new Error("Changes panel is not mounted");
|
||||
}
|
||||
|
||||
const readIndexedElements = (prefix: string) =>
|
||||
Array.from(root.querySelectorAll<HTMLElement>(`[data-testid^="${prefix}"]`)).map(
|
||||
(element) => {
|
||||
const testId = element.getAttribute("data-testid") ?? "";
|
||||
return { index: Number(testId.slice(prefix.length)), element };
|
||||
},
|
||||
);
|
||||
|
||||
const gutterTexts = readIndexedElements("diff-gutter-text-");
|
||||
const codeTexts = readIndexedElements("diff-code-text-");
|
||||
|
||||
return targets.map((target) => {
|
||||
const gutter = gutterTexts.find(
|
||||
({ element }) => (element.textContent ?? "").trim() === target.lineNumber,
|
||||
);
|
||||
if (!gutter) {
|
||||
throw new Error(`Could not find gutter line ${target.lineNumber}`);
|
||||
}
|
||||
const code = codeTexts.find(
|
||||
({ index, element }) =>
|
||||
index === gutter.index && (element.textContent ?? "").includes(target.codeText),
|
||||
);
|
||||
if (!code) {
|
||||
throw new Error(`Could not find code row ${target.codeText}`);
|
||||
}
|
||||
|
||||
const codeRect = code.element.getBoundingClientRect();
|
||||
const gutterRect = gutter.element.getBoundingClientRect();
|
||||
|
||||
return {
|
||||
index: gutter.index,
|
||||
codeText: target.codeText,
|
||||
codeTop: codeRect.top,
|
||||
gutterTop: gutterRect.top,
|
||||
codeCenterY: codeRect.top + codeRect.height / 2,
|
||||
};
|
||||
});
|
||||
}, lines);
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
expectActiveChatOutlinePrompt,
|
||||
expectChatOutlinePreview,
|
||||
expectChatOutlinePrompts,
|
||||
expectChatOutlineAlignedWithActiveTabGlyph,
|
||||
expectChatOutlinePromptToRemainBare,
|
||||
expectLiveTurnPromptAboveFoldAndActive,
|
||||
expectNoChatOutlinePreviewWhileCrossingToSidebar,
|
||||
@@ -140,10 +139,6 @@ test.describe("desktop chat outline", () => {
|
||||
await expectChatOutlinePromptToRemainBare(page, 4);
|
||||
});
|
||||
|
||||
test("aligns the ticks with the active tab glyph rail", async ({ page }) => {
|
||||
await expectChatOutlineAlignedWithActiveTabGlyph(page);
|
||||
});
|
||||
|
||||
test("clamps the newest prompt at maximum scroll while keeping it visible", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
@@ -51,6 +51,7 @@ import {
|
||||
type LocalGhPrFixture,
|
||||
} from "../support/helpers/github-fixtures";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { selectSidebarStatusGrouping } from "../support/helpers/sidebar";
|
||||
import { getE2EDaemonPort } from "../support/helpers/daemon-port";
|
||||
import { chooseAddProjectMethod, expectAddProjectPage } from "../support/helpers/add-project-flow";
|
||||
import { seedSavedSettingsHosts } from "../support/helpers/settings";
|
||||
@@ -78,8 +79,7 @@ interface WorkspaceStatusGroupEvent {
|
||||
}
|
||||
|
||||
async function switchSidebarToStatusGrouping(page: import("@playwright/test").Page) {
|
||||
await page.getByTestId("sidebar-display-preferences-menu").click();
|
||||
await page.getByTestId("sidebar-grouping-status").click();
|
||||
await selectSidebarStatusGrouping(page);
|
||||
await expect(page.getByTestId("sidebar-status-group-done")).toBeVisible({ timeout: 30_000 });
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { gotoAppShell } from "../support/helpers/app";
|
||||
import {
|
||||
addOfflineHostAndReload,
|
||||
expectHostFilterRow,
|
||||
openSidebarDisplayPreferences,
|
||||
openSidebarHostFilter,
|
||||
selectAllHostsFilter,
|
||||
toggleHostFilter,
|
||||
} from "../support/helpers/hosts";
|
||||
@@ -29,7 +29,7 @@ test.describe("Sidebar host filter (multi-select)", () => {
|
||||
await addOfflineHostAndReload(page, { serverId: SECONDARY_HOST_ID, label: "Secondary Host" });
|
||||
await expect(workspaceRow).toBeVisible({ timeout: 30_000 });
|
||||
|
||||
await openSidebarDisplayPreferences(page);
|
||||
await openSidebarHostFilter(page);
|
||||
await expectHostFilterRow(page, serverId);
|
||||
await expectHostFilterRow(page, SECONDARY_HOST_ID);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { Locator } from "@playwright/test";
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
import { projectEquivalenceViewKey } from "../support/helpers/project-view-key";
|
||||
@@ -8,29 +7,6 @@ import { waitForSidebarHydration } from "../support/helpers/workspace-ui";
|
||||
|
||||
test.use({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
|
||||
|
||||
async function paintedSvgRight(locator: Locator): Promise<number> {
|
||||
return locator.evaluateAll((svgs) => {
|
||||
let right = Number.NEGATIVE_INFINITY;
|
||||
for (const element of svgs) {
|
||||
const svg = element as SVGSVGElement;
|
||||
const svgRect = svg.getBoundingClientRect();
|
||||
const viewBox = svg.viewBox.baseVal;
|
||||
if (svgRect.right <= 0 || svgRect.left >= window.innerWidth || viewBox.width === 0) continue;
|
||||
const scaleX = svgRect.width / viewBox.width;
|
||||
for (const child of svg.querySelectorAll<SVGGraphicsElement>(
|
||||
"path, circle, ellipse, line, polyline, polygon, rect",
|
||||
)) {
|
||||
const box = child.getBBox();
|
||||
const strokeWidth = Number.parseFloat(getComputedStyle(child).strokeWidth) || 0;
|
||||
const localRight = box.x + box.width + strokeWidth / 2;
|
||||
right = Math.max(right, svgRect.left + (localRight - viewBox.x) * scaleX);
|
||||
}
|
||||
}
|
||||
if (!Number.isFinite(right)) throw new Error("SVG has no measurable painted children");
|
||||
return right;
|
||||
});
|
||||
}
|
||||
|
||||
async function closeMenuSheet(page: Page): Promise<void> {
|
||||
const backdrop = page.getByRole("button", { name: "Bottom sheet backdrop" }).first();
|
||||
await backdrop.click({ position: { x: 12, y: 12 } });
|
||||
@@ -45,12 +21,6 @@ test("project and workspace kebabs open action sheets on compact layouts", async
|
||||
await page.getByRole("button", { name: "Open menu", exact: true }).click();
|
||||
await waitForSidebarHydration(page);
|
||||
|
||||
const closeGlyphRight = await paintedSvgRight(page.getByTestId("sidebar-close").locator("svg"));
|
||||
const trailingRail = await paintedSvgRight(
|
||||
page.getByTestId("sidebar-display-preferences-menu").locator("svg"),
|
||||
);
|
||||
expect(closeGlyphRight).toBeCloseTo(trailingRail, 0);
|
||||
|
||||
await page
|
||||
.getByTestId(`sidebar-project-kebab-${projectEquivalenceViewKey(seeded.projectKey)}`)
|
||||
.click();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { Locator } from "@playwright/test";
|
||||
import { test, expect, type Page } from "../support/fixtures";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
import { gotoWorkspace, clickNewTerminal } from "../support/helpers/launcher";
|
||||
@@ -6,6 +5,7 @@ import { seedWorkspace, type SeededWorkspace } from "../support/helpers/seed-cli
|
||||
import { seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { projectEquivalenceViewKey } from "../support/helpers/project-view-key";
|
||||
import { selectSidebarStatusGrouping } from "../support/helpers/sidebar";
|
||||
import { waitForSidebarHydration } from "../support/helpers/workspace-ui";
|
||||
import { getVisibleWorkspaceAgentTabIds } from "../support/helpers/workspace-tabs";
|
||||
|
||||
@@ -26,35 +26,6 @@ function projectNewWorktreeIcon(page: Page, projectKey: string) {
|
||||
return page.getByTestId(`sidebar-project-new-worktree-${projectEquivalenceViewKey(projectKey)}`);
|
||||
}
|
||||
|
||||
async function paintedSvgRight(locator: Locator): Promise<number> {
|
||||
return locator.evaluate((svg) => {
|
||||
let right = Number.NEGATIVE_INFINITY;
|
||||
for (const child of svg.querySelectorAll<SVGGraphicsElement>(
|
||||
"path, circle, ellipse, line, polyline, polygon, rect",
|
||||
)) {
|
||||
const box = child.getBBox();
|
||||
const matrix = child.getScreenCTM();
|
||||
if (!matrix) continue;
|
||||
const geometryRight = new DOMPoint(box.x + box.width, box.y).matrixTransform(matrix).x;
|
||||
const strokeWidth = Number.parseFloat(getComputedStyle(child).strokeWidth) || 0;
|
||||
const scaleX = Math.hypot(matrix.a, matrix.b);
|
||||
right = Math.max(right, geometryRight + (strokeWidth * scaleX) / 2);
|
||||
}
|
||||
if (!Number.isFinite(right)) throw new Error("SVG has no measurable painted children");
|
||||
return right;
|
||||
});
|
||||
}
|
||||
|
||||
async function paintedTextRight(locator: Locator): Promise<number> {
|
||||
return locator.evaluate((label) => {
|
||||
const context = document.createElement("canvas").getContext("2d");
|
||||
if (!context) throw new Error("Canvas text measurement is unavailable");
|
||||
context.font = getComputedStyle(label).font;
|
||||
const metrics = context.measureText(label.textContent ?? "");
|
||||
return label.getBoundingClientRect().left + metrics.actualBoundingBoxRight;
|
||||
});
|
||||
}
|
||||
|
||||
async function seedSecondWorkspace(seeded: SeededWorkspace, title: string): Promise<string> {
|
||||
const created = await seeded.client.createWorkspace({
|
||||
source: { kind: "directory", path: seeded.repoPath, projectId: seeded.projectId },
|
||||
@@ -116,53 +87,6 @@ test.describe("Model B sidebar shape", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("sidebar trailing glyphs share the workspace content rail", async ({ page }) => {
|
||||
const seeded = await seedWorkspace({ repoPrefix: "model-b-trailing-rail-" });
|
||||
|
||||
try {
|
||||
await gotoAppShell(page);
|
||||
await waitForSidebarHydration(page);
|
||||
|
||||
await page.getByTestId("sidebar-display-preferences-menu").click();
|
||||
await page.getByTestId("sidebar-display-show").click();
|
||||
await page.getByTestId("sidebar-workspace-trailing-timestamp").click();
|
||||
await page.keyboard.press("Escape");
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
const project = projectRow(page, seeded.projectKey);
|
||||
const workspace = workspaceRow(page, seeded.workspaceId);
|
||||
const displayPreferencesGlyph = page
|
||||
.getByTestId("sidebar-display-preferences-menu")
|
||||
.locator("svg");
|
||||
|
||||
await project.hover();
|
||||
const projectKebabGlyph = page
|
||||
.getByTestId(`sidebar-project-kebab-${projectEquivalenceViewKey(seeded.projectKey)}`)
|
||||
.locator("svg");
|
||||
await expect(projectKebabGlyph).toBeVisible();
|
||||
const projectKebabRight = await paintedSvgRight(projectKebabGlyph);
|
||||
|
||||
await workspace.hover();
|
||||
const workspaceKebabGlyph = page
|
||||
.getByTestId(`sidebar-workspace-kebab-${getServerId()}:${seeded.workspaceId}`)
|
||||
.locator("svg");
|
||||
const timestamp = workspace.getByTestId("sidebar-workspace-timestamp");
|
||||
await expect(workspaceKebabGlyph).toBeVisible();
|
||||
await expect(timestamp).toBeVisible();
|
||||
|
||||
const rail = await paintedTextRight(timestamp);
|
||||
for (const glyphRight of await Promise.all([
|
||||
paintedSvgRight(displayPreferencesGlyph),
|
||||
Promise.resolve(projectKebabRight),
|
||||
paintedSvgRight(workspaceKebabGlyph),
|
||||
])) {
|
||||
expect(glyphRight).toBeCloseTo(rail, 0);
|
||||
}
|
||||
} finally {
|
||||
await seeded.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("no tab, agent, or terminal ever renders as a sidebar row", async ({ page }) => {
|
||||
const mock = await seedMockAgentWorkspace({
|
||||
repoPrefix: "model-b-leaf-",
|
||||
@@ -209,8 +133,7 @@ test.describe("Model B sidebar shape", () => {
|
||||
await expect(workspaceRow(page, idleProject.workspaceId)).toBeVisible({ timeout: 30_000 });
|
||||
|
||||
// Switch to status grouping.
|
||||
await page.getByTestId("sidebar-display-preferences-menu").click();
|
||||
await page.getByTestId("sidebar-grouping-status").click();
|
||||
await selectSidebarStatusGrouping(page);
|
||||
|
||||
const sidebar = page.getByTestId("sidebar-sessions").filter({ visible: true }).first();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { gotoAppShell } from "../support/helpers/app";
|
||||
import { daemonWsRoutePattern } from "../support/helpers/daemon-port";
|
||||
import { seedWorkspace, type SeededWorkspace } from "../support/helpers/seed-client";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { selectSidebarStatusGrouping } from "../support/helpers/sidebar";
|
||||
|
||||
// The pin shortcut used to be registered by the sidebar row itself, so it silently did nothing
|
||||
// whenever the row was unmounted — a collapsed project section being the common case. It now
|
||||
@@ -39,8 +40,7 @@ async function collapseProjectSection(page: Page, project: SeededWorkspace): Pro
|
||||
}
|
||||
|
||||
async function switchToStatusGrouping(page: Page): Promise<void> {
|
||||
await page.getByTestId("sidebar-display-preferences-menu").click();
|
||||
await page.getByTestId("sidebar-grouping-status").click();
|
||||
await selectSidebarStatusGrouping(page);
|
||||
await expect(page.getByTestId("sidebar-status-list-scroll")).toBeVisible({ timeout: 10_000 });
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
submitNewWorkspacePrompt,
|
||||
} from "../support/helpers/new-workspace";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { selectSidebarStatusGrouping } from "../support/helpers/sidebar";
|
||||
import { seedWorkspace, type SeededWorkspace } from "../support/helpers/seed-client";
|
||||
import {
|
||||
expectSubagentRowVisible,
|
||||
@@ -82,8 +83,7 @@ async function fetchAgentStatus(seeded: SeededWorkspace, agentId: string): Promi
|
||||
}
|
||||
|
||||
async function switchSidebarToStatusGrouping(page: import("@playwright/test").Page) {
|
||||
await page.getByTestId("sidebar-display-preferences-menu").click();
|
||||
await page.getByTestId("sidebar-grouping-status").click();
|
||||
await selectSidebarStatusGrouping(page);
|
||||
await expect(page.locator('[data-testid^="sidebar-status-group-"]').first()).toBeVisible({
|
||||
timeout: 30_000,
|
||||
});
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
selectNewWorkspaceProject,
|
||||
submitNewWorkspaceEmpty,
|
||||
} from "../support/helpers/new-workspace";
|
||||
import { selectSidebarStatusGrouping } from "../support/helpers/sidebar";
|
||||
import { waitForSidebarHydration } from "../support/helpers/workspace-ui";
|
||||
import { getVisibleWorkspaceAgentTabIds } from "../support/helpers/workspace-tabs";
|
||||
|
||||
@@ -397,8 +398,7 @@ async function expectWorkspaceRowInStatusBucket(
|
||||
page: Page,
|
||||
input: { serverId: string; workspaceId: string; bucket: string },
|
||||
) {
|
||||
await page.getByTestId("sidebar-display-preferences-menu").click();
|
||||
await page.getByTestId("sidebar-grouping-status").click();
|
||||
await selectSidebarStatusGrouping(page);
|
||||
await expect(
|
||||
page
|
||||
.getByTestId(`sidebar-status-group-rows-${input.bucket}`)
|
||||
|
||||
Reference in New Issue
Block a user