дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
When the recent list holds remote projects, Welcome › Projects, the Recent Projects popup, the title-bar Project Widget's Recent Projects and File › Open Recent group them under Local and each remote target (SSH · host, WSL · distro, Dev Container · folder), most recently used first, with collapsible groups and the per-row host pill dropped inside a host group; search flattens the groups again. Local-only lists are unchanged. Recent list rows now take their natural height, so two- and three-line remote rows no longer overlap in the popup's virtualized list. Co-authored-by: dengliu <[email protected]>
120 рядки
4.9 KiB
TypeScript
120 рядки
4.9 KiB
TypeScript
import { expect, stubDesktop, test } from "./fixtures";
|
||
|
||
test("groups recent projects by Local and remote host across Welcome, Recent Projects, and Project Popup without row overlap", async ({
|
||
workbench: page,
|
||
}) => {
|
||
await page.setViewportSize({ width: 980, height: 740 });
|
||
await stubDesktop(page);
|
||
|
||
await page.evaluate(async () => {
|
||
const localProjects = [
|
||
{ path: "/Users/dev/git/gocommon", name: "gocommon", openedAtMs: 70_000, branch: "main" },
|
||
{ path: "/Users/dev/git/openidea_all", name: "openidea_all", openedAtMs: 40_000, branch: null },
|
||
{ path: "/Users/dev/git/superpowers", name: "superpowers", openedAtMs: 20_000, branch: "main" },
|
||
];
|
||
const remoteProjects = [
|
||
{
|
||
target: { kind: "ssh", config: "devbox" },
|
||
path: "/home/coder/git/openidea_all",
|
||
name: "openidea_all",
|
||
host: "[email protected]:22",
|
||
openedAtMs: 100_000,
|
||
},
|
||
{
|
||
target: { kind: "ssh", config: "mbp1" },
|
||
path: "/Users/dev/git/gocommon",
|
||
name: "gocommon",
|
||
host: "dev-mbp1.local",
|
||
openedAtMs: 90_000,
|
||
},
|
||
{
|
||
target: { kind: "ssh", config: "devbox" },
|
||
path: "/home/coder/git/gocommon",
|
||
name: "gocommon",
|
||
host: "[email protected]:22",
|
||
openedAtMs: 60_000,
|
||
},
|
||
{
|
||
target: { kind: "wsl", distro: "Ubuntu-24.04" },
|
||
path: "/home/dev/git/openidea_all",
|
||
name: "openidea_all",
|
||
host: "Ubuntu-24.04",
|
||
openedAtMs: 30_000,
|
||
},
|
||
];
|
||
localStorage.setItem("openidea.remote.recent", JSON.stringify(remoteProjects));
|
||
|
||
window.__ipc.handlers.recent_projects = () => localProjects;
|
||
window.__ipc.handlers.recent_project_groups = () => [];
|
||
window.__ipc.handlers.app_info = () => ({ version: "0.1.55" });
|
||
window.__ipc.handlers.window_open_projects = () => [
|
||
{ name: "openidea_all", root: "/Users/dev/git/openidea_all", current: true, remote: null },
|
||
{
|
||
name: "openidea_all",
|
||
root: "/home/coder/git/openidea_all",
|
||
current: false,
|
||
remote: { kind: "ssh", config: "devbox" },
|
||
},
|
||
];
|
||
|
||
const projectMod = "/src/platform/project.ts";
|
||
const recentMod = "/src/features/welcome/recent.ts";
|
||
const { useProject } = await import(/* @vite-ignore */ projectMod);
|
||
const { loadRecent, useRecent } = await import(/* @vite-ignore */ recentMod);
|
||
await loadRecent();
|
||
useRecent.setState({ home: "/Users/dev" });
|
||
const prev = useProject.getState().project;
|
||
if (prev) {
|
||
useProject.setState({
|
||
project: { ...prev, name: "openidea_all", displayName: "openidea_all", root: "/Users/dev/git/openidea_all" },
|
||
});
|
||
}
|
||
});
|
||
|
||
// 1. Project Widget dropdown keeps Open Projects flat and groups Recent Projects by host.
|
||
await page.getByRole("button", { name: "openidea_all" }).click();
|
||
const projectPopup = page.getByRole("dialog", { name: "Projects" });
|
||
await expect(projectPopup).toBeVisible();
|
||
await expect(projectPopup).toContainText("Open Projects");
|
||
await expect(projectPopup).toContainText("Recent Projects");
|
||
await expect(projectPopup).toContainText("dev-mbp1.local");
|
||
await expect(projectPopup).toContainText("Local");
|
||
await expect(projectPopup).toContainText("Ubuntu-24.04");
|
||
await page.keyboard.press("Escape");
|
||
await expect(projectPopup).toBeHidden();
|
||
|
||
// 2. Recent Projects popup groups by host and never overlaps rows (grouped or 3-line search results).
|
||
await page.evaluate(async () => {
|
||
const popupMod = "/src/features/welcome/RecentProjectsPopup.tsx";
|
||
const { showRecentProjectsPopup } = await import(/* @vite-ignore */ popupMod);
|
||
showRecentProjectsPopup();
|
||
});
|
||
const recentDialog = page.getByRole("dialog", { name: "Recent Projects" });
|
||
await expect(recentDialog).toBeVisible();
|
||
const assertNoVerticalOverlap = async () => {
|
||
const options = recentDialog.getByRole("option");
|
||
const count = await options.count();
|
||
expect(count).toBeGreaterThan(1);
|
||
const boxes = await Promise.all(Array.from({ length: count }, (_, i) => options.nth(i).boundingBox()));
|
||
for (let i = 1; i < boxes.length; i++) {
|
||
expect(boxes[i]!.y).toBeGreaterThanOrEqual(boxes[i - 1]!.y + boxes[i - 1]!.height - 0.5);
|
||
}
|
||
};
|
||
await assertNoVerticalOverlap();
|
||
await recentDialog.getByRole("textbox", { name: "Search recent projects" }).fill("openidea_all");
|
||
await assertNoVerticalOverlap();
|
||
await page.keyboard.press("Escape");
|
||
await expect(recentDialog).toBeHidden();
|
||
|
||
// 3. Welcome › Projects folds and unfolds host groups.
|
||
await page.evaluate(async () => {
|
||
const projectMod = "/src/platform/project.ts";
|
||
const { useProject } = await import(/* @vite-ignore */ projectMod);
|
||
useProject.setState({ project: null, lightEdit: false });
|
||
});
|
||
const welcomeList = page.getByRole("listbox", { name: "Recent projects" });
|
||
await expect(welcomeList.getByRole("option")).toHaveCount(11);
|
||
await welcomeList.getByRole("option").first().click();
|
||
await expect(welcomeList.getByRole("option")).toHaveCount(9);
|
||
});
|