test(local_image_loader): cover the folder output in the browser suite

The test host unpacked two values from load_media, and the gallery
test expected no stored selection although the gallery now stores the
folder it shows. Return and assert the folder instead.
This commit is contained in:
Vito Sansevero
2026-11-07 04:06:25 -08:00
parent 9be3cc3397
commit 508eefddfd
2 changed files with 12 additions and 5 deletions
+6 -2
View File
@@ -118,9 +118,13 @@ def create_app(root: Path) -> web.Application:
cls = plugin.NODE_CLASS_MAPPINGS[name]
result = await asyncio.to_thread(getattr(cls(), cls.FUNCTION), **data)
if name == "KikoLocalImageLoader":
tensor, info = result
tensor, info, folder = result
return web.json_response(
{"shape": list(tensor.shape), "info": json.loads(info) if info else {}}
{
"shape": list(tensor.shape),
"info": json.loads(info) if info else {},
"folder": folder,
}
)
return web.json_response(result)
+6 -3
View File
@@ -225,14 +225,16 @@ test('local image selection persists and the real node loads the selected PNG te
const image = page.getByAltText('cat & dog.png', { exact: true });
await expect(image).toBeVisible();
await expect.poll(() => image.evaluate(image => image.complete && image.naturalWidth > 0)).toBe(true);
const selected = page.waitForResponse(response => response.url().endsWith('/set_node_selection'));
const selected = page.waitForResponse(response => response.url().endsWith('/set_node_selection') && response.request().postDataJSON().type === 'image');
await image.click();
expect((await selected).ok()).toBe(true);
const selectedPath = `${(await state(request)).input}/cat & dog.png`;
expect((await state(request)).selections[String(id)].image.path).toBe(selectedPath);
const executed = await request.post('/__test__/execute/KikoLocalImageLoader', { data: { unique_id: String(id) } });
await expect(executed).toBeOK();
expect((await executed.json()).shape).toEqual([1, 12, 16, 3]);
const output = await executed.json();
expect(output.shape).toEqual([1, 12, 16, 3]);
expect(output.folder).toBe((await state(request)).input);
await page.reload();
await expect(page.locator('body')).toHaveAttribute('data-ready', 'true');
expect(await createNode(page, 'KikoLocalImageLoader')).toBe(id);
@@ -271,7 +273,8 @@ test('gallery rejects disallowed folders and retries after a network error', asy
await expect(page.locator('.kiko-status-message')).toBeVisible();
const deniedSelection = await request.post('/kiko_local_image_loader/set_node_selection', { data: { node_id: id, path: `${info.outside}/secret.png`, type: 'image' } });
expect(deniedSelection.status()).toBe(403);
expect((await state(request)).selections).toEqual({});
// Only the folder the gallery still shows is stored, never the denied one.
expect((await state(request)).selections).toEqual({ [String(id)]: { folder: { path: info.input } } });
await page.locator('.kiko-path-input').fill(info.input);
await page.route('**/kiko_local_image_loader/images?*', route => route.abort('failed'), { times: 1 });
await page.locator('.kiko-browse').click();