Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 96 additions & 5 deletions ui/src/e2e/execution-settings-progress.test-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,83 @@ function currentLocationLayoutBox(card: Locator) {
});
}

async function assertLocationCardAlignment(component: Locator) {
await settledPanelBox(component, "settings");
const layout = await component.locator(".location-targets").evaluate((targets) => {
const basic = targets.querySelector("[data-target='platform_server']")!;
const { x, y, width, height } = basic.getBoundingClientRect();
const vms = Array.from(targets.querySelectorAll("[data-saved-vm]"), (vm) => {
const bounds = vm.getBoundingClientRect();
const footer = vm.querySelector(".saved-vm-details")!.getBoundingClientRect();
const configure = vm.querySelector("[data-configure-vm]")!.getBoundingClientRect();
const forget = vm.querySelector("[data-forget-vm]")!.getBoundingClientRect();
return {
x: bounds.x,
y: bounds.y,
width: bounds.width,
height: bounds.height,
footerBottom: footer.bottom,
configureY: configure.y,
configureHeight: configure.height,
configureBottom: configure.bottom,
forgetY: forget.y,
forgetHeight: forget.height,
};
});
const scrollport = targets.closest("main")!.getBoundingClientRect();
return {
basic: { x, y, width, height },
vms,
targets: {
x: targets.getBoundingClientRect().x,
y: targets.getBoundingClientRect().y,
width: targets.clientWidth,
},
scrollport: { top: scrollport.top, bottom: scrollport.bottom },
overflow: targets.scrollWidth > targets.clientWidth + 1,
};
});
expect(layout.overflow).toBe(false);
expect(Math.abs(layout.basic.x - layout.targets.x)).toBeLessThan(1);
expect(Math.abs(layout.basic.y - layout.targets.y)).toBeLessThan(1);
if (!layout.vms.length) {
expect(Math.abs(layout.basic.width - layout.targets.width)).toBeLessThan(1);
}
for (const card of [layout.basic, ...layout.vms]) {
for (const coordinate of ["y", "width", "height"] as const) {
expect(
Math.abs(card[coordinate] - layout.basic[coordinate]),
`Location card ${coordinate}`,
).toBeLessThan(1);
}
expect(card.y).toBeGreaterThanOrEqual(layout.scrollport.top);
expect(card.y + card.height).toBeLessThanOrEqual(layout.scrollport.bottom);
}
for (const [index, vm] of layout.vms.entries()) {
const previous = index === 0 ? layout.basic : layout.vms[index - 1]!;
expect(vm.x).toBeGreaterThan(previous.x + previous.width);
expect(vm.x + vm.width).toBeLessThanOrEqual(layout.targets.x + layout.targets.width + 1);
expect(Math.abs(vm.configureY - vm.forgetY)).toBeLessThan(1);
expect(Math.abs(vm.configureHeight - vm.forgetHeight)).toBeLessThan(1);
expect(vm.configureY).toBeGreaterThanOrEqual(vm.y);
expect(vm.configureBottom).toBeLessThanOrEqual(vm.y + vm.height);
expect(vm.footerBottom).toBeLessThanOrEqual(vm.y + vm.height);
for (const coordinate of [
"footerBottom",
"configureY",
"configureHeight",
"configureBottom",
] as const) {
expect(
Math.abs(vm[coordinate] - layout.vms[0]![coordinate]),
`VM actions ${coordinate}`,
).toBeLessThan(1);
}
}
const last = layout.vms.at(-1) ?? layout.basic;
expect(Math.abs(last.x + last.width - layout.targets.x - layout.targets.width)).toBeLessThan(1);
}

