fix: avoid duplicate backlog hydration load

This commit is contained in:
Janpeter Visser 2026-05-10 07:17:28 +02:00
parent b489e26665
commit 38d99834ef
5 changed files with 47 additions and 8 deletions

View file

@ -257,6 +257,35 @@ describe('selection cascade', () => {
expect(s.relations.taskIdsByStory).toEqual({})
expect(s.loading.loadedProductId).toBeNull()
})
it('setActiveProduct kan alleen context zetten zonder full backlog load', () => {
useProductWorkspaceStore.getState().hydrateSnapshot(
snapshotWith(
[makePbi({ id: 'p-1' })],
{ 'p-1': [makeStory({ id: 's-1', pbi_id: 'p-1' })] },
{ 's-1': [makeTask({ id: 't-1', story_id: 's-1' })] },
{ id: 'prod-1', name: 'Product 1' },
),
)
useProductWorkspaceStore.setState((s) => {
s.context.activePbiId = 'p-1'
s.context.activeStoryId = 's-1'
})
const fetchSpy = vi.spyOn(globalThis, 'fetch')
useProductWorkspaceStore
.getState()
.setActiveProduct(
{ id: 'prod-1', name: 'Product 1' },
{ load: false, preserveSelection: true },
)
const s = useProductWorkspaceStore.getState()
expect(fetchSpy).not.toHaveBeenCalled()
expect(s.context.activePbiId).toBe('p-1')
expect(s.context.activeStoryId).toBe('s-1')
expect(s.entities.pbisById['p-1']).toBeDefined()
})
})
// ─────────────────────────────────────────────────────────────────────────