This commit is contained in:
2026-10-21 16:40:10 +08:00
parent 8356e98ce3
commit e2f99b4f4b
18 changed files with 391 additions and 52 deletions
@@ -93,3 +93,19 @@ it.each(['success', 'failure'])('keeps rows stable during a refresh but rejects
expect(() => state.assertCurrent(previous)).toThrow('尚未读取完成')
}
})
it('allows mixed-warehouse pages only for the explicitly regional workspace and pins restored drafts to their warehouse', async () => {
const error = ref<ApiErrorDetails | null>(null)
const state = useDispatchCandidates(error, listDispatchCandidates, true)
const second = candidate({ sourceKey: 'ny-source', warehouseId: '654' })
vi.mocked(listDispatchCandidates).mockResolvedValueOnce(response({ candidates: [candidate(), second] }))
await state.load({ warehouseTab: 'ALL' })
expect(state.candidates.value).toHaveLength(2)
expect(() => state.assertCurrent([second])).not.toThrow()
vi.mocked(listDispatchCandidates).mockResolvedValueOnce(response({ candidates: [candidate()] }))
await state.load({ warehouseId: '321', warehouseTab: 'ALL', draftToken: 'server-token' })
expect(() => state.assertCurrent([second])).toThrow('组成已变化')
const scoped = setup()
await scoped.load({ warehouseTab: 'ALL' })
expect(listDispatchCandidates).toHaveBeenCalledTimes(2)
})