|
|
|
@ -10,6 +10,16 @@ vi.mock("@/utils/deduplicatedFetch", () => ({ |
|
|
|
clearFetchCache: vi.fn(), |
|
|
|
})); |
|
|
|
|
|
|
|
const mockLoadBrowserGenerationFile = vi.fn(); |
|
|
|
|
|
|
|
vi.mock("@/utils/browserFileSystem", () => ({ |
|
|
|
isBrowserFileSystemPath: (path: string | null | undefined) => |
|
|
|
typeof path === "string" && path.startsWith("browserfs://"), |
|
|
|
joinBrowserFileSystemPath: (basePath: string, folderName: string) => |
|
|
|
`${basePath.replace(/\/+$/, "")}/${encodeURIComponent(folderName)}`, |
|
|
|
loadBrowserGenerationFile: (...args: unknown[]) => mockLoadBrowserGenerationFile(...args), |
|
|
|
})); |
|
|
|
|
|
|
|
// Mock the workflow store
|
|
|
|
const mockUpdateNodeData = vi.fn(); |
|
|
|
const mockRegenerateNode = vi.fn(); |
|
|
|
@ -110,6 +120,7 @@ describe("GenerateImageNode", () => { |
|
|
|
decrementModalCount: mockDecrementModalCount, |
|
|
|
providerSettings: defaultProviderSettings, |
|
|
|
generationsPath: "/test/generations", |
|
|
|
saveDirectoryPath: null, |
|
|
|
isRunning: false, |
|
|
|
currentNodeIds: [], |
|
|
|
groups: {}, |
|
|
|
@ -406,6 +417,61 @@ describe("GenerateImageNode", () => { |
|
|
|
}); |
|
|
|
expect(mockFetch).not.toHaveBeenCalledWith("/api/load-generation", expect.anything()); |
|
|
|
}); |
|
|
|
|
|
|
|
it("should load carousel images from browser-local generations when only an id is stored", async () => { |
|
|
|
mockLoadBrowserGenerationFile.mockResolvedValueOnce("data:image/png;base64,browser-next"); |
|
|
|
mockUseWorkflowStore.mockImplementation((selector) => { |
|
|
|
const state = { |
|
|
|
updateNodeData: mockUpdateNodeData, |
|
|
|
regenerateNode: mockRegenerateNode, |
|
|
|
addNode: mockAddNode, |
|
|
|
incrementModalCount: mockIncrementModalCount, |
|
|
|
decrementModalCount: mockDecrementModalCount, |
|
|
|
providerSettings: defaultProviderSettings, |
|
|
|
generationsPath: null, |
|
|
|
saveDirectoryPath: "browserfs://root/project", |
|
|
|
isRunning: false, |
|
|
|
currentNodeIds: [], |
|
|
|
groups: {}, |
|
|
|
nodes: [], |
|
|
|
recentModels: [], |
|
|
|
trackModelUsage: vi.fn(), |
|
|
|
getNodesWithComments: vi.fn(() => []), |
|
|
|
markCommentViewed: vi.fn(), |
|
|
|
setNavigationTarget: vi.fn(), |
|
|
|
}; |
|
|
|
return selector(state); |
|
|
|
}); |
|
|
|
|
|
|
|
render( |
|
|
|
<TestWrapper> |
|
|
|
<GenerateImageNode {...createNodeProps({ |
|
|
|
outputImage: "data:image/png;base64,current", |
|
|
|
imageHistory: [ |
|
|
|
{ id: "img1", timestamp: Date.now(), prompt: "test1", aspectRatio: "1:1", model: "nano-banana" }, |
|
|
|
{ id: "img2", timestamp: Date.now(), prompt: "test2", aspectRatio: "1:1", model: "nano-banana" }, |
|
|
|
], |
|
|
|
selectedHistoryIndex: 0, |
|
|
|
})} /> |
|
|
|
</TestWrapper> |
|
|
|
); |
|
|
|
|
|
|
|
fireEvent.click(screen.getByTitle("Next image")); |
|
|
|
|
|
|
|
await waitFor(() => { |
|
|
|
expect(mockLoadBrowserGenerationFile).toHaveBeenCalledWith( |
|
|
|
"browserfs://root/project/generations", |
|
|
|
"img2" |
|
|
|
); |
|
|
|
expect(mockUpdateNodeData).toHaveBeenCalledWith("test-node-1", { |
|
|
|
outputImage: "data:image/png;base64,browser-next", |
|
|
|
selectedHistoryIndex: 1, |
|
|
|
status: "idle", |
|
|
|
error: null, |
|
|
|
}); |
|
|
|
}); |
|
|
|
expect(mockFetch).not.toHaveBeenCalledWith("/api/load-generation", expect.anything()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe("Legacy Data Migration", () => { |
|
|
|
|