export async function runExecutionProgressCase({
browser,
server,
Expand Down Expand Up @@ -243,6 +320,13 @@ export async function runExecutionProgressCase({
reducedMotion: reducedMotion ? "reduce" : "no-preference",
serviceWorkers: "block",
viewport: { width: 1440, height: 1000 },
recordVideo:
process.env.OPENCLAW_CAPTURE_UI_PROOF === "1" && family === "platformclaw"
? {
dir: ".artifacts/control-ui-e2e/coding-agent-settings/multi-vm-video",
size: { width: 1440, height: 1000 },
}
: undefined,
});
const page = await context.newPage();
const labels = [
Expand Down Expand Up @@ -365,12 +449,14 @@ export async function runExecutionProgressCase({
const currentLocation = component.locator("[data-current-location]");
const currentTarget = currentLocation.locator("[data-current-target]");
await expect.poll(() => currentTarget.textContent()).toContain(basic);
expect((await badge.textContent())?.trim()).toBe(copy.workLocation);
expect((await badge.locator(".label").textContent())?.trim()).toBe(copy.workLocation);
await badge.click();
await expect
.poll(() => component.getByRole("dialog", { name: copy.settings, exact: true }).isVisible())
.toBe(true);
await captureDialogIdentity(component, "settings");
await assertLocationCardAlignment(component);
await screenshot(page, `multi-vm-${family}-${mode}-empty.png`);
expect(
await currentLocation.locator("[data-target='platform_server']").getAttribute("aria-pressed"),
).toBe("true");
Expand Down Expand Up @@ -419,7 +505,7 @@ export async function runExecutionProgressCase({
.poll(() => upper.locator("[data-progress-panel]").getAttribute("data-phase"))
.toBe("error");
expect(await currentTarget.textContent()).toContain(from);
expect((await badge.textContent())?.trim()).toBe(copy.workLocation);
expect((await badge.locator(".label").textContent())?.trim()).toBe(copy.workLocation);
expect(
await upper.getByRole("heading", { name: copy.failure, exact: true }).isVisible(),
).toBe(true);
Expand All @@ -443,13 +529,17 @@ export async function runExecutionProgressCase({
).toBe(true);
await assertExecutionProgressLayout(component);
expect(await badge.getAttribute("aria-busy")).toBe("false");
expect((await badge.textContent())?.trim()).toBe(copy.workLocation);
expect((await badge.locator(".label").textContent())?.trim()).toBe(copy.workLocation);
await screenshot(page, `multi-vm-${family}-${mode}-${requests.length}.png`);
await expect
.poll(() => upper.locator("dialog").evaluate((node) => (node as HTMLDialogElement).open))
.toBe(false);
await assertDialogIdentity(component, "settings");
await assertDialogIdentity(component, "progress", false);
await assertLocationCardAlignment(component);
if (registration) {
await screenshot(page, `multi-vm-${family}-${mode}-registered-${saved.length}.png`);
}
expect(
await component.locator("[data-settings-modal] main").evaluate((node) => node.scrollTop),
).toBe(0);
Expand Down Expand Up @@ -499,8 +589,9 @@ export async function runExecutionProgressCase({
for (const destination of [0, 1, 2, 0, -1, 1]) {
await switchTo(destination);
}
// Preserve desktop matrix proof and narrow-screen switching without repeating the full matrix.
await page.setViewportSize({ width: 390, height: 844 });
// Keep failure/retry proof on the same desktop row as the direct switches.
await assertLocationCardAlignment(component);
await screenshot(page, `multi-vm-${family}-${mode}-desktop-row.png`);
failNextSwitch = family === "platformclaw";
for (const destination of [0, -1]) {
await switchTo(destination);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/e2e/platformclaw-adapter.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ describeControlUiE2e("PlatformClaw Control UI adapter mocked Gateway E2E", () =>
});

await page.goto(`${server.baseUrl}platformclaw/app/chat`);
const quickActions = page.locator("platformclaw-quick-actions:not([location-only])");
const quickActions = page.locator("platformclaw-quick-actions");
await expect.poll(() => quickActions.isVisible()).toBe(true);
await expect
.poll(() => quickActions.getByRole("button", { name: "VOC" }).isVisible())
Expand Down
2 changes: 1 addition & 1 deletion ui/src/e2e/platformclaw-execution-settings.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ suite("PlatformClaw coding agent settings", () => {
await expect
.poll(() => component.locator("[data-current-target]").textContent())
.toContain("Development VM");
expect((await component.locator("[data-action='open']").textContent())?.trim()).toBe(
expect((await component.locator("[data-action='open'] .label").textContent())?.trim()).toBe(
"Work location",
);
await component.locator("[data-target='platform_server']").click();
Expand Down
95 changes: 69 additions & 26 deletions ui/src/e2e/platformclaw-selected-location.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { mkdir } from "node:fs/promises";
import path from "node:path";
import type { Locator, Page, Route } from "playwright";
import { expect, it } from "vitest";
import type { ExecutionSettings } from "../platformclaw/execution-settings-view.ts";
Expand All @@ -11,8 +13,10 @@ import { createControlUiE2eSuite } from "./control-ui-e2e-suite.test-support.ts"

const suite = createControlUiE2eSuite({
name: "PlatformClaw selected personal work location",
unavailableMessage: (path) => `Chromium cannot start at ${path}.`,
unavailableMessage: (executablePath) => `Chromium cannot start at ${executablePath}.`,
});
const captureProof = process.env.OPENCLAW_CAPTURE_UI_PROOF === "1";
const proofDir = ".artifacts/control-ui-e2e/coding-agent-settings/selected-location";

const settings: ExecutionSettings = {
activeTarget: "platform_server",
Expand All @@ -22,7 +26,7 @@ const settings: ExecutionSettings = {
accountId: "person.one",
availableVms: [
{ id: "synthetic-vm-one", label: "Build VM" },
{ id: "synthetic-vm-two", label: "Test VM" },
{ id: "synthetic-vm-two", label: "Test VM with a deliberately long environment name" },
],
savedVms: [
{
Expand All @@ -37,7 +41,7 @@ const settings: ExecutionSettings = {
{
id: "connection-two",
vmHostId: "synthetic-vm-two",
vmLabel: "Test VM",
vmLabel: "Test VM with a deliberately long environment name",
safeConnectLabel: "Synthetic connector",
linuxAccount: "person.one",
status: "ready",
Expand Down Expand Up @@ -74,19 +78,18 @@ function savedVmsForTarget(

suite.define(() => {
it.each(["platform_server", "assigned_vm"] as const)(
"keeps the member's selected %s visible on mobile and preserves the draft when switching",
"keeps the selected %s inside the work-location button and preserves the draft when switching",
async (target) => {
const context = await suite.newBrowserContext({
locale: "en-US",
viewport: { width: 390, height: 844 },
serviceWorkers: "block",
recordVideo:
process.env.OPENCLAW_CAPTURE_UI_PROOF === "1"
? {
dir: ".artifacts/control-ui-e2e/selected-location",
size: { width: 390, height: 844 },
}
: undefined,
recordVideo: captureProof
? {
dir: path.join(proofDir, "video"),
size: { width: 390, height: 844 },
}
: undefined,
});
const page = await context.newPage();
let current: ExecutionSettings = {
Expand Down Expand Up @@ -162,43 +165,77 @@ suite.define(() => {
};
try {
const gateway = await openChat(page);
const indicator = page
.locator("platformclaw-quick-actions[location-only]")
.getByRole("status");
const assertLocation = async (status: Locator, label: string, width: number) => {
const composer = page.locator(".agent-chat__composer-combobox textarea");
await composer.fill("Keep this draft while checking work location");
await page
.locator(".topbar-nav-toggle:visible, .chat-pane__nav-toggle:visible")
.first()
.click();
const mobileLauncher = page
.locator("platformclaw-quick-actions")
.getByRole("button", { name: "Open work location settings", exact: true });
const capture = async (targetPage: Page, stage: string) => {
if (captureProof) {
await mkdir(proofDir, { recursive: true });
await targetPage.screenshot({
animations: "disabled",
path: path.join(proofDir, `${target}-${stage}.png`),
});
}
};
const assertLocation = async (button: Locator, label: string, width: number) => {
const status = button.locator("[data-location-status][role='status']");
const selected = `Selected location: ${label}`;
await expect.poll(() => button.isVisible()).toBe(true);
expect((await button.locator(".label").textContent())?.trim()).toBe("Work location");
await expect.poll(() => status.getAttribute("aria-label")).toBe(selected);
await expect.poll(async () => (await status.textContent())?.trim()).toBe(selected);
expect(await status.getAttribute("title")).toContain(`${selected}.`);
const bounds = await status.boundingBox();
const buttonBounds = await button.boundingBox();
expect(bounds).not.toBeNull();
expect(buttonBounds).not.toBeNull();
expect(bounds!.x).toBeGreaterThanOrEqual(0);
expect(bounds!.x + bounds!.width).toBeLessThanOrEqual(width);
expect(bounds!.x).toBeGreaterThanOrEqual(buttonBounds!.x);
expect(bounds!.x + bounds!.width).toBeLessThanOrEqual(
buttonBounds!.x + buttonBounds!.width,
);
expect(bounds!.y).toBeGreaterThanOrEqual(buttonBounds!.y);
expect(bounds!.y + bounds!.height).toBeLessThanOrEqual(
buttonBounds!.y + buttonBounds!.height,
);
};
await assertLocation(
indicator,
mobileLauncher,
target === "platform_server" ? "Basic server" : "Build VM",
390,
);
const composer = page.locator(".agent-chat__composer-combobox textarea");
await composer.fill("Keep this draft while checking work location");
expect(await page.locator("platformclaw-quick-actions[location-only]").count()).toBe(0);
await capture(page, "mobile-initial");
const secondPage = await context.newPage();
await secondPage.setViewportSize({ width: 1440, height: 900 });
const secondGateway = await openChat(secondPage);
const launcher = secondPage
.locator("platformclaw-quick-actions:not([location-only])")
.locator("platformclaw-quick-actions")
.getByRole("button", { name: "Open work location settings", exact: true });
expect((await launcher.textContent())?.trim()).toBe("Work location");
await assertLocation(
launcher,
target === "platform_server" ? "Basic server" : "Build VM",
1440,
);
expect(await secondPage.locator("platformclaw-quick-actions[location-only]").count()).toBe(
0,
);
await capture(secondPage, "desktop-initial");
await launcher.click();
const dialog = secondPage.getByRole("dialog", {
name: "Work environment settings",
exact: true,
});
await dialog.waitFor();
const component = secondPage.locator("platformclaw-execution-settings");
const secondIndicator = secondPage
.locator("platformclaw-quick-actions[location-only]")
.getByRole("status");
expect(await component.locator("[data-action='open']").count()).toBe(0);
for (const change of expectedChanges) {
await secondPage.bringToFront();
// Saved VM selection must identify the registration, not the shared assigned_vm target.
Expand All @@ -212,19 +249,25 @@ suite.define(() => {
const label = change.connectionId
? settings.savedVms.find((vm) => vm.id === change.connectionId)!.vmLabel
: "Basic server";
await assertLocation(secondIndicator, label, 1440);
await assertLocation(launcher, label, 1440);
await expect
.poll(() =>
component
.locator("[data-progress-modal] dialog")
.evaluate((node) => (node as HTMLDialogElement).open),
)
.toBe(false);
expect((await launcher.textContent())?.trim()).toBe("Work location");
expect((await launcher.locator(".label").textContent())?.trim()).toBe("Work location");
await page.bringToFront();
await assertLocation(indicator, label, 390);
await assertLocation(mobileLauncher, label, 390);
await capture(page, `mobile-switch-${changes.length}`);
expect(await composer.inputValue()).toBe("Keep this draft while checking work location");
}
await secondPage.bringToFront();
await component.locator("[data-action='close']").click();
await dialog.waitFor({ state: "hidden" });
await assertLocation(launcher, settings.savedVms[1]!.vmLabel, 1440);
await capture(secondPage, "desktop-final");
expect(changes).toEqual(expectedChanges);
expect(await gateway.getRequests("chat.send")).toHaveLength(0);
expect(await gateway.getRequests("sessions.patch")).toHaveLength(0);
Expand Down
Loading
Loading