Skip to content

Commit 858a1e1

Browse files
fix(ci): add library count mock for pagination and gate builds on rust job
Add /api/library/count route to E2E mock fixtures so the paginated library store can fetch track count metadata in non-Tauri (Playwright) context. Without this, accessibility tests timeout waiting for tracks that never render. Gate cross-platform builds on rust lint/format/test job to avoid wasting CI minutes when Rust checks fail. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c9afdf2 commit 858a1e1

2 files changed

Lines changed: 37 additions & 11 deletions

File tree

.github/workflows/test.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,9 @@ jobs:
9999

100100
build:
101101
name: Build (${{ matrix.platform }})
102-
# Only gate on deno-lint (fast, validates frontend source).
103-
# Test jobs (rust, vitest, playwright) run in parallel — they don't
104-
# produce artifacts the build matrix consumes, so waiting for them
105-
# just lengthens wall-clock time.
106-
needs: [deno-lint]
102+
# Gate on lint/format/test jobs so builds don't burn CI minutes
103+
# when basic checks fail.
104+
needs: [deno-lint, rust]
107105
strategy:
108106
fail-fast: false
109107
matrix:

app/frontend/tests/fixtures/mock-library.js

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function filterAndSortTracks(tracks, params) {
227227
(t) =>
228228
t.title?.toLowerCase().includes(query) ||
229229
t.artist?.toLowerCase().includes(query) ||
230-
t.album?.toLowerCase().includes(query)
230+
t.album?.toLowerCase().includes(query),
231231
);
232232

233233
// Calculate and attach search scores for ranking
@@ -246,14 +246,14 @@ function filterAndSortTracks(tracks, params) {
246246
// Artist filter
247247
if (params.artist) {
248248
result = result.filter(
249-
(t) => t.artist?.toLowerCase() === params.artist.toLowerCase()
249+
(t) => t.artist?.toLowerCase() === params.artist.toLowerCase(),
250250
);
251251
}
252252

253253
// Album filter
254254
if (params.album) {
255255
result = result.filter(
256-
(t) => t.album?.toLowerCase() === params.album.toLowerCase()
256+
(t) => t.album?.toLowerCase() === params.album.toLowerCase(),
257257
);
258258
}
259259

@@ -351,6 +351,35 @@ export async function setupLibraryMocks(page, state) {
351351
});
352352
});
353353

354+
// GET /api/library/count - get filtered count and total duration (pagination support)
355+
await page.route(/\/api\/library\/count(\?.*)?$/, async (route, request) => {
356+
if (request.method() !== 'GET') {
357+
await route.continue();
358+
return;
359+
}
360+
361+
const url = new URL(request.url());
362+
const params = Object.fromEntries(url.searchParams);
363+
state.apiCalls.push({ method: 'GET', url: '/api/library/count', params });
364+
365+
// Use filterAndSortTracks without pagination to get all matching tracks
366+
const filtered = filterAndSortTracks(state.tracks, {
367+
...params,
368+
limit: undefined,
369+
offset: undefined,
370+
});
371+
const totalDuration = filtered.tracks.reduce((sum, t) => sum + (t.duration || 0), 0);
372+
373+
await route.fulfill({
374+
status: 200,
375+
contentType: 'application/json',
376+
body: JSON.stringify({
377+
total: filtered.total,
378+
total_duration: totalDuration,
379+
}),
380+
});
381+
});
382+
354383
// GET /api/library/stats - get library statistics
355384
await page.route(/\/api\/library\/stats(\?.*)?$/, async (route, request) => {
356385
if (request.method() !== 'GET') {
@@ -437,7 +466,8 @@ export async function setupLibraryMocks(page, state) {
437466
status: 200,
438467
contentType: 'application/json',
439468
body: JSON.stringify({
440-
data: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==',
469+
data:
470+
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==',
441471
mime_type: 'image/png',
442472
source: 'mock',
443473
}),
@@ -661,7 +691,6 @@ export async function setupLibraryMocks(page, state) {
661691
});
662692
}
663693

664-
665694
/**
666695
* Helper to clear API call history
667696
* @param {Object} state - State from createLibraryState()
@@ -686,4 +715,3 @@ export function findApiCalls(state, method, urlPattern) {
686715
return urlPattern.test(call.url);
687716
});
688717
}
689-

0 commit comments

Comments
 (0)