diff --git a/ui/src/components/WorkFolderBrowser.selection.test.tsx b/ui/src/components/WorkFolderBrowser.selection.test.tsx index 7f1904cf2d..ab5355ebe2 100644 --- a/ui/src/components/WorkFolderBrowser.selection.test.tsx +++ b/ui/src/components/WorkFolderBrowser.selection.test.tsx @@ -6,8 +6,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { TooltipProvider } from "@/components/ui/tooltip"; import { WorkFolderBrowser } from "./WorkFolderBrowser"; -const api = vi.hoisted(() => ({ list: vi.fn(), sync: vi.fn(), operation: vi.fn() })); +const api = vi.hoisted(() => ({ list: vi.fn(), sync: vi.fn(), operation: vi.fn(), preview: vi.fn(), downloadUrl: vi.fn() })); vi.mock("@/api/work-folders", () => ({ workFoldersApi: api })); +vi.mock("@/components/FileViewerSheet", () => ({ FileContentViewer: ({ content }: { content: { content: { data: string } } }) =>
{content.content.data} }));
const owner = { companyId: "company", scope: "task" as const, ownerId: "task" };
const a = { id: "a", path: "a.txt", kind: "file" };
const b = { id: "b", path: "b.txt", kind: "file" };
@@ -29,6 +30,8 @@ beforeEach(async () => {
active = [a, b]; deleted = [];
api.list.mockImplementation(async (_owner, trash) => ({ files: [...(trash ? deleted : active)] }));
api.sync.mockResolvedValue([]);
+ api.preview.mockImplementation(async (_owner, file) => ({ content: { data: `contents of ${file.path}` } }));
+ api.downloadUrl.mockReturnValue("/download");
api.operation.mockImplementation(async (_owner, operation) => {
if (operation.action === "delete") {
deleted.push(...active.filter((file) => file.path === operation.path));
@@ -49,6 +52,24 @@ afterEach(async () => {
await act(async () => root.unmount()); client.clear(); container.remove(); vi.clearAllMocks();
});
describe("cached file selection and retained trash", () => {
+ it("does not flash an old preview error while retrying a cached file", async () => {
+ const row = (path: string) => container.querySelectorLoading preview…
: preview.error ?{preview.error.message}
: preview.data ? + {preview.isLoading || (preview.isFetching && preview.isError) ?Loading preview…
: preview.error ?{preview.error.message}
: preview.data ?Select a file to preview it.
} }