diff --git a/__test__/layout/account-menu.spec.ts b/__test__/layout/account-menu.spec.ts
new file mode 100644
index 00000000..6e576b98
--- /dev/null
+++ b/__test__/layout/account-menu.spec.ts
@@ -0,0 +1,45 @@
+import { avatarDropdownClick } from '../../apps/admin/src/layout/components/SiderBar/shared'
+
+const { logout, createDialog, showError, push } = vi.hoisted(() => ({
+ logout: vi.fn(),
+ createDialog: vi.fn(),
+ showError: vi.fn(),
+ push: vi.fn(),
+}))
+
+vi.mock('@/store', () => ({
+ useSigningActions: () => ({ logout }),
+ useSettingActions: () => ({ updateSettingState: vi.fn() }),
+}))
+vi.mock('@/hooks', () => ({ useI18n: () => ({ t: (key: string) => key }) }))
+vi.mock('@/router', () => ({ router: { push } }))
+
+beforeEach(() => {
+ vi.clearAllMocks()
+ window.$dialog = { create: createDialog } as unknown as typeof window.$dialog
+ window.$message = { error: showError } as unknown as typeof window.$message
+})
+
+it('confirms sign-out with the active primary color before ending the session', async () => {
+ logout.mockResolvedValue(void 0)
+ await avatarDropdownClick('logout')
+
+ expect(logout).not.toHaveBeenCalled()
+ const dialog = createDialog.mock.calls[0]![0]
+
+ expect(dialog).toMatchObject({
+ title: 'signOut',
+ showIcon: false,
+ positiveButtonProps: { type: 'primary' },
+ })
+ expect(await dialog.onPositiveClick()).toBe(true)
+ expect(logout).toHaveBeenCalledOnce()
+})
+
+it('keeps the confirmation open and reports a failed sign-out', async () => {
+ logout.mockRejectedValue(new Error('offline'))
+ await avatarDropdownClick('logout')
+
+ expect(await createDialog.mock.calls[0]![0].onPositiveClick()).toBe(false)
+ expect(showError).toHaveBeenCalledWith('signOutFailed')
+})
diff --git a/__test__/layout/mobile-search.spec.ts b/__test__/layout/mobile-search.spec.ts
index 75eb8f10..7535b6db 100644
--- a/__test__/layout/mobile-search.spec.ts
+++ b/__test__/layout/mobile-search.spec.ts
@@ -1,22 +1,63 @@
-import { mount } from '@vue/test-utils'
+import { flushPromises, mount } from '@vue/test-utils'
import GlobalSearch from '../../apps/admin/src/layout/components/Search/GlobalSearch'
import { router } from '../../apps/admin/src/router'
+import { piniaMenuStore } from '../../apps/admin/src/store/modules/menu'
import setupMiniApp from '../utils/setupMiniApp'
-it('mounts the header search on a narrow viewport and closes it immediately', async () => {
+it('keeps page search available on phones and lets a search result close the dialog', async () => {
vi.stubGlobal('innerWidth', 390)
const { app } = await setupMiniApp()
+ const menu = piniaMenuStore()
+
+ menu.options = [
+ {
+ path: '/visible',
+ fullPath: '/visible',
+ key: '/visible',
+ name: 'visible',
+ breadcrumbLabel: 'Visible page',
+ label: 'Visible page',
+ meta: {},
+ },
+ ]
+ const navigate = vi
+ .spyOn(menu, 'changeMenuModelValue')
+ .mockImplementation(() => void 0)
+ const wrapper = mount(GlobalSearch, {
+ attachTo: document.body,
+ props: { show: true },
+ global: {
+ plugins: [router],
+ stubs: {
+ teleport: true,
+ RIcon: { inheritAttrs: false, template: '' },
+ },
+ },
+ })
try {
- const wrapper = mount(GlobalSearch, {
- props: { show: true },
- global: { plugins: [router] },
- })
+ await flushPromises()
+ expect(wrapper.emitted('update:show')).toBeUndefined()
+ expect(wrapper.find('.global-search').exists()).toBe(true)
+ await wrapper.get('input').setValue('Visible')
+ await flushPromises()
+ expect(wrapper.findAll('.global-search__destination')).toHaveLength(1)
+ vi.stubGlobal('innerWidth', 1440)
+ window.dispatchEvent(new Event('resize'))
+ await flushPromises()
+ expect(wrapper.emitted('update:show')).toBeUndefined()
+ expect(wrapper.get('input').element.value).toBe('Visible')
+
+ await wrapper.get('.global-search__destination').trigger('click')
+ await flushPromises()
+ expect(navigate).toHaveBeenCalledWith(
+ '/visible',
+ expect.objectContaining({ fullPath: '/visible' }),
+ )
expect(wrapper.emitted('update:show')).toContainEqual([false])
- expect(wrapper.find('.global-search').exists()).toBe(false)
- wrapper.unmount()
} finally {
+ wrapper.unmount()
app.unmount()
vi.unstubAllGlobals()
}
diff --git a/__test__/layout/sidebar-scroll.spec.ts b/__test__/layout/sidebar-scroll.spec.ts
index 3f626af6..b0d32be8 100644
--- a/__test__/layout/sidebar-scroll.spec.ts
+++ b/__test__/layout/sidebar-scroll.spec.ts
@@ -1,12 +1,14 @@
-import { mount } from '@vue/test-utils'
+import { flushPromises, mount } from '@vue/test-utils'
import { createPinia, disposePinia, setActivePinia } from 'pinia'
import { nextTick } from 'vue'
import { useSiderScroll } from '../../apps/admin/src/hooks/template/useSiderScroll'
import Menu from '../../apps/admin/src/layout/components/Menu'
import { router } from '../../apps/admin/src/router'
import { piniaMenuStore } from '../../apps/admin/src/store/modules/menu'
+import { piniaRuntimeStore } from '../../apps/admin/src/store/modules/runtime'
import { piniaSettingStore } from '../../apps/admin/src/store/modules/setting'
import { positionSelectedMenuItem } from '../../apps/admin/src/utils'
+import setupMiniApp from '../utils/setupMiniApp'
it.each([
[true, '.n-layout-scroll-container'],
@@ -78,3 +80,46 @@ it.each([
}
},
)
+
+it('keeps the desktop collapse preference while the phone menu opens and closes', async () => {
+ vi.stubGlobal('innerWidth', 390)
+ const { app } = await setupMiniApp()
+ const menu = piniaMenuStore()
+ const runtime = piniaRuntimeStore()
+
+ menu.updateMenuState('collapsed', true)
+ runtime.setRuntimeState('globalDrawerValue', true)
+ const wrapper = mount(Menu, {
+ attachTo: document.body,
+ global: {
+ plugins: [router],
+ stubs: {
+ teleport: true,
+ RIcon: { inheritAttrs: false, template: '' },
+ },
+ },
+ })
+
+ try {
+ await flushPromises()
+ expect(menu.collapsed).toBe(true)
+ expect(wrapper.find('.app-menu__mobile-heading').exists()).toBe(true)
+ expect(wrapper.find('.n-layout-sider--collapsed').exists()).toBe(false)
+
+ await wrapper.get('.app-menu__close').trigger('click')
+ expect(runtime.globalDrawerValue).toBe(false)
+ runtime.setRuntimeState('globalDrawerValue', true)
+
+ vi.stubGlobal('innerWidth', 1440)
+ window.dispatchEvent(new Event('resize'))
+ await flushPromises()
+ expect(runtime.globalDrawerValue).toBe(false)
+ expect(menu.collapsed).toBe(true)
+ expect(wrapper.find('.app-menu__mobile-heading').exists()).toBe(false)
+ expect(wrapper.find('.n-layout-sider--collapsed').exists()).toBe(true)
+ } finally {
+ wrapper.unmount()
+ app.unmount()
+ vi.unstubAllGlobals()
+ }
+})
diff --git a/__test__/layout/workspace-settings.spec.tsx b/__test__/layout/workspace-settings.spec.tsx
index e6f964ab..b5ec0c36 100644
--- a/__test__/layout/workspace-settings.spec.tsx
+++ b/__test__/layout/workspace-settings.spec.tsx
@@ -16,6 +16,71 @@ describe('workspace preference shortcuts', () => {
afterEach(() => disposePinia(pinia))
+ it('identifies the default spacing when settings first opens', () => {
+ const wrapper = mount(Layout, { global: { plugins: [pinia] } })
+
+ try {
+ const selected = wrapper.findAll(
+ '.r-workspace-presets button[aria-pressed="true"]',
+ )
+
+ expect(selected).toHaveLength(1)
+ expect(selected[0].text()).toContain('preferences.layout.spacious')
+ expect(wrapper.get('.r-workspace-presets__current').text()).toContain(
+ '24 px',
+ )
+ } finally {
+ wrapper.unmount()
+ }
+ })
+
+ it.each([
+ { contentWidth: 'fluid' as const, contentPadding: 16 },
+ {
+ contentWidth: 'fixed' as const,
+ contentMaxWidth: 1200,
+ contentPadding: 24,
+ },
+ ])('shows saved custom spacing without changing it: %j', async (layout) => {
+ const store = piniaSettingStore()
+
+ store.updateSettingState('layoutConfig', layout)
+ const previousLayout = { ...store.layoutConfig }
+ const wrapper = mount(Layout, { global: { plugins: [pinia] } })
+
+ try {
+ const current = wrapper.get('.r-workspace-presets__current')
+
+ expect(current.text()).toContain('preferences.layout.custom')
+ expect(current.text()).toContain(`${layout.contentPadding} px`)
+ expect(
+ wrapper.findAll('.r-workspace-presets button[aria-pressed="true"]'),
+ ).toHaveLength(0)
+ expect(store.layoutConfig).toEqual(previousLayout)
+
+ await wrapper
+ .findAll('.r-workspace-presets button')
+ .find((button) => button.text() === 'preferences.layout.compact')!
+ .trigger('click')
+
+ expect(current.text()).toContain('preferences.layout.compact')
+ expect(current.text()).toContain('8 px')
+ expect(
+ wrapper.get('.r-workspace-presets button[aria-pressed="true"]').text(),
+ ).toContain('preferences.layout.compact')
+
+ await wrapper
+ .findAll('button')
+ .find((button) => button.text() === 'layout.reset')!
+ .trigger('click')
+
+ expect(current.text()).toContain('preferences.layout.spacious')
+ expect(current.text()).toContain('24 px')
+ } finally {
+ wrapper.unmount()
+ }
+ })
+
it('applies reading spacing without replacing navigation or fixed bars', async () => {
const store = piniaSettingStore()
diff --git a/apps/admin/src/app-components/app/AppAvatar/index.tsx b/apps/admin/src/app-components/app/AppAvatar/index.tsx
index 39eba97a..18db672a 100644
--- a/apps/admin/src/app-components/app/AppAvatar/index.tsx
+++ b/apps/admin/src/app-components/app/AppAvatar/index.tsx
@@ -84,12 +84,13 @@ const AppAvatar = defineComponent({
return (