Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

test(gallery): add mixed media mock coverage

joshistoastdce02065143a
diff --git a/.superpowers/sdd/mixed-media-gallery-parity/task-11-report.md b/.superpowers/sdd/mixed-media-gallery-parity/task-11-report.md
new file mode 100644
index 0000000000..cb3b36ae19
--- /dev/null
+++ b/.superpowers/sdd/mixed-media-gallery-parity/task-11-report.md
@@ -0,0 +1,249 @@
+# Task 11 Report: Additive mock videos and accessibility journey
+
+## Status
+
+Complete, with one pre-existing release-suite blocker recorded for Task 12.
+
+The representative mock backend now provides deterministic mixed image/video
+data for the gallery, date boards, board summaries and deletion, uploads,
+mutations, Details, posters, and protected full media. The fixture-count
+contract remains unchanged, and the default Images performance route still
+orders an image first.
+
+The dedicated representative-video accessibility journey passes. It is the
+only call site that disables Axe's `video-caption` rule, with the required
+generated-media explanation.
+
+## Mock fixture and route coverage
+
+- Added `state.videos` without replacing any of the 1,000 representative
+ images or adding a video key to profile counts.
+- Added owned general, board-cover, same-name collision, control-category,
+ intermediate, foreign-owner, and prior-day video rows.
+- Kept the newest default Images result as an image while retaining a real
+ static video board cover.
+- Added the production-consumed mixed gallery list and names routes, including
+ backend defaults and starred/created/kind/name ordering in both directions.
+- Added board, ownership, category, intermediate, search, inclusive date range,
+ offset, limit, total, and date-board ref behavior.
+- Added video DTO, metadata, workflow/graph, upload, star/unstar/delete, and
+ single-video board add/remove routes.
+- Added dynamic mixed board counts, covers, detach outcomes, and cascade-delete
+ outcomes.
+- Added poster and full-media responses. Full media supports bodyless `HEAD`,
+ ordinary `200`, satisfiable `206`, and malformed/unsatisfiable `416` with
+ exact `Accept-Ranges`, `Content-Length`, and `Content-Range` headers.
+
+`getStateCounts`, `MOCK_BACKEND_PROFILE_COUNTS`, and
+`performance/architecture-fixtures.json` are unchanged.
+
+## Media assets
+
+The repository had no suitably tiny H.264 fixture in the existing webv2 mock
+asset area, so both assets were generated with FFmpeg n8.1.2:
+
+```sh
+ffmpeg -hide_banner -loglevel error \
+ -f lavfi -i "testsrc2=size=64x64:rate=10:duration=1" \
+ -an -c:v libx264 -preset veryslow -crf 28 -pix_fmt yuv420p \
+ -profile:v baseline -level 3.0 -movflags +faststart \
+ -fflags +bitexact -flags:v +bitexact -map_metadata -1 \
+ -y scripts/mock-assets/fixture-video.mp4
+
+ffmpeg -hide_banner -loglevel error \
+ -i scripts/mock-assets/fixture-video.mp4 -frames:v 1 \
+ -c:v libwebp -lossless 1 -map_metadata -1 \
+ -y scripts/mock-assets/fixture-video.webp
+```
+
+Asset evidence:
+
+| Asset | Bytes | SHA-256 |
+| --- | ---: | --- |
+| `fixture-video.mp4` | 4,766 | `372ad163e36c7b0c104ff50e706554268149b437fdf26086e0af2aea6939f7f6` |
+| `fixture-video.webp` | 5,954 | `a1d099ffa75a177a7cdd64335212257654f4a0eaf150c0ef7557064137034d4d` |
+
+`ffprobe` reports a 1.0-second, 64×64, 10 fps H.264 Constrained Baseline
+stream with `yuv420p` pixels. `file` recognizes the poster as lossless WebP.
+
+## Accessibility journey
+
+The new `workbench-video-preview-representative` journey:
+
+- opens the Gallery layout and uses the renamed `Gallery items` list;
+- keyboard-focuses the representative video cell;
+- verifies its Play glyph is decorative;
+- activates the cell with Enter without starting DnD;
+- verifies the opened mixed Preview's native controls, `playsInline`, poster,
+ non-draggable video behavior, and localized duration;
+- runs Axe after the surface settles.
+
+Only this exact Axe call passes:
+
+```js
+{ rules: { 'video-caption': { enabled: false } } }
+```
+
+Every existing surface and the keyboard journey retain the critical caption
+rule.
+
+## Demonstrated Task 1–10 corrections
+
+Three production mismatches appeared only when the representative video journey
+exercised the real production bundle. All three were reported to and authorized by
+the controller before correction.
+
+### Stable gallery virtualizer callbacks
+
+`react-hook-tanstack-virtual` shallow-compares its external-store options.
+Fresh inline `estimateSize` and `getScrollElement` functions produced a new
+snapshot on every render, causing React's cached-snapshot warning and then
+error 301 (`Too many re-renders`) once real gallery data arrived. The existing
+browser mock hid the identity requirement.
+
+The two callbacks are now memoized with `useCallback`. A focused browser test
+first failed on callback identity, then passed, and the production
+representative gallery rendered normally.
+
+### Compact Preview contrast
+
+Once the video opened, Axe exposed 3.56:1 contrast for the 10px position,
+dimensions/duration, and Details text. A focused browser test first failed
+against the `fg.muted` semantic foreground. Those three existing compact text
+surfaces now use `fg.muted`; image and video footer cases both pass, and the
+focused video Axe journey is clean.
+
+### Keyboard item activation versus DnD
+
+The workbench's real `KeyboardSensor` received the Enter/Space keydown bubbled
+from the gallery item's native button. It activated dragging and prevented the
+button click that opens Preview. Focused browser tests reproduced both keys
+with the production sensor: both initially made zero selection calls.
+
+The native item button now stops propagation only for Enter/Space keydown.
+Native button click behavior remains intact, pointer DnD remains green, and
+keyboard DnD remains available when its own parent handle is focused. Both
+focused key cases pass, and the production accessibility journey now opens the
+video with Enter.
+
+No new production module, `<video>`, `useEffect`, migration exception,
+performance baseline, or `@platform/ui` importer was added.
+
+## TDD evidence
+
+The first fixture run failed six new cases while all four legacy cases passed:
+the video state was absent and the mixed/date/video/board routes returned
+404s or image-only results. After implementation, all ten fixture tests pass.
+
+Additional focused RED/GREEN cycles covered:
+
+- default Images ordering remaining image-first;
+- the backend's omitted-parameter `starred_first=true` behavior;
+- backend-accurate board-cover starred ordering and the
+ `starred_count=0` contract when `starred_first=false`;
+- stable virtualizer callback identity (1 failed / 14 passed, then 15/15);
+- Enter/Space gallery activation with a real keyboard sensor (2 failed / 15
+ passed, then 17/17);
+- readable compact Preview foreground (1 failed / 6 passed, then 7/7);
+- the representative video journey and its sole caption exception.
+
+## Verification
+
+All frontend commands ran from `invokeai/frontend/webv2`.
+
+```sh
+pnpm lint
+```
+
+```text
+format: passed
+OXC: passed
+tsc --noEmit: passed
+architecture: 3 files, 34 tests passed
+```
+
+```sh
+pnpm test
+```
+
+```text
+Test Files 376 passed (376)
+Tests 5005 passed (5005)
+```
+
+```sh
+pnpm test:browser
+```
+
+The first full run hit the repository's known timing-sensitive Tabs hover
+timeout. The focused Tabs file passed 1/1, and the required complete rerun
+passed:
+
+```text
+Test Files 69 passed (69)
+Tests 349 passed (349)
+```
+
+```sh
+pnpm test:fixtures
+```
+
+```text
+Tests 10 passed (10)
+```
+
+```sh
+INVOKEAI_ACCESSIBILITY_JOURNEY=workbench-video-preview-representative \
+ node scripts/run-accessibility-journeys.mjs
+```
+
+```text
+workbench-video-preview-representative: passed
+```
+
+Invariant scans also confirmed:
+
+- the only production `<video>` remains in `PreviewFrame.tsx`;
+- no production source file was added in Task 11;
+- `GeneratedImageContract`, migration exceptions, architecture fixtures, and
+ performance baselines are unchanged;
+- exactly one `video-caption` exception exists;
+- `git diff --check` passes;
+- the checked-in MP4/WebP formats, dimensions, lengths, and hashes match the
+ values above.
+
+## Full accessibility suite and Task 12 dependency
+
+`pnpm test:accessibility` builds successfully, then stops at the existing
+`workbench-canvas-representative` surface before later surfaces run. Axe
+reports:
+
+- `nested-interactive` on the 64 sortable canvas layer rows because their
+ role-button containers contain focusable descendants;
+- `target-size` on 12×12 layer visibility buttons.
+
+These are unrelated to mixed media and predate Task 11. The video-specific
+journey passes independently with no violation. Task 12 must either fix or
+explicitly disposition the Canvas violations before `check:release` can be
+fully green; Task 11 does not weaken either rule.
+
+## Independent review
+
+The independent read-only review found no Critical issues. It reported two
+Important findings and one Minor finding:
+
+- mock board-cover selection omitted starred-first ordering;
+- the video journey focused the item but activated it with a mouse click;
+- item-name `starred_count` did not become zero when starred-first ordering was
+ disabled.
+
+All three were addressed test-first. Board covers now use the backend's exact
+starred/created/kind/name precedence and the intended fixture cover is itself
+starred. The journey now activates with Enter after focused Enter/Space
+browser coverage fixed the DnD conflict. The Minor `starred_count` mismatch is
+fixed and asserted for `starred_first=false`.
+
+The scoped re-review approved the code corrections with no Critical or
+Important findings. Its two report-only Minor findings—the stale count of
+production mismatches and stale browser-test total—are corrected in this
+report.
diff --git a/invokeai/frontend/webv2/scripts/mock-assets/fixture-video.mp4 b/invokeai/frontend/webv2/scripts/mock-assets/fixture-video.mp4
new file mode 100644
index 0000000000..65389aeba0
Binary files /dev/null and b/invokeai/frontend/webv2/scripts/mock-assets/fixture-video.mp4 differ
diff --git a/invokeai/frontend/webv2/scripts/mock-assets/fixture-video.webp b/invokeai/frontend/webv2/scripts/mock-assets/fixture-video.webp
new file mode 100644
index 0000000000..89b839d073
Binary files /dev/null and b/invokeai/frontend/webv2/scripts/mock-assets/fixture-video.webp differ
diff --git a/invokeai/frontend/webv2/scripts/mock-backend-fixtures.mjs b/invokeai/frontend/webv2/scripts/mock-backend-fixtures.mjs
index 44053e0021..7c55423e21 100644
--- a/invokeai/frontend/webv2/scripts/mock-backend-fixtures.mjs
+++ b/invokeai/frontend/webv2/scripts/mock-backend-fixtures.mjs
@@ -31,6 +31,7 @@ export const MOCK_BACKEND_PROFILE_COUNTS = Object.freeze({
});
export const MOCK_BACKEND_FIXED_EPOCH = '2026-01-15T12:00:00.000Z';
+export const MOCK_BACKEND_REPRESENTATIVE_VIDEO_NAME = 'fixture-video-001.mp4';
const FIXED_EPOCH_MS = Date.parse(MOCK_BACKEND_FIXED_EPOCH);
const range = (length, build) => Array.from({ length }, (_, index) => build(index));
@@ -70,20 +71,179 @@ const createImages = (count) =>
};
});
-const createBoards = (images) =>
+const createVideos = () => [
+ {
+ board_id: null,
+ created_at: timestampAt(2),
+ duration: 1,
+ fps: 10,
+ graph: '{"nodes":[{"id":"fixture-video-output","type":"wan_l2v"}]}',
+ height: 64,
+ is_intermediate: false,
+ metadata: { codec: 'h264', prompt: 'wan fixture' },
+ owner_user_id: 'fixture-user',
+ starred: true,
+ thumbnail_url: `/api/v1/videos/i/${MOCK_BACKEND_REPRESENTATIVE_VIDEO_NAME}/thumbnail`,
+ video_category: 'general',
+ video_name: MOCK_BACKEND_REPRESENTATIVE_VIDEO_NAME,
+ video_origin: 'external',
+ video_url: `/api/v1/videos/i/${MOCK_BACKEND_REPRESENTATIVE_VIDEO_NAME}/full`,
+ width: 64,
+ workflow: '{"name":"Fixture video workflow","nodes":[]}',
+ },
+ {
+ board_id: 'fixture-board-02',
+ created_at: timestampAt(0),
+ duration: 1,
+ fps: 10,
+ graph: null,
+ height: 64,
+ is_intermediate: false,
+ metadata: { prompt: 'board cover fixture' },
+ owner_user_id: 'fixture-user',
+ starred: true,
+ thumbnail_url: '/api/v1/videos/i/fixture-video-board.mp4/thumbnail',
+ video_category: 'control',
+ video_name: 'fixture-video-board.mp4',
+ video_origin: 'internal',
+ video_url: '/api/v1/videos/i/fixture-video-board.mp4/full',
+ width: 64,
+ workflow: null,
+ },
+ {
+ board_id: null,
+ created_at: timestampAt(11),
+ duration: 1,
+ fps: 10,
+ graph: null,
+ height: 64,
+ is_intermediate: false,
+ metadata: { prompt: 'same-name collision fixture' },
+ owner_user_id: 'fixture-user',
+ starred: true,
+ thumbnail_url: '/api/v1/videos/i/fixture-image-0012.png/thumbnail',
+ video_category: 'general',
+ video_name: 'fixture-image-0012.png',
+ video_origin: 'internal',
+ video_url: '/api/v1/videos/i/fixture-image-0012.png/full',
+ width: 64,
+ workflow: null,
+ },
+ {
+ board_id: 'fixture-board-03',
+ created_at: timestampAt(2),
+ duration: 1,
+ fps: 10,
+ graph: null,
+ height: 64,
+ is_intermediate: false,
+ metadata: { prompt: 'asset category fixture' },
+ owner_user_id: 'fixture-user',
+ starred: false,
+ thumbnail_url: '/api/v1/videos/i/fixture-video-asset.mp4/thumbnail',
+ video_category: 'control',
+ video_name: 'fixture-video-asset.mp4',
+ video_origin: 'internal',
+ video_url: '/api/v1/videos/i/fixture-video-asset.mp4/full',
+ width: 64,
+ workflow: null,
+ },
+ {
+ board_id: null,
+ created_at: timestampAt(3),
+ duration: 1,
+ fps: 10,
+ graph: null,
+ height: 64,
+ is_intermediate: true,
+ metadata: { prompt: 'intermediate fixture' },
+ owner_user_id: 'fixture-user',
+ starred: false,
+ thumbnail_url: '/api/v1/videos/i/fixture-video-intermediate.mp4/thumbnail',
+ video_category: 'general',
+ video_name: 'fixture-video-intermediate.mp4',
+ video_origin: 'internal',
+ video_url: '/api/v1/videos/i/fixture-video-intermediate.mp4/full',
+ width: 64,
+ workflow: null,
+ },
+ {
+ board_id: null,
+ created_at: timestampAt(4),
+ duration: 1,
+ fps: 10,
+ graph: null,
+ height: 64,
+ is_intermediate: false,
+ metadata: { prompt: 'foreign fixture' },
+ owner_user_id: 'other-user',
+ starred: false,
+ thumbnail_url: '/api/v1/videos/i/fixture-video-foreign.mp4/thumbnail',
+ video_category: 'general',
+ video_name: 'fixture-video-foreign.mp4',
+ video_origin: 'external',
+ video_url: '/api/v1/videos/i/fixture-video-foreign.mp4/full',
+ width: 64,
+ workflow: null,
+ },
+ {
+ board_id: null,
+ created_at: timestampAt(800),
+ duration: 1,
+ fps: 10,
+ graph: null,
+ height: 64,
+ is_intermediate: false,
+ metadata: { prompt: 'previous-day fixture' },
+ owner_user_id: 'fixture-user',
+ starred: false,
+ thumbnail_url: '/api/v1/videos/i/fixture-video-old.mp4/thumbnail',
+ video_category: 'general',
+ video_name: 'fixture-video-old.mp4',
+ video_origin: 'internal',
+ video_url: '/api/v1/videos/i/fixture-video-old.mp4/full',
+ width: 64,
+ workflow: null,
+ },
+];
+
+const createBoards = (images, videos) =>
range(10, (index) => {
const boardId = `fixture-board-${ordinal(index, 2)}`;
const boardImages = images.filter((image) => image.board_id === boardId);
+ const boardVideos = videos.filter((video) => video.board_id === boardId);
+ const cover = [
+ ...boardImages.map((image) => ({
+ createdAt: image.created_at,
+ kind: 'image',
+ name: image.image_name,
+ starred: image.starred,
+ })),
+ ...boardVideos.map((video) => ({
+ createdAt: video.created_at,
+ kind: 'video',
+ name: video.video_name,
+ starred: video.starred,
+ })),
+ ].sort(
+ (left, right) =>
+ Number(right.starred) - Number(left.starred) ||
+ right.createdAt.localeCompare(left.createdAt) ||
+ right.kind.localeCompare(left.kind) ||
+ right.name.localeCompare(left.name)
+ )[0];
return {
archived: false,
asset_count: boardImages.filter((image) => image.image_category !== 'general').length,
board_id: boardId,
board_name: `Fixture Board ${ordinal(index, 2)}`,
- cover_image_name: boardImages[0]?.image_name ?? null,
+ cover_image_name: cover?.kind === 'image' ? cover.name : null,
+ cover_video_name: cover?.kind === 'video' ? cover.name : null,
created_at: timestampAt(index * 10),
image_count: boardImages.filter((image) => image.image_category === 'general').length,
owner_username: null,
+ video_count: boardVideos.length,
};
});
@@ -405,15 +565,17 @@ const createEmptyFixture = () => ({
profile: 'empty',
projects: [],
queueItems: [],
+ videos: [],
workflows: [],
});
const createRepresentativeFixture = () => {
const counts = MOCK_BACKEND_PROFILE_COUNTS.representative;
const images = createImages(counts.images);
+ const videos = createVideos();
return {
- boards: createBoards(images),
+ boards: createBoards(images, videos),
images,
models: createModels(counts.models),
nodeCatalog: {
@@ -424,6 +586,7 @@ const createRepresentativeFixture = () => {
profile: 'representative',
projects: createProjects(counts.projects, counts.workflowNodes, counts.layers),
queueItems: createQueueItems(counts.queueItems),
+ videos,
workflows: createWorkflows(100),
};
};
@@ -484,6 +647,7 @@ export const validateMockBackendFixture = (fixture) => {
['model keys', fixture.models.map((model) => model.key)],
['project ids', fixture.projects.map((project) => project.project_id)],
['queue item ids', fixture.queueItems.map((item) => item.item_id)],
+ ['video names', fixture.videos.map((video) => video.video_name)],
];
for (const [label, values] of identities) {
diff --git a/invokeai/frontend/webv2/scripts/mock-backend-fixtures.test.mjs b/invokeai/frontend/webv2/scripts/mock-backend-fixtures.test.mjs
index bf0e70e44f..9e93db0dbb 100644
--- a/invokeai/frontend/webv2/scripts/mock-backend-fixtures.test.mjs
+++ b/invokeai/frontend/webv2/scripts/mock-backend-fixtures.test.mjs
@@ -1,4 +1,5 @@
import assert from 'node:assert/strict';
+import { readFile } from 'node:fs/promises';
import test from 'node:test';
import {
@@ -22,6 +23,37 @@ test('empty and representative fixtures have exact, distinct workloads', () => {
assert.notDeepEqual(createMockBackendFixture('empty'), createMockBackendFixture('representative'));
});
+test('video fixtures are additive without changing the profile-count contract', () => {
+ const empty = createMockBackendFixture('empty');
+ const representative = createMockBackendFixture('representative');
+
+ assert.deepEqual(Object.keys(MOCK_BACKEND_PROFILE_COUNTS.empty), [
+ 'images',
+ 'layers',
+ 'models',
+ 'nodes',
+ 'projects',
+ 'queueItems',
+ 'workflowNodes',
+ ]);
+ assert.deepEqual(Object.keys(MOCK_BACKEND_PROFILE_COUNTS.representative), [
+ 'images',
+ 'layers',
+ 'models',
+ 'nodes',
+ 'projects',
+ 'queueItems',
+ 'workflowNodes',
+ ]);
+ assert.equal(empty.videos.length, 0);
+ assert.ok(representative.videos.length >= 5);
+ assert.equal(representative.images.length, 1_000);
+ assert.equal(representative.images[0].image_name, 'fixture-image-0001.png');
+ assert.ok(representative.videos.some((video) => video.video_name === 'fixture-image-0012.png'));
+ assert.ok(representative.videos.some((video) => video.video_name === 'fixture-video-001.mp4'));
+ assert.deepEqual(getMockBackendFixtureCounts(representative), MOCK_BACKEND_PROFILE_COUNTS.representative);
+});
+
test('fixture generation is byte-deterministic', () => {
for (const profile of MOCK_BACKEND_PROFILE_NAMES) {
assert.equal(JSON.stringify(createMockBackendFixture(profile)), JSON.stringify(createMockBackendFixture(profile)));
@@ -107,3 +139,294 @@ test('the HTTP reset contract selects profiles explicitly and restores the start
await backend.close();
}
});
+
+const withRepresentativeBackend = async (run) => {
+ const backend = await startMockBackend(0, { profile: 'representative' });
+
+ try {
+ await run(backend);
+ } finally {
+ await backend.close();
+ }
+};
+
+const getJson = async (backend, path, init) => {
+ const response = await fetch(`${backend.origin}${path}`, init);
+ const body = await response.json();
+
+ assert.equal(
+ response.ok,
+ true,
+ `${init?.method ?? 'GET'} ${path} returned ${response.status}: ${JSON.stringify(body)}`
+ );
+
+ return body;
+};
+
+test('merged gallery list and names share qualified ordering, filters, ownership, totals, and pagination', async () => {
+ await withRepresentativeBackend(async (backend) => {
+ const defaultPage = await getJson(
+ backend,
+ '/api/v1/gallery/items/?categories=general&is_intermediate=false&starred_first=false&order_dir=DESC&limit=1&offset=0'
+ );
+ const backendDefaultPage = await getJson(
+ backend,
+ '/api/v1/gallery/items/?categories=general&is_intermediate=false&order_dir=DESC&limit=100&offset=0'
+ );
+
+ assert.equal(defaultPage.items[0]?.kind, 'image');
+ assert.deepEqual(
+ backendDefaultPage.items.map((item) => item.starred),
+ backendDefaultPage.items.map((item) => item.starred).toSorted((left, right) => Number(right) - Number(left))
+ );
+
+ const query =
+ 'categories=general&is_intermediate=false&starred_first=true&order_dir=DESC&created_from=2026-01-15&created_to=2026-01-15';
+ const page = await getJson(backend, `/api/v1/gallery/items/?${query}&limit=3&offset=0`);
+ const names = await getJson(backend, `/api/v1/gallery/items/names?${query}`);
+ const chronologicalNames = await getJson(
+ backend,
+ '/api/v1/gallery/items/names?categories=general&is_intermediate=false&starred_first=false&order_dir=DESC'
+ );
+
+ assert.equal(page.items.length, 3);
+ assert.equal(page.total, names.total_count);
+ assert.equal(chronologicalNames.starred_count, 0);
+ assert.deepEqual(
+ page.items.map(({ kind, name }) => ({ kind, name })),
+ names.items.slice(0, 3)
+ );
+ assert.deepEqual(names.items.slice(1, 3), [
+ { kind: 'video', name: 'fixture-image-0012.png' },
+ { kind: 'image', name: 'fixture-image-0012.png' },
+ ]);
+ assert.ok(names.starred_count >= 2);
+ assert.ok(!names.items.some((item) => item.name === 'fixture-video-foreign.mp4'));
+ assert.ok(!names.items.some((item) => item.name === 'fixture-video-intermediate.mp4'));
+
+ const secondPage = await getJson(backend, `/api/v1/gallery/items/?${query}&limit=2&offset=1`);
+
+ assert.deepEqual(secondPage.items, page.items.slice(1, 3));
+
+ const assetPage = await getJson(
+ backend,
+ '/api/v1/gallery/items/?categories=control&categories=mask&categories=user&is_intermediate=false&limit=100&offset=0'
+ );
+
+ assert.ok(assetPage.items.some((item) => item.kind === 'video' && item.name === 'fixture-video-asset.mp4'));
+ assert.ok(!assetPage.items.some((item) => item.kind === 'video' && item.category === 'general'));
+
+ const searched = await getJson(
+ backend,
+ '/api/v1/gallery/items/?categories=general&is_intermediate=false&search_term=wan%20fixture&limit=100&offset=0'
+ );
+
+ assert.deepEqual(
+ searched.items.map(({ kind, name }) => ({ kind, name })),
+ [{ kind: 'video', name: 'fixture-video-001.mp4' }]
+ );
+
+ const ascending = await getJson(
+ backend,
+ '/api/v1/gallery/items/?categories=general&is_intermediate=false&starred_first=false&order_dir=ASC&limit=100&offset=0'
+ );
+ const ascendingKeys = ascending.items.map((item) => `${item.created_at}|${item.kind}|${item.name}`);
+
+ assert.deepEqual(ascendingKeys, [...ascendingKeys].sort());
+ });
+});
+
+test('date-board item names preserve the mixed gallery ordering and filter contract', async () => {
+ await withRepresentativeBackend(async (backend) => {
+ const result = await getJson(
+ backend,
+ '/api/v1/virtual_boards/by_date/2026-01-15/item_names?categories=general&is_intermediate=false&starred_first=true&order_dir=DESC'
+ );
+
+ assert.ok(result.items.some((item) => item.kind === 'image'));
+ assert.ok(result.items.some((item) => item.kind === 'video'));
+ assert.deepEqual(result.items.slice(1, 3), [
+ { kind: 'video', name: 'fixture-image-0012.png' },
+ { kind: 'image', name: 'fixture-image-0012.png' },
+ ]);
+ assert.equal(result.total_count, result.items.length);
+ });
+});
+
+test('video DTO, Details, poster, full media, HEAD, and Range routes use the checked-in assets', async () => {
+ await withRepresentativeBackend(async (backend) => {
+ const name = 'fixture-video-001.mp4';
+ const encodedName = encodeURIComponent(name);
+ const dto = await getJson(backend, `/api/v1/videos/i/${encodedName}`);
+
+ assert.equal(dto.video_name, name);
+ assert.equal(dto.video_category, 'general');
+ assert.equal(dto.video_url, `/api/v1/videos/i/${name}/full`);
+ assert.equal(dto.thumbnail_url, `/api/v1/videos/i/${name}/thumbnail`);
+ assert.equal(Number.isFinite(dto.duration), true);
+ assert.equal(dto.width, 64);
+ assert.equal(dto.height, 64);
+
+ assert.deepEqual(await getJson(backend, `/api/v1/videos/i/${encodedName}/metadata`), {
+ codec: 'h264',
+ prompt: 'wan fixture',
+ });
+ assert.deepEqual(await getJson(backend, `/api/v1/videos/i/${encodedName}/workflow`), {
+ graph: '{"nodes":[{"id":"fixture-video-output","type":"wan_l2v"}]}',
+ workflow: '{"name":"Fixture video workflow","nodes":[]}',
+ });
+
+ const poster = await fetch(`${backend.origin}/api/v1/videos/i/${encodedName}/thumbnail`);
+
+ assert.equal(poster.status, 200);
+ assert.equal(poster.headers.get('content-type'), 'image/webp');
+ assert.ok((await poster.arrayBuffer()).byteLength > 0);
+
+ const head = await fetch(`${backend.origin}/api/v1/videos/i/${encodedName}/full`, { method: 'HEAD' });
+ const length = Number(head.headers.get('content-length'));
+
+ assert.equal(head.status, 200);
+ assert.equal(head.headers.get('accept-ranges'), 'bytes');
+ assert.equal(head.headers.get('content-type'), 'video/mp4');
+ assert.ok(length > 0);
+ assert.equal((await head.arrayBuffer()).byteLength, 0);
+
+ const full = await fetch(`${backend.origin}/api/v1/videos/i/${encodedName}/full`);
+
+ assert.equal(full.status, 200);
+ assert.equal(full.headers.get('accept-ranges'), 'bytes');
+ assert.equal(Number(full.headers.get('content-length')), length);
+ assert.equal((await full.arrayBuffer()).byteLength, length);
+
+ const range = await fetch(`${backend.origin}/api/v1/videos/i/${encodedName}/full`, {
+ headers: { range: 'bytes=0-15' },
+ });
+
+ assert.equal(range.status, 206);
+ assert.equal(range.headers.get('accept-ranges'), 'bytes');
+ assert.equal(range.headers.get('content-length'), '16');
+ assert.equal(range.headers.get('content-range'), `bytes 0-15/${String(length)}`);
+ assert.equal((await range.arrayBuffer()).byteLength, 16);
+
+ for (const invalidRange of ['bytes=bad', `bytes=${String(length)}-`, 'bytes=9-1']) {
+ const unsatisfiable = await fetch(`${backend.origin}/api/v1/videos/i/${encodedName}/full`, {
+ headers: { range: invalidRange },
+ });
+
+ assert.equal(unsatisfiable.status, 416);
+ assert.equal(unsatisfiable.headers.get('accept-ranges'), 'bytes');
+ assert.equal(unsatisfiable.headers.get('content-range'), `bytes */${String(length)}`);
+ assert.equal((await unsatisfiable.arrayBuffer()).byteLength, 0);
+ }
+ });
+});
+
+test('video upload, star, delete, board movement, counts, covers, and board deletion return authoritative outcomes', async () => {
+ await withRepresentativeBackend(async (backend) => {
+ const boards = await getJson(backend, '/api/v1/boards/?all=true');
+ const board = boards.find((candidate) => candidate.board_id === 'fixture-board-02');
+
+ assert.ok(board);
+ assert.ok(board.image_count > 0);
+ assert.ok(board.video_count > 0);
+ assert.equal(board.cover_image_name, null);
+ assert.equal(board.cover_video_name, 'fixture-video-board.mp4');
+ assert.equal((await getJson(backend, '/api/v1/videos/i/fixture-video-board.mp4')).starred, true);
+
+ const form = new FormData();
+ form.append('file', new Blob(['fixture upload'], { type: 'video/mp4' }), 'uploaded-fixture.mp4');
+ const uploadResponse = await fetch(
+ `${backend.origin}/api/v1/videos/upload?video_category=general&is_intermediate=false&board_id=fixture-board-02`,
+ { body: form, method: 'POST' }
+ );
+ const uploaded = await uploadResponse.json();
+
+ assert.equal(uploadResponse.status, 201);
+ assert.equal(uploaded.video_category, 'general');
+ assert.equal(uploaded.is_intermediate, false);
+ assert.equal(uploaded.board_id, 'fixture-board-02');
+
+ assert.deepEqual(
+ await getJson(backend, '/api/v1/videos/star', {
+ body: JSON.stringify({ video_names: [uploaded.video_name, 'missing.mp4'] }),
+ headers: { 'content-type': 'application/json' },
+ method: 'POST',
+ }),
+ {
+ affected_boards: ['fixture-board-02'],
+ failed_videos: [],
+ starred_videos: [uploaded.video_name],
+ }
+ );
+
+ assert.deepEqual(
+ await getJson(backend, '/api/v1/videos/board', {
+ body: JSON.stringify({ board_id: 'fixture-board-03', video_name: uploaded.video_name }),
+ headers: { 'content-type': 'application/json' },
+ method: 'POST',
+ }),
+ {
+ added_videos: [uploaded.video_name],
+ affected_boards: ['fixture-board-02', 'fixture-board-03'],
+ }
+ );
+
+ assert.deepEqual(
+ await getJson(backend, '/api/v1/videos/board', {
+ body: JSON.stringify({ video_name: uploaded.video_name }),
+ headers: { 'content-type': 'application/json' },
+ method: 'DELETE',
+ }),
+ {
+ affected_boards: ['fixture-board-03', 'none'],
+ removed_videos: [uploaded.video_name],
+ }
+ );
+
+ assert.deepEqual(
+ await getJson(backend, '/api/v1/videos/delete', {
+ body: JSON.stringify({ video_names: [uploaded.video_name, 'missing.mp4'] }),
+ headers: { 'content-type': 'application/json' },
+ method: 'POST',
+ }),
+ {
+ affected_boards: ['none'],
+ deleted_videos: [uploaded.video_name],
+ failed_videos: [],
+ }
+ );
+
+ const detachResult = await getJson(backend, '/api/v1/boards/fixture-board-02?include_images=false', {
+ method: 'DELETE',
+ });
+
+ assert.ok(detachResult.deleted_board_images.length > 0);
+ assert.deepEqual(detachResult.deleted_board_videos, ['fixture-video-board.mp4']);
+ assert.deepEqual(detachResult.deleted_images, []);
+ assert.deepEqual(detachResult.deleted_videos, []);
+ assert.equal((await getJson(backend, '/api/v1/videos/i/fixture-video-board.mp4')).board_id, null);
+ });
+
+ await withRepresentativeBackend(async (backend) => {
+ const deleteResult = await getJson(backend, '/api/v1/boards/fixture-board-02?include_images=true', {
+ method: 'DELETE',
+ });
+
+ assert.ok(deleteResult.deleted_images.length > 0);
+ assert.deepEqual(deleteResult.deleted_videos, ['fixture-video-board.mp4']);
+ assert.deepEqual(deleteResult.failed_images, []);
+ assert.deepEqual(deleteResult.failed_videos, []);
+ assert.equal((await fetch(`${backend.origin}/api/v1/videos/i/fixture-video-board.mp4`)).status, 404);
+ });
+});
+
+test('the representative video accessibility journey owns the only generated-media caption exception', async () => {
+ const source = await readFile(new URL('./run-accessibility-journeys.mjs', import.meta.url), 'utf8');
+ const captionExceptions = source.match(/'video-caption': \{ enabled: false \}/g) ?? [];
+
+ assert.equal(captionExceptions.length, 1);
+ assert.match(source, /generated media has no caption track/i);
+ assert.match(source, /workbench-video-preview-representative/);
+ assert.match(source, /getByRole\('list', \{ exact: true, name: 'Gallery items' \}\)/);
+ assert.match(source, /INVOKEAI_ACCESSIBILITY_JOURNEY/);
+});
diff --git a/invokeai/frontend/webv2/scripts/mock-backend.mjs b/invokeai/frontend/webv2/scripts/mock-backend.mjs
index 37d9d5470e..b5da7a1436 100644
--- a/invokeai/frontend/webv2/scripts/mock-backend.mjs
+++ b/invokeai/frontend/webv2/scripts/mock-backend.mjs
@@ -1,4 +1,6 @@
+import { readFileSync } from 'node:fs';
import { createServer } from 'node:http';
+import { resolve } from 'node:path';
import {
assertMockBackendFixture,
@@ -22,6 +24,9 @@ const TINY_PNG = Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAF/gL+XcX1WQAAAABJRU5ErkJggg==',
'base64'
);
+const FIXTURE_VIDEO = readFileSync(resolve(import.meta.dirname, 'mock-assets/fixture-video.mp4'));
+const FIXTURE_VIDEO_POSTER = readFileSync(resolve(import.meta.dirname, 'mock-assets/fixture-video.webp'));
+const MOCK_USER_ID = 'fixture-user';
const clone = (value) => structuredClone(value);
@@ -35,11 +40,13 @@ const createState = (profile) => {
models: new Map(fixture.models.map((model) => [model.key, clone(model)])),
mutationClock: 0,
nextProjectNumber: fixture.projects.length + 1,
+ nextVideoNumber: fixture.videos.length + 1,
nodeCatalog: clone(fixture.nodeCatalog),
openApiDocument: clone(fixture.openApiDocument),
profile,
projects: new Map(fixture.projects.map((project) => [project.project_id, clone(project)])),
queueItems: new Map(fixture.queueItems.map((item) => [item.item_id, clone(item)])),
+ videos: new Map(fixture.videos.map((video) => [video.video_name, clone(video)])),
workflows: new Map(fixture.workflows.map((workflow) => [workflow.workflow_id, clone(workflow)])),
};
};
@@ -122,6 +129,244 @@ const getRequestedCategories = (url) => {
return values.flatMap((value) => value.split(',')).filter(Boolean);
};
+const getOptionalBoolean = (url, name) => {
+ const value = url.searchParams.get(name);
+
+ return value === null ? undefined : value === 'true';
+};
+
+const toVideoDto = (video) => ({
+ board_id: video.board_id,
+ created_at: video.created_at,
+ duration: video.duration,
+ fps: video.fps,
+ height: video.height,
+ is_intermediate: video.is_intermediate,
+ starred: video.starred,
+ thumbnail_url: video.thumbnail_url,
+ video_category: video.video_category,
+ video_name: video.video_name,
+ video_url: video.video_url,
+ width: video.width,
+});
+
+const toGalleryItem = (kind, value) =>
+ kind === 'image'
+ ? {
+ board_id: value.board_id,
+ category: value.image_category,
+ created_at: value.created_at,
+ full_url: value.image_url,
+ height: value.height,
+ is_intermediate: value.is_intermediate,
+ kind,
+ name: value.image_name,
+ starred: value.starred ?? false,
+ thumbnail_url: value.thumbnail_url,
+ width: value.width,
+ }
+ : {
+ board_id: value.board_id,
+ category: value.video_category,
+ created_at: value.created_at,
+ duration: value.duration,
+ fps: value.fps,
+ full_url: value.video_url,
+ height: value.height,
+ is_intermediate: value.is_intermediate,
+ kind,
+ name: value.video_name,
+ starred: value.starred,
+ thumbnail_url: value.thumbnail_url,
+ width: value.width,
+ };
+
+const getGalleryCandidates = (state) => [
+ ...[...state.images.values()].map((image) => ({ item: toGalleryItem('image', image), searchable: image.metadata })),
+ ...[...state.videos.values()]
+ .filter((video) => video.owner_user_id === MOCK_USER_ID)
+ .map((video) => ({ item: toGalleryItem('video', video), searchable: video.metadata })),
+];
+
+const compareGalleryItems = (left, right, orderDir, starredFirst) => {
+ if (starredFirst && left.starred !== right.starred) {
+ return left.starred ? -1 : 1;
+ }
+
+ const direction = orderDir === 'ASC' ? 1 : -1;
+
+ return (
+ direction * left.created_at.localeCompare(right.created_at) ||
+ direction * left.kind.localeCompare(right.kind) ||
+ direction * left.name.localeCompare(right.name)
+ );
+};
+
+const filterGalleryItems = (state, url, { createdDate } = {}) => {
+ const boardId = url.searchParams.get('board_id');
+ const categories = getRequestedCategories(url);
+ const createdFrom = url.searchParams.get('created_from');
+ const createdTo = url.searchParams.get('created_to');
+ const intermediate = getOptionalBoolean(url, 'is_intermediate');
+ const searchTerm = url.searchParams.get('search_term')?.trim().toLocaleLowerCase() ?? '';
+
+ return getGalleryCandidates(state)
+ .filter(({ item, searchable }) => {
+ if (boardId && (boardId === 'none' ? item.board_id !== null : item.board_id !== boardId)) {
+ return false;
+ }
+ if (categories.length > 0 && !categories.includes(item.category)) {
+ return false;
+ }
+ if (intermediate !== undefined && item.is_intermediate !== intermediate) {
+ return false;
+ }
+ if (createdDate && item.created_at.slice(0, 10) !== createdDate) {
+ return false;
+ }
+ if (createdFrom && item.created_at < createdFrom) {
+ return false;
+ }
+ if (createdTo && item.created_at >= `${createdTo}T24:00:00`) {
+ return false;
+ }
+ if (searchTerm) {
+ const document = `${JSON.stringify(searchable ?? {})} ${item.created_at}`.toLocaleLowerCase();
+
+ if (!document.includes(searchTerm)) {
+ return false;
+ }
+ }
+
+ return true;
+ })
+ .map(({ item }) => item)
+ .sort((left, right) =>
+ compareGalleryItems(
+ left,
+ right,
+ url.searchParams.get('order_dir')?.toUpperCase() === 'ASC' ? 'ASC' : 'DESC',
+ url.searchParams.get('starred_first') !== 'false'
+ )
+ );
+};
+
+const listGalleryItems = (state, url) => {
+ const offset = Math.max(0, Number(url.searchParams.get('offset') ?? 0) || 0);
+ const limit = Math.max(0, Number(url.searchParams.get('limit') ?? 10) || 0);
+ const filtered = filterGalleryItems(state, url);
+
+ return {
+ items: limit === 0 ? [] : filtered.slice(offset, offset + limit),
+ limit,
+ offset,
+ total: filtered.length,
+ };
+};
+
+const listGalleryItemNames = (state, url, options) => {
+ const items = filterGalleryItems(state, url, options);
+
+ return {
+ items: items.map(({ kind, name }) => ({ kind, name })),
+ starred_count: url.searchParams.get('starred_first') !== 'false' ? items.filter((item) => item.starred).length : 0,
+ total_count: items.length,
+ };
+};
+
+const listVideos = (state, url) => {
+ const boardId = url.searchParams.get('board_id');
+ const categories = getRequestedCategories(url);
+ const intermediate = getOptionalBoolean(url, 'is_intermediate');
+ const searchTerm = url.searchParams.get('search_term')?.trim().toLocaleLowerCase() ?? '';
+ const orderDir = url.searchParams.get('order_dir')?.toUpperCase() === 'ASC' ? 'ASC' : 'DESC';
+ const starredFirst = url.searchParams.get('starred_first') !== 'false';
+ const offset = Math.max(0, Number(url.searchParams.get('offset') ?? 0) || 0);
+ const limit = Math.max(0, Number(url.searchParams.get('limit') ?? 10) || 0);
+ const filtered = [...state.videos.values()]
+ .filter((video) => {
+ if (video.owner_user_id !== MOCK_USER_ID) {
+ return false;
+ }
+ if (boardId && (boardId === 'none' ? video.board_id !== null : video.board_id !== boardId)) {
+ return false;
+ }
+ if (categories.length > 0 && !categories.includes(video.video_category)) {
+ return false;
+ }
+ if (intermediate !== undefined && video.is_intermediate !== intermediate) {
+ return false;
+ }
+
+ return (
+ !searchTerm ||
+ `${JSON.stringify(video.metadata ?? {})} ${video.created_at}`.toLocaleLowerCase().includes(searchTerm)
+ );
+ })
+ .map(toVideoDto)
+ .sort((left, right) =>
+ compareGalleryItems(
+ {
+ created_at: left.created_at,
+ kind: 'video',
+ name: left.video_name,
+ starred: left.starred,
+ },
+ {
+ created_at: right.created_at,
+ kind: 'video',
+ name: right.video_name,
+ starred: right.starred,
+ },
+ orderDir,
+ starredFirst
+ )
+ );
+
+ return {
+ items: limit === 0 ? [] : filtered.slice(offset, offset + limit),
+ limit,
+ offset,
+ total: filtered.length,
+ };
+};
+
+const boardDto = (state, board) => {
+ const images = [...state.images.values()].filter((image) => image.board_id === board.board_id);
+ const videos = [...state.videos.values()].filter(
+ (video) => video.board_id === board.board_id && video.owner_user_id === MOCK_USER_ID
+ );
+ const cover = [
+ ...images.map((image) => ({
+ createdAt: image.created_at,
+ kind: 'image',
+ name: image.image_name,
+ starred: image.starred,
+ })),
+ ...videos.map((video) => ({
+ createdAt: video.created_at,
+ kind: 'video',
+ name: video.video_name,
+ starred: video.starred,
+ })),
+ ].sort(
+ (left, right) =>
+ Number(right.starred) - Number(left.starred) ||
+ right.createdAt.localeCompare(left.createdAt) ||
+ right.kind.localeCompare(left.kind) ||
+ right.name.localeCompare(left.name)
+ )[0];
+
+ return {
+ ...board,
+ asset_count: images.filter((image) => image.image_category !== 'general').length,
+ cover_image_name: cover?.kind === 'image' ? cover.name : null,
+ cover_video_name: cover?.kind === 'video' ? cover.name : null,
+ image_count: images.filter((image) => image.image_category === 'general').length,
+ video_count: videos.length,
+ };
+};
+
const listImages = (state, url) => {
const boardId = url.searchParams.get('board_id');
const categories = getRequestedCategories(url);
@@ -173,24 +418,34 @@ const listImages = (state, url) => {
const listVirtualDateBoards = (state) => {
const groups = new Map();
- for (const image of state.images.values()) {
- const date = image.created_at.slice(0, 10);
+ for (const item of getGalleryCandidates(state).map(({ item }) => item)) {
+ if (item.is_intermediate) {
+ continue;
+ }
+ const date = item.created_at.slice(0, 10);
const group = groups.get(date) ?? [];
- group.push(image);
+ group.push(item);
groups.set(date, group);
}
return [...groups.entries()]
.sort(([left], [right]) => right.localeCompare(left))
- .map(([date, images]) => ({
- asset_count: images.filter((image) => image.image_category !== 'general').length,
- board_name: date,
- cover_image_name: images[0]?.image_name ?? null,
- date,
- image_count: images.filter((image) => image.image_category === 'general').length,
- virtual_board_id: `by_date:${date}`,
- }));
+ .map(([date, items]) => {
+ const ordered = [...items].sort((left, right) => compareGalleryItems(left, right, 'DESC', false));
+ const cover = ordered[0];
+
+ return {
+ asset_count: items.filter((item) => item.kind === 'image' && item.category !== 'general').length,
+ board_name: date,
+ cover_image_name: cover?.kind === 'image' ? cover.name : null,
+ cover_video_name: cover?.kind === 'video' ? cover.name : null,
+ date,
+ image_count: items.filter((item) => item.kind === 'image' && item.category === 'general').length,
+ video_count: items.filter((item) => item.kind === 'video').length,
+ virtual_board_id: `by_date:${date}`,
+ };
+ });
};
const writeJson = (response, status, value) => {
@@ -213,6 +468,35 @@ const writePng = (response) => {
response.end(TINY_PNG);
};
+const writeBinary = (response, status, body, headers) => {
+ response.writeHead(status, {
+ 'cache-control': 'public, max-age=3600',
+ 'content-length': body.length,
+ ...headers,
+ });
+ response.end(body);
+};
+
+const parseByteRange = (value, size) => {
+ const match = /^bytes=(\d*)-(\d*)$/.exec(value.trim());
+
+ if (!match || size <= 0 || (!match[1] && !match[2])) {
+ return null;
+ }
+ if (!match[1]) {
+ const suffixLength = Number(match[2]);
+
+ return suffixLength > 0 ? [Math.max(size - suffixLength, 0), size - 1] : null;
+ }
+
+ const start = Number(match[1]);
+ const end = match[2] ? Number(match[2]) : size - 1;
+
+ return Number.isSafeInteger(start) && Number.isSafeInteger(end) && start <= end && start < size
+ ? [start, Math.min(end, size - 1)]
+ : null;
+};
+
export const startMockBackend = async (port, { profile = 'empty' } = {}) => {
const initialProfile = assertMockBackendProfileName(profile);
let state = createState(initialProfile);
@@ -470,13 +754,82 @@ export const startMockBackend = async (port, { profile = 'empty' } = {}) => {
}
if (method === 'GET' && (path === '/api/v1/boards' || path === '/api/v1/boards/')) {
- return json(200, [...state.boards.values()]);
+ return json(
+ 200,
+ [...state.boards.values()].map((board) => boardDto(state, board))
+ );
+ }
+
+ const boardMatch = /^\/api\/v1\/boards\/([^/]+)$/.exec(path);
+ if (boardMatch) {
+ const boardId = decodeURIComponent(boardMatch[1]);
+ const board = state.boards.get(boardId);
+
+ if (!board) {
+ return json(404, { detail: 'Board not found' });
+ }
+ if (method === 'GET') {
+ return json(200, boardDto(state, board));
+ }
+ if (method === 'DELETE') {
+ const includeImages = url.searchParams.get('include_images') === 'true';
+ const boardImages = [...state.images.values()].filter((image) => image.board_id === boardId);
+ const boardVideos = [...state.videos.values()].filter(
+ (video) => video.board_id === boardId && video.owner_user_id === MOCK_USER_ID
+ );
+ const imageNames = boardImages.map((image) => image.image_name);
+ const videoNames = boardVideos.map((video) => video.video_name);
+
+ state.boards.delete(boardId);
+ if (includeImages) {
+ for (const imageName of imageNames) {
+ state.images.delete(imageName);
+ }
+ for (const videoName of videoNames) {
+ state.videos.delete(videoName);
+ }
+
+ return json(200, {
+ board_id: boardId,
+ deleted_board_images: [],
+ deleted_board_videos: [],
+ deleted_images: imageNames,
+ deleted_videos: videoNames,
+ failed_images: [],
+ failed_videos: [],
+ });
+ }
+
+ for (const image of boardImages) {
+ image.board_id = null;
+ }
+ for (const video of boardVideos) {
+ video.board_id = null;
+ }
+
+ return json(200, {
+ board_id: boardId,
+ deleted_board_images: imageNames,
+ deleted_board_videos: videoNames,
+ deleted_images: [],
+ deleted_videos: [],
+ failed_images: [],
+ failed_videos: [],
+ });
+ }
}
if (method === 'GET' && path === '/api/v1/virtual_boards/by_date') {
return json(200, listVirtualDateBoards(state));
}
+ const virtualBoardItemNamesMatch = /^\/api\/v1\/virtual_boards\/by_date\/([^/]+)\/item_names$/.exec(path);
+ if (method === 'GET' && virtualBoardItemNamesMatch) {
+ const date = decodeURIComponent(virtualBoardItemNamesMatch[1]);
+
+ return json(200, listGalleryItemNames(state, url, { createdDate: date }));
+ }
+
const virtualBoardNamesMatch = /^\/api\/v1\/virtual_boards\/by_date\/([^/]+)\/image_names$/.exec(path);
if (method === 'GET' && virtualBoardNamesMatch) {
const date = decodeURIComponent(virtualBoardNamesMatch[1]);
@@ -501,6 +854,14 @@ export const startMockBackend = async (port, { profile = 'empty' } = {}) => {
return json(200, listImages(state, url));
}
+ if (method === 'GET' && path === '/api/v1/gallery/items/') {
+ return json(200, listGalleryItems(state, url));
+ }
+
+ if (method === 'GET' && path === '/api/v1/gallery/items/names') {
+ return json(200, listGalleryItemNames(state, url));
+ }
+
const imageAssetMatch = /^\/api\/v1\/images\/i\/([^/]+)\/(full|thumbnail)$/.exec(path);
if (method === 'GET' && imageAssetMatch) {
const imageName = decodeURIComponent(imageAssetMatch[1]);
@@ -521,6 +882,199 @@ export const startMockBackend = async (port, { profile = 'empty' } = {}) => {
return image ? json(200, image) : json(404, { detail: 'Image not found' });
}
+ if (method === 'POST' && path === '/api/v1/videos/upload') {
+ const multipartBody = await readBody(request);
+ const requestedName = /filename="([^"]+)"/.exec(multipartBody)?.[1] ?? 'uploaded-fixture.mp4';
+ const suffix = String(state.nextVideoNumber).padStart(3, '0');
+ const videoName = `fixture-upload-${suffix}-${requestedName.replaceAll(/[^a-zA-Z0-9._-]/g, '-')}`;
+ const boardId = url.searchParams.get('board_id');
+ const video = {
+ board_id: boardId && state.boards.has(boardId) ? boardId : null,
+ created_at: timestamp(state),
+ duration: 1,
+ fps: 10,
+ graph: null,
+ height: 64,
+ is_intermediate: url.searchParams.get('is_intermediate') === 'true',
+ metadata: null,
+ owner_user_id: MOCK_USER_ID,
+ starred: false,
+ thumbnail_url: `/api/v1/videos/i/${videoName}/thumbnail`,
+ video_category: url.searchParams.get('video_category') ?? 'general',
+ video_name: videoName,
+ video_origin: 'external',
+ video_url: `/api/v1/videos/i/${videoName}/full`,
+ width: 64,
+ workflow: null,
+ };
+
+ state.nextVideoNumber += 1;
+ state.videos.set(videoName, video);
+ response.setHeader('location', video.video_url);
+ return json(201, toVideoDto(video));
+ }
+
+ if (method === 'GET' && (path === '/api/v1/videos' || path === '/api/v1/videos/')) {
+ return json(200, listVideos(state, url));
+ }
+
+ if (method === 'POST' && (path === '/api/v1/videos/star' || path === '/api/v1/videos/unstar')) {
+ const body = await readJsonBody(request);
+ const names = Array.isArray(body.video_names) ? [...new Set(body.video_names)] : [];
+ const succeeded = [];
+ const affectedBoards = [];
+ const starred = path.endsWith('/star');
+
+ for (const name of names) {
+ const video = state.videos.get(name);
+
+ if (!video || video.owner_user_id !== MOCK_USER_ID) {
+ continue;
+ }
+ video.starred = starred;
+ succeeded.push(name);
+ affectedBoards.push(video.board_id ?? 'none');
+ }
+
+ return json(200, {
+ affected_boards: [...new Set(affectedBoards)],
+ failed_videos: [],
+ [starred ? 'starred_videos' : 'unstarred_videos']: succeeded,
+ });
+ }
+
+ if (method === 'POST' && path === '/api/v1/videos/delete') {
+ const body = await readJsonBody(request);
+ const names = Array.isArray(body.video_names) ? [...new Set(body.video_names)] : [];
+ const deletedVideos = [];
+ const affectedBoards = [];
+
+ for (const name of names) {
+ const video = state.videos.get(name);
+
+ if (!video || video.owner_user_id !== MOCK_USER_ID) {
+ continue;
+ }
+ state.videos.delete(name);
+ deletedVideos.push(name);
+ affectedBoards.push(video.board_id ?? 'none');
+ }
+
+ return json(200, {
+ affected_boards: [...new Set(affectedBoards)],
+ deleted_videos: deletedVideos,
+ failed_videos: [],
+ });
+ }
+
+ if (path === '/api/v1/videos/board' && (method === 'POST' || method === 'DELETE')) {
+ const body = await readJsonBody(request);
+ const video = state.videos.get(body.video_name);
+
+ if (!video || video.owner_user_id !== MOCK_USER_ID) {
+ return json(404, { detail: 'Video not found' });
+ }
+
+ const oldBoardId = video.board_id ?? 'none';
+
+ if (method === 'POST') {
+ if (!body.board_id || !state.boards.has(body.board_id)) {
+ return json(404, { detail: 'Board not found' });
+ }
+ video.board_id = body.board_id;
+ return json(200, {
+ added_videos: [video.video_name],
+ affected_boards: [...new Set([oldBoardId, body.board_id])],
+ });
+ }
+
+ video.board_id = null;
+ return json(200, {
+ affected_boards: [...new Set([oldBoardId, 'none'])],
+ removed_videos: [video.video_name],
+ });
+ }
+
+ const videoMetadataMatch = /^\/api\/v1\/videos\/i\/([^/]+)\/metadata$/.exec(path);
+ if (method === 'GET' && videoMetadataMatch) {
+ const video = state.videos.get(decodeURIComponent(videoMetadataMatch[1]));
+
+ return video && video.owner_user_id === MOCK_USER_ID
+ ? json(200, video.metadata)
+ : json(404, { detail: 'Video not found' });
+ }
+
+ const videoWorkflowMatch = /^\/api\/v1\/videos\/i\/([^/]+)\/workflow$/.exec(path);
+ if (method === 'GET' && videoWorkflowMatch) {
+ const video = state.videos.get(decodeURIComponent(videoWorkflowMatch[1]));
+
+ return video && video.owner_user_id === MOCK_USER_ID
+ ? json(200, { graph: video.graph, workflow: video.workflow })
+ : json(404, { detail: 'Video not found' });
+ }
+
+ const videoThumbnailMatch = /^\/api\/v1\/videos\/i\/([^/]+)\/thumbnail$/.exec(path);
+ if (method === 'GET' && videoThumbnailMatch) {
+ const video = state.videos.get(decodeURIComponent(videoThumbnailMatch[1]));
+
+ return video && video.owner_user_id === MOCK_USER_ID
+ ? writeBinary(response, 200, FIXTURE_VIDEO_POSTER, { 'content-type': 'image/webp' })
+ : json(404, { detail: 'Video not found' });
+ }
+
+ const videoFullMatch = /^\/api\/v1\/videos\/i\/([^/]+)\/full$/.exec(path);
+ if ((method === 'GET' || method === 'HEAD') && videoFullMatch) {
+ const video = state.videos.get(decodeURIComponent(videoFullMatch[1]));
+
+ if (!video || video.owner_user_id !== MOCK_USER_ID) {
+ return json(404, { detail: 'Video not found' });
+ }
+
+ const commonHeaders = {
+ 'accept-ranges': 'bytes',
+ 'content-type': 'video/mp4',
+ };
+
+ if (method === 'HEAD') {
+ response.writeHead(200, { ...commonHeaders, 'content-length': FIXTURE_VIDEO.length });
+ return response.end();
+ }
+
+ const rangeHeader = request.headers.range;
+
+ if (!rangeHeader) {
+ return writeBinary(response, 200, FIXTURE_VIDEO, commonHeaders);
+ }
+
+ const range = parseByteRange(rangeHeader, FIXTURE_VIDEO.length);
+
+ if (!range) {
+ response.writeHead(416, {
+ ...commonHeaders,
+ 'content-length': 0,
+ 'content-range': `bytes */${String(FIXTURE_VIDEO.length)}`,
+ });
+ return response.end();
+ }
+
+ const [start, end] = range;
+ const body = FIXTURE_VIDEO.subarray(start, end + 1);
+
+ return writeBinary(response, 206, body, {
+ ...commonHeaders,
+ 'content-range': `bytes ${String(start)}-${String(end)}/${String(FIXTURE_VIDEO.length)}`,
+ });
+ }
+
+ const videoMatch = /^\/api\/v1\/videos\/i\/([^/]+)$/.exec(path);
+ if (method === 'GET' && videoMatch) {
+ const video = state.videos.get(decodeURIComponent(videoMatch[1]));
+
+ return video && video.owner_user_id === MOCK_USER_ID
+ ? json(200, toVideoDto(video))
+ : json(404, { detail: 'Video not found' });
+ }
+
const workflowMatch = /^\/api\/v1\/workflows\/i\/([^/]+)(?:\/opened_at)?$/.exec(path);
if (workflowMatch) {
const workflowId = decodeURIComponent(workflowMatch[1]);
diff --git a/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs b/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs
index a5d75029f5..ab6a8e7b33 100644
--- a/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs
+++ b/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs
@@ -5,6 +5,7 @@ import process from 'node:process';
import { chromium } from 'playwright';
import { assertNoAxeViolations } from './accessibility/axe.mjs';
+import { MOCK_BACKEND_REPRESENTATIVE_VIDEO_NAME } from './mock-backend-fixtures.mjs';
import { startMockBackend } from './mock-backend.mjs';
const root = resolve(import.meta.dirname, '..');
@@ -13,6 +14,7 @@ const origin = `http://127.0.0.1:${String(port)}`;
const backendPort = Number(process.env.INVOKEAI_ACCESSIBILITY_BACKEND_PORT ?? 4179);
const backendOrigin = `http://127.0.0.1:${String(backendPort)}`;
const representativeProjectPath = '/#/app?project=fixture-project-001';
+const requestedJourney = process.env.INVOKEAI_ACCESSIBILITY_JOURNEY;
const waitForPreview = async () => {
const deadline = Date.now() + 20_000;
@@ -59,11 +61,17 @@ const openRepresentativePage = async (browser, path) => {
});
const page = await context.newPage();
const pageErrors = [];
+ const consoleErrors = [];
page.on('pageerror', (error) => pageErrors.push(error));
+ page.on('console', (message) => {
+ if (message.type() === 'error') {
+ consoleErrors.push(message.text());
+ }
+ });
await page.goto(`${origin}${path}`, { waitUntil: 'domcontentloaded' });
- return { context, page, pageErrors };
+ return { consoleErrors, context, page, pageErrors };
};
const waitForProjects = async (page) => {
@@ -245,6 +253,67 @@ const runKeyboardJourney = async (browser) => {
}
};
+const runVideoPreviewJourney = async (browser) => {
+ const { consoleErrors, context, page, pageErrors } = await openRepresentativePage(browser, representativeProjectPath);
+ const id = 'workbench-video-preview-representative';
+
+ try {
+ await waitForWorkbench(page);
+ await selectLayoutPreset(page, 'Gallery');
+
+ const gallery = page.getByRole('list', { exact: true, name: 'Gallery items' });
+ const selectVideo = page.getByRole('button', {
+ exact: true,
+ name: `Select video ${MOCK_BACKEND_REPRESENTATIVE_VIDEO_NAME}, duration 0:01, for preview`,
+ });
+
+ try {
+ await gallery.waitFor();
+ } catch (error) {
+ const bodyText = (await page.locator('body').innerText()).slice(0, 4_000);
+ throw new Error(
+ `${error instanceof Error ? error.message : String(error)}\nPage errors: ${pageErrors.map(String).join('\n')}\nConsole errors: ${consoleErrors.join('\n')}\nBody:\n${bodyText}`
+ );
+ }
+ await selectVideo.waitFor();
+ await selectVideo.focus();
+ await expectFocused(selectVideo, 'The video gallery item must be keyboard focusable.');
+ assert.equal(await selectVideo.locator('xpath=..').locator('svg.lucide-play').getAttribute('aria-hidden'), 'true');
+ await selectVideo.press('Enter');
+
+ const video = page
+ .getByRole('complementary', { exact: true, name: 'right widget panel' })
+ .locator(`video[aria-label="Video ${MOCK_BACKEND_REPRESENTATIVE_VIDEO_NAME}"]`);
+
+ try {
+ await video.waitFor();
+ } catch (error) {
+ const bodyText = (await page.locator('body').innerText()).slice(0, 4_000);
+ throw new Error(
+ `${error instanceof Error ? error.message : String(error)}\nPage errors: ${pageErrors.map(String).join('\n')}\nConsole errors: ${consoleErrors.join('\n')}\nBody:\n${bodyText}`
+ );
+ }
+ assert.equal(await video.getAttribute('controls'), '');
+ assert.equal(await video.getAttribute('playsinline'), '');
+ assert.match((await video.getAttribute('poster')) ?? '', /fixture-video-001\.mp4\/thumbnail$/);
+ assert.equal(await video.getAttribute('draggable'), null);
+ await page.getByText(/Duration 0:01/).waitFor();
+ await waitForSettledDocument(page);
+
+ // Generated media has no caption track, so only this video-specific surface
+ // disables axe's caption rule. Every other release surface keeps it enabled.
+ await assertNoAxeViolations(page, id, { rules: { 'video-caption': { enabled: false } } });
+
+ if (pageErrors.length > 0) {
+ throw new AggregateError(pageErrors, `${id} raised uncaught browser errors.`);
+ }
+
+ return { id, status: 'passed' };
+ } finally {
+ await context.close();
+ }
+};
+
const mockBackend = await startMockBackend(backendPort, { profile: 'representative' });
const preview = spawn(
'pnpm',
@@ -268,11 +337,19 @@ try {
browser = await chromium.launch({ headless: true });
const reports = [];
- for (const surface of surfaces) {
+ for (const surface of surfaces.filter(({ id }) => !requestedJourney || id === requestedJourney)) {
reports.push(await runAxeSurface(browser, surface));
}
- reports.push(await runKeyboardJourney(browser));
+ if (!requestedJourney || requestedJourney === 'keyboard-critical-journey') {
+ reports.push(await runKeyboardJourney(browser));
+ }
+ if (!requestedJourney || requestedJourney === 'workbench-video-preview-representative') {
+ reports.push(await runVideoPreviewJourney(browser));
+ }
+ if (reports.length === 0) {
+ throw new Error(`Unknown accessibility journey ${JSON.stringify(requestedJourney)}.`);
+ }
process.stdout.write(`${JSON.stringify({ profile: 'representative', reports }, null, 2)}\n`);
} catch (error) {
throw new Error(
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx
index a5f2b79615..3772502df2 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx
@@ -3,7 +3,16 @@ import type { GalleryItem, GalleryItemRef } from '@features/gallery/contracts';
import type { StreamingImageSource } from '@platform/ui/streaming-image/streamingImageSource';
import { ChakraProvider } from '@chakra-ui/react';
-import { DndContext, PointerSensor, useDndMonitor, useSensor, useSensors, type DragStartEvent } from '@dnd-kit/core';
+import {
+ DndContext,
+ KeyboardSensor,
+ PointerSensor,
+ useDndMonitor,
+ useSensor,
+ useSensors,
+ type DragStartEvent,
+} from '@dnd-kit/core';
+import { sortableKeyboardCoordinates } from '@dnd-kit/sortable';
import { DEFAULT_GALLERY_SETTINGS } from '@features/gallery/core/settings';
import { GalleryUiProvider, type GalleryUiAdapter } from '@features/gallery/react';
import { isGalleryImageDragData } from '@features/gallery/utility';
@@ -17,6 +26,7 @@ import { act, type ReactNode } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { I18nextProvider, initReactI18next } from 'react-i18next';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { userEvent } from 'vitest/browser';
import type { GalleryStateView } from './galleryStateView';
import type { GalleryActions, GalleryWidgetContextValue } from './GalleryWidgetContext';
@@ -31,6 +41,7 @@ const mocks = vi.hoisted(() => ({
virtualizerOptions: [] as Array<{
count: number;
estimateSize: () => number;
+ getScrollElement: () => Element | null;
overscan: number;
}>,
}));
@@ -47,7 +58,12 @@ vi.mock('@features/gallery/data/queries', async (importOriginal) => ({
}));
vi.mock('react-hook-tanstack-virtual', () => ({
- useVirtualizer: (options: { count: number; estimateSize: () => number; overscan: number }) => {
+ useVirtualizer: (options: {
+ count: number;
+ estimateSize: () => number;
+ getScrollElement: () => Element | null;
+ overscan: number;
+ }) => {
mocks.virtualizerOptions.push(options);
const size = options.estimateSize();
@@ -314,7 +330,10 @@ const Harness = ({
coMountPreviewSources?: boolean;
gallery: GalleryStateView;
}) => {
- const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 6 } }));
+ const sensors = useSensors(
+ useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),
+ useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates })
+ );
const contextValue: GalleryWidgetContextValue = {
actions: createActions(),
gallery,
@@ -469,6 +488,22 @@ describe('GalleryImageGrid mixed item cells', () => {
await interact(() => pointer('pointerup', videoButton.ownerDocument, 120, 80), 300);
});
+ it.each([
+ { key: '{Enter}', label: 'Enter' },
+ { key: ' ', label: 'Space' },
+ ])('opens a video with $label without activating keyboard DnD', async ({ key }) => {
+ const video = createItem('video', 'keyboard.mp4');
+
+ await renderGallery(createGallery({ items: [video] }));
+ const videoButton = getButton('Select video keyboard.mp4, duration 1:06, for preview');
+
+ await interact(() => videoButton.focus());
+ await act(() => userEvent.keyboard(key));
+
+ expect(actionMocks.selectItem).toHaveBeenCalledWith(video);
+ expect(onDragStart).not.toHaveBeenCalled();
+ });
+
it('preserves the ordered full selection when an unloaded video is dragged from a loaded image', async () => {
await renderGallery(
createGallery({
@@ -728,6 +763,18 @@ describe('GalleryImageGrid range selection', () => {
});
describe('GalleryImageGrid virtualization', () => {
+ it('keeps external-store option callbacks stable across equivalent renders', async () => {
+ const gallery = createGallery({ items: [createItem('video', 'clip.mp4')] });
+
+ await renderGallery(gallery);
+ const firstOptions = mocks.virtualizerOptions.at(-1);
+ await renderGallery({ ...gallery });
+ const secondOptions = mocks.virtualizerOptions.at(-1);
+
+ expect(secondOptions?.estimateSize).toBe(firstOptions?.estimateSize);
+ expect(secondOptions?.getScrollElement).toBe(firstOptions?.getScrollElement);
+ });
+
it('retains constant row estimates, overscan, and the near-end infinite-load trigger', async () => {
const items = Array.from({ length: 14 }, (_, index) => createItem('image', `image-${index}.png`));
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx
index 241b34ed7f..1e6c841ef0 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx
@@ -30,6 +30,7 @@ import {
useRef,
useState,
type DragEvent,
+ type KeyboardEvent,
type MouseEvent,
} from 'react';
import { useVirtualizer } from 'react-hook-tanstack-virtual';
@@ -151,11 +152,13 @@ export const GalleryImageGrid = ({ layout }: { layout: 'stacked' | 'wide' }) =>
viewportWidth > 0 ? Math.max(1, (viewportWidth - GRID_GAP_PX * (columnCount - 1)) / columnCount) : 96;
const rowHeightPx = cellSizePx + GRID_GAP_PX;
+ const estimateRowSize = useCallback(() => rowHeightPx, [rowHeightPx]);
+ const getScrollElement = useCallback(() => viewportRef.current, []);
const virtualizer = useVirtualizer({
count: rowCount,
- estimateSize: () => rowHeightPx,
- getScrollElement: () => viewportRef.current,
+ estimateSize: estimateRowSize,
+ getScrollElement,
overscan: 4,
});
@@ -782,6 +785,11 @@ const GalleryThumbnail = ({
);
const handleClick = useCallback((event: MouseEvent) => onClick(item, event), [item, onClick]);
+ const handleActivationKeyDown = useCallback((event: KeyboardEvent<HTMLButtonElement>) => {
+ if (event.key === 'Enter' || event.key === ' ') {
+ event.stopPropagation();
+ }
+ }, []);
const handleToggleStarred = useCallback(
(event: MouseEvent<HTMLButtonElement>) => {
@@ -825,6 +833,7 @@ const GalleryThumbnail = ({
style={THUMBNAIL_BUTTON_STYLE}
type="button"
onClick={handleClick}
+ onKeyDown={handleActivationKeyDown}
>
<img
alt={item.name}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsx
index a2a9ed8337..4032c1ef02 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsx
@@ -54,13 +54,13 @@ export const PreviewFooter = ({
<Stack borderWidth="1px" borderColor="border.subtle" gap="2" p="3" rounded="lg">
<HStack align="center" justify="space-between">
<HStack gap="1" minW="0">
- <Text color="fg.subtle" fontSize="2xs" fontVariantNumeric="tabular-nums" truncate>
+ <Text color="fg.muted" fontSize="2xs" fontVariantNumeric="tabular-nums" truncate>
{positionLabel}
</Text>
<Text color="fg.subtle" flexShrink={0} fontSize="2xs">
·
</Text>
- <Text color="fg.subtle" flexShrink={0} fontSize="2xs" fontVariantNumeric="tabular-nums">
+ <Text color="fg.muted" flexShrink={0} fontSize="2xs" fontVariantNumeric="tabular-nums">
{item.width} × {item.height}
{item.kind === 'video'
? ` · ${t('widgets.preview.videoDuration', {
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsx
index 8b3dbff585..3c93f32606 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsx
@@ -2,7 +2,7 @@
import type { GalleryImageItem, GalleryVideoItem } from '@features/gallery';
import type { ImageActions } from '@workbench/image-actions';
-import { ChakraProvider } from '@chakra-ui/react';
+import { ChakraProvider, Text } from '@chakra-ui/react';
import { DndContext, PointerSensor, useDndMonitor, useSensor, useSensors, type DragStartEvent } from '@dnd-kit/core';
import { system } from '@theme/system';
import { createInstance } from 'i18next';
@@ -220,6 +220,43 @@ describe('PreviewFilmstrip mixed media', () => {
});
describe('Preview mixed media footer and actions', () => {
+ it('uses the readable muted foreground for compact image and video footer text', async () => {
+ for (const item of [sharedImage, sharedVideo]) {
+ await render(
+ <>
+ <Text color="fg.muted" data-testid="expected-muted">
+ Expected muted
+ </Text>
+ <PreviewFooter
+ actionImage={null}
+ actions={{} as ImageActions}
+ boardItemCount={3}
+ isLoadingBoard={false}
+ isMetadataOpen={false}
+ item={item}
+ selectedIndex={1}
+ onNext={() => undefined}
+ onPrevious={() => undefined}
+ onToggleMetadata={() => undefined}
+ />
+ </>
+ );
+
+ const position = Array.from(host!.querySelectorAll<HTMLElement>('p')).find((element) =>
+ element.textContent?.includes('2 of 3')
+ );
+ const dimensions = Array.from(host!.querySelectorAll<HTMLElement>('p')).find((element) =>
+ element.textContent?.includes(`${item.width} × ${item.height}`)
+ );
+ const details = host!.querySelector<HTMLElement>('button[aria-expanded="false"]');
+ const mutedColor = getComputedStyle(host!.querySelector<HTMLElement>('[data-testid="expected-muted"]')!).color;
+
+ expect(getComputedStyle(position!).color).toBe(mutedColor);
+ expect(getComputedStyle(dimensions!).color).toBe(mutedColor);
+ expect(getComputedStyle(details!).color).toBe(mutedColor);
+ }
+ });
+
it('shows mixed position, dimensions, duration, and localized fps with tabular numerals', async () => {
await render(
<PreviewFooter
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
index 7141a74d10..1ee7f8d0a3 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
@@ -53,7 +53,7 @@ export const PreviewMetadataPanel = ({
<HStack
as="button"
aria-expanded={isOpen}
- color="fg.subtle"
+ color="fg.muted"
cursor="pointer"
gap="1"
w="fit-content"