mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-22 19:49:35 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
679c905621 |
No files matched your search
@@ -320,3 +320,88 @@ test("the Paths filter replaces the repository filter and can be cleared from ov
|
||||
await picker.getByRole("button", { name: "OK" }).click();
|
||||
await expect(firstCommit.getByText("Commit 1", { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("the Git Log path tree resizes and keeps selected paths reachable in a short window", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1000, height: 720 });
|
||||
const longName = "reconcile-invoices-and-export-the-complete-quarterly-settlement-audit.ts";
|
||||
await page.evaluate(async (longName) => {
|
||||
const logPath = "/src/features/vcs/logStore.ts";
|
||||
const optionsPath = "/src/features/vcs/logOptions.ts";
|
||||
const { setLogFilters } = await import(/* @vite-ignore */ logPath);
|
||||
const { setLogOptions } = await import(/* @vite-ignore */ optionsPath);
|
||||
const root = "/dev/acme-api";
|
||||
const selected = Array.from({ length: 9 }, (_, i) => `entry-${i + 1}.ts`);
|
||||
const entry = (name: string, kind: "dir" | "file") => ({
|
||||
name,
|
||||
path: `${root}/${name}`,
|
||||
kind,
|
||||
size: 0,
|
||||
mtimeMs: 0,
|
||||
});
|
||||
window.__ipc.handlers.fs_read_dir = ({ path }) =>
|
||||
path === root
|
||||
? [entry("src", "dir"), entry(longName, "file"), ...selected.map((name) => entry(name, "file"))]
|
||||
: [];
|
||||
setLogOptions({ showBranches: false, showDetails: false });
|
||||
setLogFilters({ paths: selected.map((name) => `${root}/${name}`) });
|
||||
}, longName);
|
||||
|
||||
const toolbar = page.getByRole("toolbar", { name: "Log filters" });
|
||||
const openTree = async () => {
|
||||
await toolbar.getByRole("button", { name: "More Filters" }).click();
|
||||
await page.getByRole("menuitem", { name: /^Paths:/ }).click();
|
||||
await page.getByRole("menuitem", { name: "Select in Tree…" }).click();
|
||||
};
|
||||
await openTree();
|
||||
const dialog = page.getByRole("dialog", { name: "Filter by Paths" });
|
||||
const tree = dialog.getByRole("tree", { name: "Files and folders" });
|
||||
const resize = dialog.locator('[class*="_resizeGrip_"]');
|
||||
await expect(tree).toBeVisible();
|
||||
await expect(resize).toBeVisible();
|
||||
await tree.getByRole("treeitem", { name: "acme-api", exact: true }).locator("[data-tree-toggle]").click();
|
||||
const folder = tree.getByRole("checkbox", { name: "src", exact: true });
|
||||
const file = tree.getByRole("checkbox", { name: longName, exact: true });
|
||||
await expect(folder.locator("xpath=ancestor::label").locator("svg")).toHaveCount(1);
|
||||
const title = file.locator("xpath=ancestor::label").getByTitle(longName);
|
||||
await expect(title).toHaveCSS("font-size", "13px");
|
||||
await expect(title).toHaveCSS("text-overflow", "ellipsis");
|
||||
|
||||
const originalTreeHeight = (await tree.boundingBox())!.height;
|
||||
const grip = (await resize.boundingBox())!;
|
||||
const x = grip.x + grip.width / 2;
|
||||
const y = grip.y + grip.height / 2;
|
||||
await page.mouse.move(x, y);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x + 30, y + 65, { steps: 5 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(async () => (await tree.boundingBox())!.height).toBeGreaterThan(originalTreeHeight + 40);
|
||||
|
||||
await dialog.getByRole("button", { name: "Cancel" }).click();
|
||||
await page.setViewportSize({ width: 420, height: 325 });
|
||||
await openTree();
|
||||
await tree.getByRole("treeitem", { name: "acme-api", exact: true }).locator("[data-tree-toggle]").click();
|
||||
const selected = dialog.getByRole("group", { name: "Selected paths" });
|
||||
await expect(selected).toBeVisible();
|
||||
await expect.poll(() => selected.evaluate((node) => node.scrollHeight - node.clientHeight)).toBeGreaterThan(1);
|
||||
await expect
|
||||
.poll(() => dialog.locator("[data-dialog-body]").evaluate((node) => node.scrollHeight - node.clientHeight))
|
||||
.toBeLessThanOrEqual(1);
|
||||
await expect.poll(() => title.evaluate((node) => node.scrollWidth - node.clientWidth)).toBeGreaterThan(1);
|
||||
const removed = selected.getByRole("checkbox", { name: "acme-api/entry-9.ts", exact: true });
|
||||
await removed.click();
|
||||
await expect(removed).toHaveCount(0);
|
||||
await file.check();
|
||||
await expect(selected.getByRole("checkbox", { name: `acme-api/${longName}`, exact: true })).toBeChecked();
|
||||
await expect(dialog.getByRole("button", { name: "OK" })).toBeInViewport({ ratio: 1 });
|
||||
await dialog.getByRole("button", { name: "OK" }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
const applied = await page.evaluate(async () => {
|
||||
const path = "/src/features/vcs/logStore.ts";
|
||||
const { useGitLog } = await import(/* @vite-ignore */ path);
|
||||
return useGitLog.getState().filters.paths;
|
||||
});
|
||||
expect(applied).toContain(`/dev/acme-api/${longName}`);
|
||||
expect(applied).not.toContain("/dev/acme-api/entry-9.ts");
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
.chooser > [data-dialog-body] {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-2) var(--space-4) 0;
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.tree {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-small);
|
||||
background: var(--bg-input);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.choice {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.entry {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.entry svg {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.path {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.selected {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 0 1 auto;
|
||||
min-height: 0;
|
||||
max-height: min(96px, 33%);
|
||||
padding-inline: var(--space-2);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.selected .choice {
|
||||
flex: none;
|
||||
min-height: var(--h-list-row);
|
||||
}
|
||||
|
||||
.error {
|
||||
max-height: 25%;
|
||||
overflow: auto;
|
||||
overflow-wrap: anywhere;
|
||||
color: var(--danger);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { Checkbox, Dialog, SearchField, Tree } from "@/ui";
|
||||
import { Checkbox, Dialog, Icon, SearchField, Tree, fileIconName } from "@/ui";
|
||||
import { projectFs } from "@/features/project-tree/fs";
|
||||
import { openDialog } from "./dialogs";
|
||||
import { dirName, relTo, stripSlash } from "./model";
|
||||
@@ -7,6 +7,7 @@ import { repoName, repoOf } from "./store";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { ipcPath, isSameOrInside } from "@/platform/paths";
|
||||
import styles from "./PathFilterDialog.module.css";
|
||||
|
||||
interface PathNode {
|
||||
path: string;
|
||||
@@ -167,15 +168,21 @@ function PathFilterDialog({
|
||||
<Dialog
|
||||
open
|
||||
title="Filter by Paths"
|
||||
width={560}
|
||||
className={styles.chooser}
|
||||
width={432}
|
||||
initialSize={{ w: 432, h: 392 }}
|
||||
resizable="both"
|
||||
minWidth={300}
|
||||
minHeight={220}
|
||||
onClose={() => onDone(null)}
|
||||
buttons={[
|
||||
{ label: "OK", role: "default", onClick: () => onDone([...checked]) },
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
]}
|
||||
>
|
||||
<div style={{ height: 320 }}>
|
||||
<div className={styles.content}>
|
||||
<Tree<PathNode>
|
||||
className={styles.tree}
|
||||
roots={nodes}
|
||||
getKey={(n) => n.path}
|
||||
getLabel={(n) => n.name}
|
||||
@@ -183,21 +190,49 @@ function PathFilterDialog({
|
||||
isExpandable={(n) => n.directory}
|
||||
loadChildren={load}
|
||||
renderNode={(n) => (
|
||||
<Checkbox label={n.name} checked={checked.has(n.path)} onChange={(on) => toggle(n.path, on)} />
|
||||
<Checkbox
|
||||
className={styles.choice}
|
||||
label={
|
||||
<span className={styles.entry}>
|
||||
<Icon name={n.directory ? "folder" : fileIconName(n.name, n.path)} size={16} />
|
||||
<span className={styles.path} title={n.name}>
|
||||
{n.name}
|
||||
</span>
|
||||
</span>
|
||||
}
|
||||
checked={checked.has(n.path)}
|
||||
onChange={(on) => toggle(n.path, on)}
|
||||
/>
|
||||
)}
|
||||
aria-label="Files and folders"
|
||||
/>
|
||||
{checked.size > 0 && (
|
||||
<div className={styles.selected} role="group" aria-label={tx("Selected paths")}>
|
||||
{[...checked].map((path) => {
|
||||
const root = roots.includes(path) ? path : repoOf(path, roots);
|
||||
const label = root ? (path === root ? repoName(root) : `${repoName(root)}/${relTo(root, path)}`) : path;
|
||||
return (
|
||||
<Checkbox
|
||||
key={path}
|
||||
className={styles.choice}
|
||||
label={
|
||||
<span className={styles.path} title={label}>
|
||||
{label}
|
||||
</span>
|
||||
}
|
||||
checked
|
||||
onChange={(on) => toggle(path, on)}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{error && (
|
||||
<div className={styles.error} role="alert">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{checked.size > 0 && (
|
||||
<div style={{ maxHeight: 100, overflow: "auto" }} aria-label="Selected paths">
|
||||
{[...checked].map((path) => {
|
||||
const root = roots.includes(path) ? path : repoOf(path, roots);
|
||||
const label = root ? (path === root ? repoName(root) : `${repoName(root)}/${relTo(root, path)}`) : path;
|
||||
return <Checkbox key={path} label={label} checked onChange={(on) => toggle(path, on)} />;
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{error && <div role="alert">{error}</div>}
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user