Skip to content

Commit 17364ab

Browse files
fix(test): fix type-to-jump pagination compat and loading state race
- type-to-jump: use _setSectionTracks to inject test tracks instead of mutating the array returned by the paginated filteredTracks getter (unshift on a freshly built array was silently lost) - error-states: combine set+read in single evaluate to prevent race with background library load() clearing the loading flag Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 71ad8a6 commit 17364ab

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

app/frontend/tests/error-states.spec.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,21 +547,19 @@ test.describe('Loading States', () => {
547547
});
548548

549549
test('should track library loading state', async ({ page }) => {
550-
// Set library to loading state
551-
await page.evaluate(() => {
550+
// Set and read in a single evaluate to avoid race with background load()
551+
const loadingAfterSet = await page.evaluate(() => {
552552
window.Alpine.store('library').loading = true;
553+
return window.Alpine.store('library').loading;
553554
});
555+
expect(loadingAfterSet).toBe(true);
554556

555-
const libraryStore = await getAlpineStore(page, 'library');
556-
expect(libraryStore.loading).toBe(true);
557-
558-
// Complete loading
559-
await page.evaluate(() => {
557+
// Complete loading and verify
558+
const loadingAfterClear = await page.evaluate(() => {
560559
window.Alpine.store('library').loading = false;
560+
return window.Alpine.store('library').loading;
561561
});
562-
563-
const updatedStore = await getAlpineStore(page, 'library');
564-
expect(updatedStore.loading).toBe(false);
562+
expect(loadingAfterClear).toBe(false);
565563
});
566564
});
567565

app/frontend/tests/library-type-to-jump.spec.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,9 @@ test.describe('Type-to-jump artist navigation (task-255)', () => {
404404
// because stripped "la's" starts with "la".
405405
await page.evaluate(() => {
406406
const library = window.Alpine.store('library');
407-
// Insert in backend sort order: "La's" < "Lana Del Rey" alphabetically
408-
library.tracks.unshift(
407+
// Prepend test tracks via _setSectionTracks to bypass paginated getter
408+
const existing = library.filteredTracks;
409+
const testTracks = [
409410
{
410411
id: 9999,
411412
title: 'There She Goes',
@@ -422,8 +423,9 @@ test.describe('Type-to-jump artist navigation (task-255)', () => {
422423
duration: 180,
423424
filepath: '/music/test/decoy.mp3',
424425
},
425-
);
426-
library.applyFilters();
426+
];
427+
library._setSectionTracks([...testTracks, ...existing]);
428+
library.totalTracks = testTracks.length + existing.length;
427429
window.Alpine.store('ui').sortIgnoreWords = true;
428430
window.Alpine.store('ui').sortIgnoreWordsList = 'the, a, an, la, le, les, los, las, el';
429431
});

0 commit comments

Comments
 (0)