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,82 @@
const fs = require('fs')
const path = require('path')
function readJson(fileName) {
return JSON.parse(
fs.readFileSync(path.join(process.cwd(), fileName), {
encoding: 'utf8'
})
)
}
describe('project config', () => {
test('declares an explicit project name and base library version in root config', () => {
const projectConfig = readJson('project.config.json')
expect(projectConfig.projectname).toEqual(expect.any(String))
expect(projectConfig.projectname.trim()).not.toBe('')
expect(projectConfig.libVersion).toMatch(/^\d+\.\d+\.\d+$/)
})
test('registers native tab pages and matching tabBar items in app config', () => {
const appConfig = readJson('app.json')
const expectedTabPages = [
'pages/home/index',
'pages/library/index',
'pages/ai/index',
'pages/profile/index'
]
expect(appConfig.pages).toEqual(
expect.arrayContaining([...expectedTabPages, 'pages/login/index'])
)
expect(appConfig.tabBar).toEqual(
expect.objectContaining({
list: expect.arrayContaining(
expectedTabPages.map(pagePath =>
expect.objectContaining({
pagePath
})
)
)
})
)
expect(appConfig.tabBar.list).toHaveLength(4)
})
test('registers static migration subpackages in app config', () => {
const appConfig = readJson('app.json')
expect(appConfig.subPackages).toEqual(
expect.arrayContaining([
expect.objectContaining({
root: 'packages/tcm',
pages: expect.arrayContaining([
'pages/ai-history/index',
'pages/assets/index',
'pages/bianzheng/index',
'pages/book-detail/index',
'pages/search-books/index',
'pages/section/index',
'pages/placeholder/index'
])
}),
expect.objectContaining({
root: 'packages/mingli',
pages: expect.arrayContaining([
'pages/hall/index',
'pages/bazi/index',
'pages/book-detail/index',
'pages/search-books/index',
'pages/section/index',
'pages/interpret/index'
])
}),
expect.objectContaining({
root: 'packages/learning',
pages: ['pages/center/index']
})
])
)
})
})