mirror of
https://github.com/getpaseo/paseo.git
synced 2026-08-14 20:32:46 +00:00
The file explorer had a useEffect that re-enforced expansion of every ancestor of `selectedEntryPath` whenever `expandedPaths` changed. As a result, the moment a user collapsed the parent folder of a file they had just opened, the effect re-added that folder to the expanded set and the folder appeared stuck open. Selection and expansion are orthogonal: clicking a file should not dictate that its parent folder stays open forever. There is also no current caller that sets `selectedEntryPath` from outside the tree, so the reveal-on-external-selection use case the effect was designed for is unused. Delete the effect and its two now-dead helpers. If a future "Reveal in Explorer" action is introduced, it can expand ancestors at the call site. Adds an E2E regression test that reproduces the original scenario: expand a folder, open an image, collapse the parent folder, assert children are hidden. Also asserts an unrelated sibling folder still expands after the image is open, guarding against any future regression that makes the bug global.
62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import { test } from "./fixtures";
|
|
import {
|
|
collapseFolder,
|
|
expandFolder,
|
|
expectExplorerEntryHidden,
|
|
expectExplorerEntryVisible,
|
|
expectFileTabOpen,
|
|
openFileExplorer,
|
|
openFileFromExplorer,
|
|
} from "./helpers/file-explorer";
|
|
import { gotoWorkspace } from "./helpers/launcher";
|
|
import { createTempGitRepo } from "./helpers/workspace";
|
|
import {
|
|
connectWorkspaceSetupClient,
|
|
type WorkspaceSetupDaemonClient,
|
|
} from "./helpers/workspace-setup";
|
|
|
|
let tempRepo: { path: string; cleanup: () => Promise<void> };
|
|
let workspaceId: string;
|
|
let seedClient: WorkspaceSetupDaemonClient;
|
|
|
|
test.beforeAll(async () => {
|
|
tempRepo = await createTempGitRepo("file-explorer-collapse-", {
|
|
files: [
|
|
{ path: "assets/logo.png", content: "image bytes for explorer e2e\n" },
|
|
{ path: "docs/guide.md", content: "# Guide\n" },
|
|
],
|
|
});
|
|
seedClient = await connectWorkspaceSetupClient();
|
|
const result = await seedClient.openProject(tempRepo.path);
|
|
if (!result.workspace) {
|
|
throw new Error(result.error ?? "Failed to seed workspace");
|
|
}
|
|
workspaceId = String(result.workspace.id);
|
|
});
|
|
|
|
test.afterAll(async () => {
|
|
await seedClient?.close();
|
|
await tempRepo?.cleanup();
|
|
});
|
|
|
|
test.describe("File explorer collapse", () => {
|
|
test("collapses an opened image file parent folder and still expands other folders", async ({
|
|
page,
|
|
}) => {
|
|
await gotoWorkspace(page, workspaceId);
|
|
await openFileExplorer(page);
|
|
|
|
await expandFolder(page, "assets");
|
|
await expectExplorerEntryVisible(page, "logo.png");
|
|
|
|
await openFileFromExplorer(page, "logo.png");
|
|
await expectFileTabOpen(page, "assets/logo.png");
|
|
|
|
await collapseFolder(page, "assets");
|
|
await expectExplorerEntryHidden(page, "logo.png");
|
|
|
|
await expandFolder(page, "docs");
|
|
await expectExplorerEntryVisible(page, "guide.md");
|
|
});
|
|
});
|