feat: migrate static pages to native tabbar

This commit is contained in:
2026-04-23 21:25:24 +08:00
parent f3cd0c3a98
commit cd30f57f2c
116 changed files with 7143 additions and 311 deletions

View File

@@ -0,0 +1,99 @@
describe('tcm support pages', () => {
afterEach(() => {
delete global.Page
delete global.wx
jest.resetModules()
})
test('assets page switches by static kind and keeps route-only navigation', () => {
let capturedPageConfig
global.Page = config => {
capturedPageConfig = config
}
const assetsPageModule = require('../packages/tcm/pages/assets/index')
const pageData = assetsPageModule.createTcmAssetsPageData('favorites')
expect(capturedPageConfig.data).toEqual(expect.objectContaining({ activeKind: 'notes' }))
expect(pageData.activeKind).toBe('favorites')
expect(pageData.title).toBe('学习资产')
expect(pageData.filterItems).toHaveLength(4)
})
test('routes TCM asset history items back to the AI tab with switchTab', () => {
let capturedPageConfig
global.Page = config => {
capturedPageConfig = config
}
global.wx = {
switchTab: jest.fn(),
navigateTo: jest.fn()
}
const assetsPageModule = require('../packages/tcm/pages/assets/index')
const pageData = assetsPageModule.createTcmAssetsPageData('history')
capturedPageConfig.handleEntryTap({
currentTarget: {
dataset: {
route: pageData.items[0].route
}
}
})
expect(global.wx.switchTab).toHaveBeenCalledWith({
url: '/pages/ai/index'
})
expect(global.wx.navigateTo).not.toHaveBeenCalled()
})
test('ai history, bianzheng and placeholder pages expose scene-driven static data', () => {
global.Page = () => {}
const aiHistoryModule = require('../packages/tcm/pages/ai-history/index')
const bianzhengModule = require('../packages/tcm/pages/bianzheng/index')
const placeholderModule = require('../packages/tcm/pages/placeholder/index')
expect(aiHistoryModule.createTcmAiHistoryPageData('empty')).toEqual(
expect.objectContaining({ scene: 'empty', title: 'AI对话历史' })
)
expect(bianzhengModule.createTcmBianzhengPageData('result')).toEqual(
expect.objectContaining({ scene: 'result', title: '辨证分析' })
)
expect(placeholderModule.createTcmPlaceholderPageData('membership')).toEqual(
expect.objectContaining({ kind: 'membership' })
)
})
test('routes AI history items targeting the AI tab with switchTab', () => {
let capturedPageConfig
global.Page = config => {
capturedPageConfig = config
}
global.wx = {
switchTab: jest.fn(),
navigateTo: jest.fn()
}
const aiHistoryModule = require('../packages/tcm/pages/ai-history/index')
const pageData = aiHistoryModule.createTcmAiHistoryPageData('default')
capturedPageConfig.handleHistoryTap({
currentTarget: {
dataset: {
route: pageData.groups[0].items[0].route
}
}
})
expect(global.wx.switchTab).toHaveBeenCalledWith({
url: '/pages/ai/index'
})
expect(global.wx.navigateTo).not.toHaveBeenCalled()
})
})