skillhub/web/src/app/layout-main-content.test.ts
dongmucat e5a3aa6006 test(web): add colocated frontend coverage
变更摘要:
- 将前端测试共置到 web/src,保留并迁移 app 样式相关用例
- 为 pages、features、shared UI 与 hooks 补齐大范围 Vitest 覆盖
- 强化 governance、file preview、namespace header 与 API client 的关键分支测试
- 重新验证 pnpm run test 与 pnpm run typecheck,当前均已通过

关键文件:
- web/src/pages/dashboard/governance.test.ts
- web/src/features/governance/governance-inbox.test.ts
- web/src/features/skill/file-preview-dialog.test.ts
- web/src/features/namespace/namespace-header.test.ts
- web/src/api/client.test.ts
2026-03-23 16:13:34 +08:00

55 lines
1.9 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
CENTERED_DASHBOARD_CONTENT_CLASS_NAME,
CENTERED_MAIN_CLASS_NAME,
CENTERED_SEARCH_CONTENT_CLASS_NAME,
DEFAULT_MAIN_CLASS_NAME,
getAppMainContentLayout,
resolveAppMainContentPathname,
} from './layout-main-content'
describe('getAppMainContentLayout', () => {
it('keeps the landing page full width without the app-shell padding wrapper', () => {
expect(getAppMainContentLayout('/')).toEqual({
mainClassName: 'flex-1 relative z-10',
contentClassName: '',
})
})
it('centers the search page content with roomier responsive gutters', () => {
const layout = getAppMainContentLayout('/search')
expect(layout).toEqual({
mainClassName: CENTERED_MAIN_CLASS_NAME,
contentClassName: CENTERED_SEARCH_CONTENT_CLASS_NAME,
})
expect(layout.contentClassName).toContain('max-w-[1200px]')
})
it('centers all dashboard sub-pages within a slightly narrower content frame', () => {
const layout = getAppMainContentLayout('/dashboard/skills')
expect(layout).toEqual({
mainClassName: CENTERED_MAIN_CLASS_NAME,
contentClassName: CENTERED_DASHBOARD_CONTENT_CLASS_NAME,
})
expect(layout.contentClassName).toContain('max-w-[1200px]')
})
it('leaves other non-landing routes on the default full-width app content layout', () => {
expect(getAppMainContentLayout('/space/acme/demo')).toEqual({
mainClassName: DEFAULT_MAIN_CLASS_NAME,
contentClassName: '',
})
})
})
describe('resolveAppMainContentPathname', () => {
it('sticks with the last resolved route while the next page is still pending', () => {
expect(resolveAppMainContentPathname('/dashboard', '/search')).toBe('/search')
})
it('falls back to the live location when no resolved route is available yet', () => {
expect(resolveAppMainContentPathname('/search')).toBe('/search')
})
})