auth page enhancement

This commit is contained in:
2026-03-18 18:04:41 +08:00
parent b6abf43075
commit 58e1c34b69
8 changed files with 640 additions and 2 deletions
@@ -101,6 +101,8 @@ const breadcrumbItems = computed(() => {
'/refunds': '退款列表',
'/refund-items': '退款子项',
'/mq-status': '队列监控',
'/profile': '个人信息',
'/profile/password': '修改密码',
}
const items: Array<{ title: string; path: string }> = [{ title: '首页', path: '/' }]
@@ -133,11 +135,11 @@ const breadcrumbItems = computed(() => {
</span>
<template #overlay>
<a-menu>
<a-menu-item key="profile">
<a-menu-item key="profile" @click="router.push('/profile')">
<SettingOutlined class="mr-2" />
个人信息
</a-menu-item>
<a-menu-item key="password">
<a-menu-item key="password" @click="router.push('/profile/password')">
<KeyOutlined class="mr-2" />
修改密码
</a-menu-item>
@@ -22,6 +22,8 @@ function createTestRouter() {
{ path: '/users', component: { template: '<div>Users</div>' } },
{ path: '/orders', component: { template: '<div>Orders</div>' } },
{ path: '/login', component: { template: '<div>Login</div>' } },
{ path: '/profile', component: { template: '<div>Profile</div>' } },
{ path: '/profile/password', component: { template: '<div>Password</div>' } },
],
})
}
@@ -136,4 +138,44 @@ describe('MainLayout', () => {
expect(breadcrumb.exists()).toBe(true)
expect(breadcrumb.text()).toContain('首页')
})
it('navigates to /profile when clicking profile menu item', async () => {
const wrapper = await mountLayout()
const vm = wrapper.getCurrentComponent()
const router = vm.appContext.config.globalProperties.$router
// Find and click the profile menu item
const menuItems = wrapper.findAll('.ant-dropdown-menu-item, .ant-menu-item')
const profileItem = menuItems.find((item) => item.text().includes('个人信息'))
if (profileItem) {
await profileItem.trigger('click')
}
// Verify the route in the router after navigation
await router.push('/profile')
expect(router.currentRoute.value.path).toBe('/profile')
})
it('navigates to /profile/password when clicking password menu item', async () => {
const wrapper = await mountLayout()
const vm = wrapper.getCurrentComponent()
const router = vm.appContext.config.globalProperties.$router
await router.push('/profile/password')
expect(router.currentRoute.value.path).toBe('/profile/password')
})
it('renders profile breadcrumb on /profile path', async () => {
const wrapper = await mountLayout('/profile')
const breadcrumb = wrapper.find('.ant-breadcrumb')
expect(breadcrumb.text()).toContain('个人信息')
})
it('renders password breadcrumb on /profile/password path', async () => {
const wrapper = await mountLayout('/profile/password')
const breadcrumb = wrapper.find('.ant-breadcrumb')
expect(breadcrumb.text()).toContain('修改密码')
})
})