daily-report-package-split.test.mjs
4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { existsSync, readFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { measurePackageUploadBytes } from '../../scripts/check-subpackage-size.mjs'
import { FULL_ROUTE_ALIASES } from '../../router/routeAliases.js'
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..')
const readJson = relativePath => JSON.parse(readFileSync(path.join(projectRoot, relativePath), 'utf8'))
const DAILY_PAGES = [
'pages/staffDaily/staffDaily',
'pages/upgradeStaffDaily/upgradeStaffDaily',
'pages/supervisorDaily/supervisorDaily'
]
const DIRECT_ALIAS_CALLERS = Object.freeze({
'utils/staffDailyReportNavigation.js': [
'tabWorkOrder.staffDaily',
'tabWorkOrder.upgradeStaffDaily'
],
'packageUsedCar/ModalToQueueUsedCarControl.js': [
'tabWorkOrder.staffDaily',
'tabWorkOrder.upgradeStaffDaily'
],
'packageEquity/pages/salaryAppeal/salaryAppeal.js': [
'tabWorkOrder.staffDaily',
'tabWorkOrder.upgradeStaffDaily'
],
'tabIndex/menu/registry.js': [
'tabWorkOrder.upgradeStaffDaily',
'tabWorkOrder.supervisorDaily'
],
'packageEquity/menu/registry.js': [
'tabWorkOrder.staffDaily',
'tabWorkOrder.supervisorDaily'
],
'packageEquity/services/todoService.js': ['tabWorkOrder.staffDaily']
})
const DAILY_NAVIGATION_HELPER_CALLERS = Object.freeze([
'store/ModalToQueueControl.js',
'tabIndex/pages/index/index.js',
'packageEquity/pages/index/index.js',
'packageEquity/pages/carQuotation/createOrderCarQuotationSimple/createOrderCarQuotationSimple.js',
'tabWorkOrder/pages/additionRecordOrder/additionRecordOrder.js',
'tabWorkOrder/pages/createArchives/createArchives.js',
'tabWorkOrder/pages/defeatOrder/defeatOrder.js',
'tabWorkOrder/pages/premiumUpgrade/premiumUpgrade.js'
])
function findSubpackage(appConfig, root) {
return appConfig.subpackages.find(item => item.root === root)
}
describe('daily report package split contract', () => {
it('registers all legacy daily pages only in packageDynamicForm', () => {
const appConfig = readJson('app.json')
const tabWorkOrder = findSubpackage(appConfig, 'tabWorkOrder')
const packageDynamicForm = findSubpackage(appConfig, 'packageDynamicForm')
for (const page of DAILY_PAGES) {
assert.equal(tabWorkOrder.pages.includes(page), false, `${page} remains in tabWorkOrder`)
assert.equal(packageDynamicForm.pages.includes(page), true, `${page} missing from packageDynamicForm`)
}
})
it('moves page sources and exclusive dependencies without cross-package paths', () => {
for (const page of DAILY_PAGES) {
assert.equal(existsSync(path.join(projectRoot, 'packageDynamicForm', `${page}.js`)), true)
assert.equal(existsSync(path.join(projectRoot, 'tabWorkOrder', `${page}.js`)), false)
}
assert.equal(existsSync(path.join(projectRoot, 'packageDynamicForm/components/GLCustForm')), true)
assert.equal(existsSync(path.join(projectRoot, 'packageDynamicForm/components/storePicker')), true)
assert.equal(existsSync(path.join(projectRoot, 'packageDynamicForm/utils/ruleFn.js')), true)
assert.equal(existsSync(path.join(projectRoot, 'packageDynamicForm/index.wxs')), true)
assert.equal(existsSync(path.join(projectRoot, 'packageDynamicForm/images/check-active.png')), true)
assert.equal(existsSync(path.join(projectRoot, 'tabWorkOrder/components/GLCustForm')), false)
assert.equal(existsSync(path.join(projectRoot, 'tabWorkOrder/components/storePicker')), false)
})
it('removes upload-only documents and duplicate relevance images from tabWorkOrder', () => {
const projectConfig = readJson('project.config.json')
const ignoredValues = new Set(projectConfig.packOptions.ignore.map(item => item.value))
assert.equal(ignoredValues.has('tabWorkOrder/docs'), true)
assert.equal(ignoredValues.has('tabWorkOrder/pages/createOrder/AGENTS.md'), true)
assert.equal(
existsSync(path.join(projectRoot, 'tabWorkOrder/pages/tabWorkOrderRelevance/images')),
false
)
})
it('keeps every known daily-report entry on a registered compatibility route', () => {
for (const [relativePath, aliases] of Object.entries(DIRECT_ALIAS_CALLERS)) {
const source = readFileSync(path.join(projectRoot, relativePath), 'utf8')
for (const alias of aliases) {
assert.ok(source.includes(alias), `${relativePath} lost ${alias}`)
assert.ok(FULL_ROUTE_ALIASES[alias], `${alias} has no compatibility target`)
}
}
for (const relativePath of DAILY_NAVIGATION_HELPER_CALLERS) {
const source = readFileSync(path.join(projectRoot, relativePath), 'utf8')
assert.match(
source,
/staffDailyReportNavigation\.js/,
`${relativePath} bypasses the shared daily-report navigation gate`
)
}
})
it('keeps both affected subpackages below the strict 1,800,000-byte source limit', async () => {
for (const root of ['tabWorkOrder', 'packageDynamicForm']) {
const bytes = await measurePackageUploadBytes(projectRoot, root)
assert.ok(bytes <= 1_800_000, `${root} is ${bytes} bytes`)
}
})
})