diff --git a/fe/src/__tests__/CollectionView.spec.ts b/fe/src/__tests__/CollectionView.spec.ts index 6511d032a..958914d31 100644 --- a/fe/src/__tests__/CollectionView.spec.ts +++ b/fe/src/__tests__/CollectionView.spec.ts @@ -1284,4 +1284,53 @@ describe('CollectionView', () => { 'Updated the author image, description, related authors, and catalog.', ) }) + + it('renders the per-collection series position for a book matched via a non-primary membership', async () => { + const pinia = createPinia() + setActivePinia(pinia) + + const router = createRouter({ + history: createMemoryHistory(), + routes: [ + { path: '/', name: 'home', component: { template: '
' } }, + { path: '/collection/:type/:name', name: 'collection', component: CollectionView }, + ], + }) + await router.push('/collection/series/Mistborn') + await router.isReady().catch(() => {}) + + const store = useLibraryStore() + store.audiobooks = [ + { + id: 1, + title: 'Shadows of Self', + authors: ['Brandon Sanderson'], + // Primary series (and number) point at a DIFFERENT series... + series: 'Other Series', + seriesNumber: '5', + // ...but the book also belongs to Mistborn at position 2. + seriesMemberships: [ + { seriesName: 'Other Series', seriesNumber: '5', isPrimary: true }, + { seriesName: 'Mistborn', seriesNumber: '2', isPrimary: false }, + ], + imageUrl: 'c1.jpg', + files: [], + }, + ] as unknown as import('@/types').Audiobook[] + + store.fetchLibrary = vi.fn(async () => undefined) + const wrapper = mount(CollectionView, { + global: { + plugins: [pinia, router], + stubs: ['EditAudiobookModal', 'CustomSelect', 'AddLibraryModal'], + }, + }) + await flushPromises() + + const card = wrapper.find('.collection-card') + expect(card.exists()).toBe(true) + // Shows the Mistborn position (#2 from the membership), not the primary 'Other Series' #5. + expect(card.text()).toContain('#2') + expect(card.text()).not.toContain('#5') + }) }) diff --git a/fe/src/__tests__/EditAudiobookModal.moveOptions.spec.ts b/fe/src/__tests__/EditAudiobookModal.moveOptions.spec.ts index 17590007a..30f882c7b 100644 --- a/fe/src/__tests__/EditAudiobookModal.moveOptions.spec.ts +++ b/fe/src/__tests__/EditAudiobookModal.moveOptions.spec.ts @@ -256,6 +256,54 @@ describe('EditAudiobookModal move options', () => { ) }) + it('persists a non-first primary series selection (regression for #658)', async () => { + const wrapper = mount(EditAudiobookModal, { + props: { isOpen: true, audiobook }, + attachTo: document.body, + global: { plugins: [(await import('pinia')).createPinia()] }, + }) + + await new Promise((r) => setTimeout(r, 200)) + + const vm = wrapper.vm as unknown as { + formData: { + seriesMemberships: Array<{ seriesName: string; seriesNumber: string; isPrimary: boolean }> + } + handleSave: () => Promise