Compare commits
2 Commits
09c91fe452
...
5a0500d7b4
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a0500d7b4 | |||
| 071c225b2d |
Generated
+8
-8
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "68916c1b58d9ce06a59f6c58e4a2d226",
|
||||
"content-hash": "d1b5f8dbf4a0d0bfddbd1473bf180da7",
|
||||
"packages": [
|
||||
{
|
||||
"name": "laravel/serializable-closure",
|
||||
@@ -1946,16 +1946,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "12.5.31",
|
||||
"version": "12.5.32",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "0608d157a284f15cc73b99a3327eff06b66a176d"
|
||||
"reference": "c02591dd7840ed124a98d7770753329ad28e9f8f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0608d157a284f15cc73b99a3327eff06b66a176d",
|
||||
"reference": "0608d157a284f15cc73b99a3327eff06b66a176d",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c02591dd7840ed124a98d7770753329ad28e9f8f",
|
||||
"reference": "c02591dd7840ed124a98d7770753329ad28e9f8f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2024,7 +2024,7 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.31"
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.32"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -2032,7 +2032,7 @@
|
||||
"type": "other"
|
||||
}
|
||||
],
|
||||
"time": "2026-07-06T14:54:16+00:00"
|
||||
"time": "2026-07-25T06:54:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
@@ -3057,5 +3057,5 @@
|
||||
"ext-iconv": "*"
|
||||
},
|
||||
"platform-dev": {},
|
||||
"plugin-api-version": "2.6.0"
|
||||
"plugin-api-version": "2.9.0"
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { useLayoutStore } from '@KTXC/stores/layoutStore'
|
||||
import { useTenantStore } from '@KTXC/stores/tenantStore'
|
||||
import { useUserStore } from '@KTXC/stores/userStore'
|
||||
|
||||
const userServiceMock = vi.hoisted(() => ({
|
||||
updateProfile: vi.fn(() => Promise.resolve()),
|
||||
updateSettings: vi.fn(() => Promise.resolve()),
|
||||
flushAll: vi.fn(() => Promise.resolve()),
|
||||
}))
|
||||
|
||||
vi.mock('@KTXC/services/user/userService', () => ({
|
||||
userService: userServiceMock,
|
||||
}))
|
||||
|
||||
describe('layoutStore', () => {
|
||||
beforeEach(() => {
|
||||
const storage = new Map<string, string>()
|
||||
vi.stubGlobal('localStorage', {
|
||||
getItem: vi.fn((key: string) => storage.get(key) ?? null),
|
||||
setItem: vi.fn((key: string, value: string) => storage.set(key, value)),
|
||||
removeItem: vi.fn((key: string) => storage.delete(key)),
|
||||
clear: vi.fn(() => storage.clear()),
|
||||
})
|
||||
setActivePinia(createPinia())
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('hydrates initial layout preferences after settings are loaded', () => {
|
||||
const userStore = useUserStore()
|
||||
const tenantStore = useTenantStore()
|
||||
|
||||
const layoutStore = useLayoutStore()
|
||||
expect(layoutStore.sidebarDrawer).toBe(true)
|
||||
expect(layoutStore.miniSidebar).toBe(false)
|
||||
expect(layoutStore.theme).toBe('light')
|
||||
|
||||
tenantStore.init({
|
||||
id: 'tenant',
|
||||
domain: 'example.test',
|
||||
label: 'Example',
|
||||
settings: {
|
||||
theme_default_mode: 'dark',
|
||||
},
|
||||
})
|
||||
userStore.init({
|
||||
settings: {
|
||||
sidebar_drawer: false,
|
||||
mini_sidebar: true,
|
||||
theme: 'system',
|
||||
},
|
||||
})
|
||||
|
||||
layoutStore.hydrateFromSettings()
|
||||
|
||||
expect(layoutStore.sidebarDrawer).toBe(false)
|
||||
expect(layoutStore.miniSidebar).toBe(true)
|
||||
expect(layoutStore.theme).toBe('system')
|
||||
expect(userServiceMock.updateSettings).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('continues to persist user-driven layout changes', () => {
|
||||
const layoutStore = useLayoutStore()
|
||||
|
||||
layoutStore.toggleSidebarDrawer()
|
||||
layoutStore.setMiniSidebar(true)
|
||||
layoutStore.setTheme('dark')
|
||||
|
||||
expect(userServiceMock.updateSettings).toHaveBeenCalledWith({ sidebar_drawer: false })
|
||||
expect(userServiceMock.updateSettings).toHaveBeenCalledWith({ mini_sidebar: true })
|
||||
expect(userServiceMock.updateSettings).toHaveBeenCalledWith({ theme: 'dark' })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user