20260915221013
This commit is contained in:
1 parent
1f56cc3efb
commit
dce29f250e
54 files changed
+3732
-574
No files matched your search
@@ -3,9 +3,15 @@ import { createMemoryHistory, createRouter } from 'vue-router'
|
||||
import { menuRouteOptions, routes } from '@/router/routes'
|
||||
|
||||
/**
|
||||
* 路由分组(/module)的契约测试。
|
||||
* 分组节点必须保持「无 component」:一旦给它配容器组件(内部再放 router-view),
|
||||
* 页面会下沉一层、脱离 DefaultLayout 的 keep-alive,缓存静默失效。
|
||||
* 路由分组(/module)的契约测试。两条分组节点的硬约束:
|
||||
*
|
||||
* 1. 分组节点必须保持「无 component」:一旦给它配容器组件(内部再放 router-view),
|
||||
* 页面会下沉一层、脱离 DefaultLayout 的 keep-alive,缓存静默失效。
|
||||
*
|
||||
* 2. 分组节点也不配 redirect:分组只是归类,不该自带「默认落地页」语义。
|
||||
* 直接访问 /base、/module 这类裸前缀时,交给表尾的 /:pathMatch(.*)* 兜到工作台
|
||||
* (/dashboard)—— 业务入口一律由 s_menu + 路由地址维护,避免出现「菜单上没配、
|
||||
* 却能落在某个页面」的第二入口。
|
||||
*/
|
||||
function createTestRouter() {
|
||||
return createRouter({ history: createMemoryHistory(), routes })
|
||||
@@ -24,10 +30,22 @@ describe('路由分组(嵌套结构)', () => {
|
||||
expect(router.currentRoute.value.meta.componentName).toBe('I18nTypeManagement')
|
||||
})
|
||||
|
||||
it('访问分组路径本身会重定向到首个子页(不会白屏)', async () => {
|
||||
it('分组节点既无 component 也无 redirect:只是归类,不自带默认落地页', async () => {
|
||||
const router = createTestRouter()
|
||||
await router.push('/module/i18n-type')
|
||||
const group = router.currentRoute.value.matched[1]
|
||||
|
||||
expect(group.path).toBe('/module')
|
||||
expect(group.components).toBeFalsy()
|
||||
expect(group.redirect).toBeFalsy()
|
||||
})
|
||||
|
||||
it('访问分组裸前缀时兜到工作台,不白屏', async () => {
|
||||
const router = createTestRouter()
|
||||
await router.push('/module')
|
||||
expect(router.currentRoute.value.path).toBe('/module/module-management')
|
||||
|
||||
// 分组无 component、无 redirect,裸前缀由表尾 /:pathMatch(.*)* 兜底
|
||||
expect(router.currentRoute.value.path).toBe('/dashboard')
|
||||
})
|
||||
|
||||
it('菜单路由选项:排除模块中心(adminOnly)整组与分组节点/动态/通配路由', () => {
|
||||
|
||||
Reference in new issue
Block a user