mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
The changelist form stacked small labels above each field and left room for only three lines of comments. The Name and Comment labels now sit beside a shared field column at the workbench UI size. The comment field starts at four lines, and the fields stack on narrow windows. The same form is available when creating, editing or moving changes to a new list.
114 lines
5.3 KiB
TypeScript
114 lines
5.3 KiB
TypeScript
import type { Page } from "@playwright/test";
|
|
import type { ChangelistState } from "../src/bindings";
|
|
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
|
|
|
async function action(page: Page, id: string, arg?: string[]) {
|
|
await page.evaluate(
|
|
async ({ id, arg }) => {
|
|
const actions = "/src/platform/actions.ts";
|
|
const { executeAction } = await import(/* @vite-ignore */ actions);
|
|
await executeAction(id, arg);
|
|
},
|
|
{ id, arg },
|
|
);
|
|
}
|
|
|
|
async function savedLists(page: Page) {
|
|
const last = (await ipcCalls(page, "vcs_changelists_save")).at(-1);
|
|
return last?.changelists as ChangelistState | undefined;
|
|
}
|
|
|
|
test("changelist forms align the fields and preserve multiline comments through create, edit and move", async ({
|
|
workbench: page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 1100, height: 700 });
|
|
await stubDesktop(page);
|
|
await page.evaluate(async () => {
|
|
const root = "/dev/acme-api";
|
|
const vcsModule = "/src/features/vcs/store.ts";
|
|
const { useVcs } = await import(/* @vite-ignore */ vcsModule);
|
|
useVcs.setState({
|
|
available: true,
|
|
root,
|
|
repo: root,
|
|
roots: [root],
|
|
status: [{ path: root + "/build.gradle.kts", relPath: "build.gradle.kts", staged: null, unstaged: "modified" }],
|
|
});
|
|
const listModule = "/src/features/vcs/changelists.ts";
|
|
const { initialChangelists, useChangelists } = await import(/* @vite-ignore */ listModule);
|
|
useChangelists.setState({
|
|
state: { ...initialChangelists(), files: { "build.gradle.kts": "default" } },
|
|
loaded: true,
|
|
});
|
|
window.__ipc.handlers.vcs_changelists_save = () => null;
|
|
const context = "/src/platform/context.ts";
|
|
const { setContext } = await import(/* @vite-ignore */ context);
|
|
setContext("vcsAvailable", true);
|
|
});
|
|
|
|
await action(page, "vcs.changelist.new");
|
|
const create = page.getByRole("dialog", { name: "New Changelist", exact: true });
|
|
const name = create.getByRole("textbox", { name: "Name:", exact: true });
|
|
const comment = create.getByRole("textbox", { name: "Comment:", exact: true });
|
|
const ok = create.getByRole("button", { name: "OK", exact: true });
|
|
await expect(name).toBeFocused();
|
|
await expect(ok).toBeDisabled();
|
|
const nameLabel = (await create.getByText("Name:", { exact: true }).boundingBox())!;
|
|
const nameField = (await name.boundingBox())!;
|
|
expect(nameLabel.x + nameLabel.width).toBeLessThan(nameField.x);
|
|
const commentLabel = (await create.getByText("Comment:", { exact: true }).boundingBox())!;
|
|
const commentField = (await comment.boundingBox())!;
|
|
expect(Math.abs(nameField.x - commentField.x)).toBeLessThan(1);
|
|
expect(commentLabel.x + commentLabel.width).toBeLessThan(commentField.x);
|
|
expect(commentField.height).toBeGreaterThan(76);
|
|
await expect(create.getByText("Name:", { exact: true })).toHaveCSS(
|
|
"font-size",
|
|
await name.evaluate((el) => getComputedStyle(el).fontSize),
|
|
);
|
|
await name.fill("Changes");
|
|
await expect(name).toHaveAccessibleDescription(/already exists/);
|
|
await expect(ok).toBeDisabled();
|
|
|
|
await name.fill("Release review");
|
|
await comment.fill("Review the totals.\nAsk for a second check.");
|
|
await create.getByRole("checkbox", { name: "Set active" }).check();
|
|
await ok.click();
|
|
await expect
|
|
.poll(async () => {
|
|
const state = await savedLists(page);
|
|
return state?.lists.find((list) => list.id === state.active)?.comment;
|
|
})
|
|
.toBe("Review the totals.\nAsk for a second check.");
|
|
|
|
await action(page, "vcs.changelist.edit");
|
|
const edit = page.getByRole("dialog", { name: "Edit Changelist", exact: true });
|
|
await expect(edit.getByRole("textbox", { name: "Name:", exact: true })).toHaveValue("Release review");
|
|
const editComment = edit.getByRole("textbox", { name: "Comment:", exact: true });
|
|
await expect(editComment).toHaveValue("Review the totals.\nAsk for a second check.");
|
|
await expect(edit.getByRole("checkbox", { name: "Set active" })).toBeDisabled();
|
|
await editComment.fill("Review complete.\nReady for the release checklist.");
|
|
await edit.getByRole("button", { name: "OK", exact: true }).click();
|
|
await expect
|
|
.poll(async () => (await savedLists(page))?.lists.find((list) => list.name === "Release review")?.comment)
|
|
.toBe("Review complete.\nReady for the release checklist.");
|
|
|
|
await action(page, "vcs.changelist.move", ["/dev/acme-api/build.gradle.kts"]);
|
|
const move = page.getByRole("dialog", { name: "Move Changes to Another Changelist" });
|
|
await move.getByRole("radio", { name: "New changelist:" }).check();
|
|
await page.setViewportSize({ width: 400, height: 540 });
|
|
const newName = move.getByRole("textbox", { name: "Name:", exact: true });
|
|
const stackedName = (await newName.boundingBox())!;
|
|
const stackedLabel = (await move.getByText("Name:", { exact: true }).boundingBox())!;
|
|
expect(stackedLabel.y + stackedLabel.height).toBeLessThanOrEqual(stackedName.y);
|
|
expect(Math.abs(stackedLabel.x - stackedName.x)).toBeLessThan(1);
|
|
await newName.fill("Ready to ship");
|
|
await move.getByRole("textbox", { name: "Comment:", exact: true }).fill("Move the reviewed change here.");
|
|
await move.getByRole("button", { name: "OK", exact: true }).click();
|
|
await expect
|
|
.poll(async () => {
|
|
const state = await savedLists(page);
|
|
return state?.lists.find((list) => list.id === state.files?.["build.gradle.kts"])?.name;
|
|
})
|
|
.toBe("Ready to ship");
|
|
});
|