mirror of
https://github.com/zammad/zammad
synced 2026-05-24 09:48:36 +00:00
Co-authored-by: Dominik Klein <dk@zammad.com> Co-authored-by: Benjamin Scharf <bs@zammad.com> Co-authored-by: Dusan Vuckovic <dv@zammad.com> Co-authored-by: Florian Liebe <fl@zammad.com> Co-authored-by: Joe Schroecker <js@zammad.com> Co-authored-by: Mantas Masalskis <mm@zammad.com>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
// Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
|
|
|
|
import { createTestingPinia } from '@pinia/testing'
|
|
|
|
import { useApplicationStore } from '#shared/stores/application.ts'
|
|
|
|
import type { TestingPinia } from '@pinia/testing'
|
|
import type { Store } from 'pinia'
|
|
|
|
let storeInitialized = false
|
|
let pinia: TestingPinia
|
|
export const getTestPinia = () => pinia
|
|
const stores = new Set<Store>()
|
|
|
|
export const initializeStore = () => {
|
|
if (storeInitialized) return pinia
|
|
|
|
pinia = createTestingPinia({ createSpy: vi.fn, stubActions: false })
|
|
// plugins.push({ install: pinia.install })
|
|
pinia.use((context) => {
|
|
stores.add(context.store)
|
|
})
|
|
storeInitialized = true
|
|
const app = useApplicationStore()
|
|
app.config.product_logo = 'logo.svg'
|
|
app.config.product_name = 'Zammad'
|
|
app.config.ticket_hook = 'Ticket#'
|
|
app.config.api_path = '/api'
|
|
app.config.pretty_date_format = 'relative'
|
|
app.config.locale_default = 'en-us'
|
|
return pinia
|
|
}
|
|
|
|
export const cleanupStores = () => {
|
|
if (!storeInitialized) return
|
|
|
|
stores.forEach((store) => {
|
|
store.$dispose()
|
|
})
|
|
pinia.state.value = {}
|
|
stores.clear()
|
|
}
|