mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 10:42:44 +00:00
test: add cloud mode test for bootstrapStore
Amp-Thread-ID: https://ampcode.com/threads/T-019bfd62-e2e1-7797-849b-919a0e8cf4e7 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -49,23 +49,36 @@ vi.mock('@/stores/userStore', () => ({
|
|||||||
}))
|
}))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe('bootstrapStore', () => {
|
const mockIsFirebaseInitialized = ref(false)
|
||||||
let store: ReturnType<typeof useBootstrapStore>
|
vi.mock('@/stores/firebaseAuthStore', () => ({
|
||||||
|
useFirebaseAuthStore: vi.fn(() => ({
|
||||||
|
isInitialized: mockIsFirebaseInitialized
|
||||||
|
}))
|
||||||
|
}))
|
||||||
|
|
||||||
|
const mockDistributionTypes = vi.hoisted(() => ({
|
||||||
|
isCloud: false
|
||||||
|
}))
|
||||||
|
vi.mock('@/platform/distribution/types', () => mockDistributionTypes)
|
||||||
|
|
||||||
|
describe('bootstrapStore', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockIsSettingsReady.value = false
|
mockIsSettingsReady.value = false
|
||||||
|
mockIsFirebaseInitialized.value = false
|
||||||
|
mockDistributionTypes.isCloud = false
|
||||||
setActivePinia(createTestingPinia({ stubActions: false }))
|
setActivePinia(createTestingPinia({ stubActions: false }))
|
||||||
store = useBootstrapStore()
|
|
||||||
vi.clearAllMocks()
|
vi.clearAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('initializes with all flags false', () => {
|
it('initializes with all flags false', () => {
|
||||||
|
const store = useBootstrapStore()
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
expect(settingStore.isReady).toBe(false)
|
expect(settingStore.isReady).toBe(false)
|
||||||
expect(store.isI18nReady).toBe(false)
|
expect(store.isI18nReady).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('starts store bootstrap (settings, i18n)', async () => {
|
it('starts store bootstrap (settings, i18n)', async () => {
|
||||||
|
const store = useBootstrapStore()
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
void store.startStoreBootstrap()
|
void store.startStoreBootstrap()
|
||||||
|
|
||||||
@@ -74,4 +87,29 @@ describe('bootstrapStore', () => {
|
|||||||
expect(store.isI18nReady).toBe(true)
|
expect(store.isI18nReady).toBe(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('cloud mode', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
mockDistributionTypes.isCloud = true
|
||||||
|
})
|
||||||
|
|
||||||
|
it('waits for Firebase auth before loading i18n and settings', async () => {
|
||||||
|
const store = useBootstrapStore()
|
||||||
|
const settingStore = useSettingStore()
|
||||||
|
const bootstrapPromise = store.startStoreBootstrap()
|
||||||
|
|
||||||
|
// Bootstrap is blocked waiting for firebase
|
||||||
|
expect(store.isI18nReady).toBe(false)
|
||||||
|
expect(settingStore.isReady).toBe(false)
|
||||||
|
|
||||||
|
// Unblock by initializing firebase
|
||||||
|
mockIsFirebaseInitialized.value = true
|
||||||
|
await bootstrapPromise
|
||||||
|
|
||||||
|
await vi.waitFor(() => {
|
||||||
|
expect(store.isI18nReady).toBe(true)
|
||||||
|
expect(settingStore.isReady).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user