refactor: move workflow loading state from bootstrapStore to workflowStore

- Add useAsyncState in workflowStore for syncWorkflows with loading state

- Add loadWorkflows action that guards against double-loading

- Simplify bootstrapStore by delegating workflow loading to workflowStore

- Update test mocks for workflowStore

Amp-Thread-ID: https://ampcode.com/threads/T-019bfcce-cce0-70b0-abc6-742669ac86e3
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Alexander Brown
2026-01-26 16:44:52 -08:00
parent c171227d28
commit 35eb0286e5
3 changed files with 65 additions and 95 deletions

View File

@@ -33,11 +33,10 @@ vi.mock('@/platform/settings/settingStore', () => ({
}))
}))
vi.mock('@/stores/workspaceStore', () => ({
useWorkspaceStore: vi.fn(() => ({
workflow: {
syncWorkflows: vi.fn().mockResolvedValue(undefined)
}
vi.mock('@/platform/workflow/management/stores/workflowStore', () => ({
useWorkflowStore: vi.fn(() => ({
loadWorkflows: vi.fn(),
syncWorkflows: vi.fn().mockResolvedValue(undefined)
}))
}))
@@ -53,23 +52,10 @@ describe('bootstrapStore', () => {
it('initializes with all flags false', () => {
const settingStore = useSettingStore()
expect(store.isNodeDefsReady).toBe(false)
expect(settingStore.isReady).toBe(false)
expect(store.isI18nReady).toBe(false)
})
it('starts early bootstrap (node defs)', async () => {
const { api } = await import('@/scripts/api')
store.startEarlyBootstrap()
await vi.waitFor(() => {
expect(store.isNodeDefsReady).toBe(true)
})
expect(api.getNodeDefs).toHaveBeenCalled()
})
it('starts store bootstrap (settings, i18n)', async () => {
const settingStore = useSettingStore()
void store.startStoreBootstrap()