Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9a9c8ae0
authored
Sep 04, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
test: establish subpackage split baseline
1 parent
ca558bec
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
741 additions
and
0 deletions
docs/migrations/2026-09-04-subpackage-ai-work-report-split-plan.md
docs/migrations/subpackage-ai-work-report-split/api-inventory.md
docs/migrations/subpackage-ai-work-report-split/manifest.json
docs/migrations/subpackage-ai-work-report-split/test-acceptance.md
package.json
tests/subpackage-split/api-contracts.test.mjs
tests/subpackage-split/fixtures/api-contracts.mjs
tests/subpackage-split/navigation-baseline.test.mjs
tests/subpackage-split/support/load-api-facade.mjs
tests/subpackage-split/support/load-mini-program-source.mjs
docs/migrations/2026-09-04-subpackage-ai-work-report-split-plan.md
0 → 100644
View file @
9a9c8ae
This diff is collapsed.
Click to expand it.
docs/migrations/subpackage-ai-work-report-split/api-inventory.md
0 → 100644
View file @
9a9c8ae
# AI 与工作日报分包 API 清单
## 边界
本次只迁移调用位置,不改变 method、payload、网关、签名排除字段、失败提示开关或响应消费方式。基线由
`tests/subpackage-split/api-contracts.test.mjs`
直接监听现有 facade 的
`request.post`
完整参数。
在线来源为
`develop`
环境的
`dj-car-boutique-work-wechat`
配置中心。已注册来源
`axios / rop-dj-car-boutique`
于 2026-09-04 在线读取成功;不带来源约束时,候选
`axios2 / rop-dj-smartcarlife`
的内网 Swagger 当前不可达,因此每个已确认方法均使用已注册
`axios`
来源执行精确匹配。
## 非 ROP AI transport
这些调用没有 dotted method,原样使用 AI 域名与路径,靠转发契约测试锁定。
| facade | path | domain | failTips |
| --- | --- | --- | --- |
|
`sparring`
|
`/router/sparring/1.0.0`
|
`AI`
|
`false`
|
|
`objectionSparring`
|
`/router/objection/sparring/1.0.0`
|
`AI`
|
`false`
|
|
`inspiration`
|
`/router/inspiration/1.0.0`
|
`AI`
| 默认值 |
|
`objectionInspiration`
|
`/router/objection/inspiration/1.0.0`
|
`AI`
| 默认值 |
|
`enhancement`
|
`/router/enhancement/1.0.0`
|
`AI`
|
`false`
|
|
`objectionEnhancement`
|
`/router/objection/enhancement/1.0.0`
|
`AI`
|
`false`
|
|
`getSensitive`
|
`/router/is/sensitive/1.0.0`
|
`AI`
|
`false`
|
|
`getPhrases`
|
`/router/similar/phrases/1.0.0`
|
`AI`
|
`false`
|
|
`getVoice`
|
`/router/get/voice/to/text/1.0.0`
|
`AI`
|
`false`
|
## AI ROP methods
| facade | method | 当前请求网关 | develop Swagger | 迁移处理 |
| --- | --- | --- | --- | --- |
|
`aiApi.getSparringPage`
|
`dj.api.carboutique.ai.sparring.staff.record.page`
|
`/rop-dj-pairexc/router`
|
`axios`
未收录 | 保持原调用;API 写入门禁暂缓 |
|
`aiApi.setSparringVerify`
|
`dj.api.carboutique.ai.sparring.verify`
|
`/rop-dj-pairexc/router`
|
`axios`
未收录 | 保持原调用;API 写入门禁暂缓 |
|
`aiApi.getToken`
|
`dj.api.smartcarlife.recepiton.customer.oss.getToken`
| 默认 |
`found`
, fresh | 原样迁移 |
|
`carEquityApi.getInspectionDetail`
|
`dj.api.smartcarlife.app.inspection.conversation.check.detail`
| 默认 |
`found`
, fresh | 原样迁移 |
|
`carEquityApi.getSparringPage`
|
`dj.api.carboutique.ai.sparring.task.page`
|
`/rop-dj-pairexc/router`
|
`axios`
未收录 | 保持原调用;API 写入门禁暂缓 |
|
`carEquityApi.getSparringDetail`
|
`dj.api.carboutique.ai.sparring.task.staff.detail.page`
|
`/rop-dj-pairexc/router`
|
`axios`
未收录 | 保持原调用;API 写入门禁暂缓 |
|
`carEquityApi.getSparringResult`
|
`dj.api.carboutique.ai.sparring.detail.check.result`
|
`/rop-dj-pairexc/router`
|
`axios`
未收录 | 保持原调用;API 写入门禁暂缓 |
|
`carEquityApi.sparringCommit`
|
`dj.api.carboutique.ai.sparring.detail.commit`
|
`/rop-dj-pairexc/router`
|
`axios`
未收录 | 保持原调用;API 写入门禁暂缓 |
|
`carEquityApi.behaviorSave`
|
`dj.api.carboutique.ai.sparring.staff.behavior.save`
|
`/rop-dj-pairexc/router`
|
`axios`
未收录 | 保持原调用;API 写入门禁暂缓 |
|
`carEquityApi.objectionPage`
|
`dj.api.carboutique.ai.sparring.objection.page`
|
`/rop-dj-pairexc/router`
|
`axios`
未收录 | 保持原调用;API 写入门禁暂缓 |
|
`carEquityApi.sparringRole`
|
`dj.api.carboutique.ai.sparring.role.info.page`
|
`/rop-dj-pairexc/router`
|
`found`
, fresh | method 已收录;网关仍保持不变 |
|
`carEquityApi.sparringRrain`
|
`dj.api.carboutique.ai.sparring.start.train`
|
`/rop-dj-pairexc/router`
|
`axios`
未收录 | 保持原调用;API 写入门禁暂缓 |
`/rop-dj-pairexc/swagger-rop/api-docs`
经当前 develop 公共域名读取返回 HTTP 502,配置中心也未登记该 ROP source。因此上述 9 个方法属于“Swagger 尚未收录且目标 Swagger 不可验证”;在取得一次性契约覆盖确认前,不创建或改写 AI API facade。
## 工作日报 ROP methods
下列 16 项在
`axios / rop-dj-car-boutique`
的最新 develop Swagger 中均为
`found`
、
`fresh=true`
、
`relevantMethodChanged=false`
。
| facade | method |
| --- | --- |
|
`staffDailyReportSave`
|
`dj.api.smartcarlife.staff.daily.report.save`
|
|
`staffDailyReportDetail`
|
`dj.api.smartcarlife.staff.daily.report.detail`
|
|
`staffDailyReportDetailWeeklyList`
|
`dj.api.smartcarlife.staff.daily.report.weekly.list`
|
|
`staffDailyReportApprove`
|
`dj.api.smartcarlife.staff.daily.report.approve`
|
|
`querySceneRefByShop`
|
`dj.api.scenemerchantref.querySceneRefByShop`
|
|
`staffDailyReportMerchantCarBand`
|
`dj.api.smartcarlife.staff.daily.report.car.brand`
|
|
`getDateRecord`
|
`dj.api.mindworkplate.app.daily.report.mySubmittedDateRecord`
|
|
`getRecordDetail`
|
`dj.api.mindworkplate.app.daily.report.myRecordDetail`
|
|
`getWeeklyRecordDetail`
|
`dj.api.carboutique.assign.month.find.staff.weekly.report.submit`
|
|
`getMonthCalWeek`
|
`dj.api.carboutique.assign.month.cal.week`
|
|
`getMonthlyRecordDetail`
|
`dj.api.carboutique.assign.year.find.staff.monthly.report.submit`
|
|
`saveTempReport`
|
`dj.api.mindworkplate.app.daily.report.save`
|
|
`getStaffList`
|
`dj.api.mindworkplate.app.daily.report.staffBaseInfo.page`
|
|
`dailyReportCheck`
|
`dj.api.smartcarlife.staff.daily.report.data.check`
|
|
`userStat`
|
`dj.api.smartcarlife.user.stat`
|
|
`outputValueStatistics`
|
`dj.api.smartcarlife.vehicle.damage.upgrade.quotation.outputValueStatistics`
|
`staffDailyReportMerchantValid`
留在
`tabWorkOrder/api.js`
,因为迁移范围外页面和主包弹窗队列仍消费它。
docs/migrations/subpackage-ai-work-report-split/manifest.json
0 → 100644
View file @
9a9c8ae
{
"id"
:
"subpackage-ai-work-report-split"
,
"title"
:
"权益 AI 与旧版工作日报独立分包迁移"
,
"sourceProject"
:
"dj-car-boutique-work-wechat"
,
"affectedPaths"
:
[
"app.json"
,
"router"
,
"store"
,
"utils"
,
"packageEquity"
,
"tabWorkOrder"
,
"tabIndex"
,
"packageUsedCar"
,
"packageDynamicForm"
,
"tests"
,
"docs"
],
"interfaces"
:
[
"packageEquityAI semantic routes and legacy packageEquity route aliases"
,
"packageWorkReport semantic routes and legacy tabWorkOrder route aliases"
,
"AI API request.post method, payload identity, gateway and transport flags"
,
"work report API request.post method and payload identity"
,
"H5 page mapping, login allowlist and wx.$SCENE path"
,
"cross-package imports, usingComponents78 and WXS src references"
],
"tests"
:
[
{
"id"
:
"subpackage-api-forwarding-contracts"
,
"file"
:
"tests/subpackage-split/api-contracts.test.mjs"
,
"level"
:
"contract"
,
"expectedBefore"
:
"pass"
,
"status"
:
"pass"
},
{
"id"
:
"subpackage-navigation-baseline"
,
"file"
:
"tests/subpackage-split/navigation-baseline.test.mjs"
,
"level"
:
"integration"
,
"expectedBefore"
:
"pass"
,
"status"
:
"pass"
}
],
"baseline"
:
{
"command"
:
"npm run test:subpackage-split"
,
"result"
:
"44/44 pass at ca558bec before production code migration"
},
"apiInventory"
:
"docs/migrations/subpackage-ai-work-report-split/api-inventory.md"
,
"acceptance"
:
"docs/migrations/subpackage-ai-work-report-split/test-acceptance.md"
,
"verification"
:
{
"commands"
:
[
{
"command"
:
"npm run test:subpackage-split"
,
"status"
:
"pass"
},
{
"command"
:
"npm test"
,
"status"
:
"pass"
},
{
"command"
:
"node scripts/check-subpackage-boundaries.mjs"
,
"status"
:
"blocked"
,
"blocker"
:
"The migration boundary scanner is created during the implementation phase."
},
{
"command"
:
"npm run check:subpackage-size"
,
"status"
:
"blocked"
,
"blocker"
:
"The per-package size gate is created after the two target subpackages exist."
},
{
"command"
:
"git diff --check"
,
"status"
:
"pass"
}
]
}
}
docs/migrations/subpackage-ai-work-report-split/test-acceptance.md
0 → 100644
View file @
9a9c8ae
# AI 与工作日报分包测试验收
## 基线
-
基线提交:
`ca558bec`
-
建立日期:2026-09-04
-
`npm test`
:通过(建立迁移计划前执行)
-
`npm run test:subpackage-split`
:44/44 通过
-
`node scripts/scan-component-paths.mjs`
:
`BROKEN_COMPONENT_PATHS=0`
-
`node scripts/scan-broken-imports.mjs`
:基线
`CRITICAL_CROSS_ROOT=2`
、
`OTHER_BROKEN=23`
;均不在迁移目标目录,迁移后总数不得增加,新包必须为 0
-
`project.config.json`
已整体忽略
`tests`
与
`docs`
,并保持
`ignoreUploadUnusedFiles: true`
,所以新增测试和迁移资料不会进入上传包
## 自动化用例
| 编号 | 层级 | 范围 | 改造前 | 改造后 |
| --- | --- | --- | --- | --- |
| SS-API-001 | contract | 21 个 AI facade 完整 transport 参数与 rejection | pass | 尚未执行 |
| SS-API-002 | contract | 16 个旧版日报 facade method 与 payload identity | pass | 尚未执行 |
| SS-NAV-001 | integration | 权益/轻改旧版日报选择 | pass | 尚未执行 |
| SS-NAV-002 | integration | 日/周/月主管日报菜单参数 | pass | 尚未执行 |
| SS-NAV-003 | integration | AI 菜单与任务提醒 query | pass | 尚未执行 |
| SS-NAV-004 | integration | H5 page 映射与免登录规则 | pass | 尚未执行 |
| SS-BOUNDARY-001 | static | 新包同步依赖、usingComponents、WXS 路径 | 尚未建立 | 尚未执行 |
| SS-SIZE-001 | static | 四个相关包源码预算与 DevTools 包体 | 尚未建立 | 尚未执行 |
## 真机矩阵
| 编号 | 平台 | 路径 | 改造前 | 改造后 |
| --- | --- | --- | --- | --- |
| SS-DEVICE-AI-ANDROID | Android | AI 菜单→开始→场景→对话→结果→返回 | 等待扫码执行 | 尚未执行 |
| SS-DEVICE-AI-IOS | iOS | AI 菜单→开始→场景→对话→结果→返回 | 等待扫码执行 | 尚未执行 |
| SS-DEVICE-TASK-ANDROID | Android | 对练提醒携参进入任务→详情/结果→返回 | 等待扫码执行 | 尚未执行 |
| SS-DEVICE-TASK-IOS | iOS | 对练提醒携参进入任务→详情/结果→返回 | 等待扫码执行 | 尚未执行 |
| SS-DEVICE-REPORT-ANDROID | Android | 驻店日报与日/周/月主管日报加载、保存、批复、返回 | 等待扫码执行 | 尚未执行 |
| SS-DEVICE-REPORT-IOS | iOS | 驻店日报与日/周/月主管日报加载、保存、批复、返回 | 等待扫码执行 | 尚未执行 |
| SS-DEVICE-H5-ANDROID | Android | H5
`staffDaily`
、
`upgradeStaffDaily`
、
`aiDetail`
深链 | 等待扫码执行 | 尚未执行 |
| SS-DEVICE-H5-IOS | iOS | H5
`staffDaily`
、
`upgradeStaffDaily`
、
`aiDetail`
深链 | 等待扫码执行 | 尚未执行 |
## 契约门禁状态
-
日报 16 个 ROP method:最新 develop Swagger 已全部确认。
-
AI 的 3 个 ROP method:最新 develop Swagger 已确认。
-
AI 的 9 个派练 ROP method:当前
`axios`
Swagger 未收录,运行时
`/rop-dj-pairexc`
Swagger 返回 HTTP 502;API 文件写入保持暂停。
-
9 个非 ROP AI HTTP path:已由 transport 特征测试锁定。
## 发布判定
只有自动化、开发者工具预览、Android 与 iOS 真机矩阵均通过,并且迁移 post 门禁通过,才标记为发布验收完成。设备或外部服务不可用时可以记录阻塞证据,但不能算发布通过。
package.json
View file @
9a9c8ae
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
"test:orderLifecycle:ui"
:
"node --test tests/order-lifecycle/ui/miniProgramSmoke.live.test.mjs"
,
"test:orderLifecycle:ui"
:
"node --test tests/order-lifecycle/ui/miniProgramSmoke.live.test.mjs"
,
"test:storeDailyReport:ui"
:
"node --test tests/store-daily-report/ui/storeDailyReport.live.test.mjs"
,
"test:storeDailyReport:ui"
:
"node --test tests/store-daily-report/ui/storeDailyReport.live.test.mjs"
,
"test:quotation"
:
"node --experimental-detect-module --test packageEquity/tests/quotationCustomerDailyFields.test.mjs packageEquity/tests/quotationCustomerDailyFields.ui.test.mjs packageEquity/tests/quotationMoney.helpers.test.mjs packageEquity/tests/quotationPayload.helpers.test.mjs packageEquity/tests/ruleFn.test.mjs"
,
"test:quotation"
:
"node --experimental-detect-module --test packageEquity/tests/quotationCustomerDailyFields.test.mjs packageEquity/tests/quotationCustomerDailyFields.ui.test.mjs packageEquity/tests/quotationMoney.helpers.test.mjs packageEquity/tests/quotationPayload.helpers.test.mjs packageEquity/tests/ruleFn.test.mjs"
,
"test:subpackage-split"
:
"node --experimental-detect-module --test tests/subpackage-split"
,
"test:components"
:
"node --test tests/popupBehavior.test.mjs tests/calendarMonthMode.test.mjs tests/componentsImageUrl.test.mjs tests/technicianSelect.helpers.test.mjs tests/sideSelectDataSource.test.mjs tests/storePickerConfirm.test.mjs"
,
"test:components"
:
"node --test tests/popupBehavior.test.mjs tests/calendarMonthMode.test.mjs tests/componentsImageUrl.test.mjs tests/technicianSelect.helpers.test.mjs tests/sideSelectDataSource.test.mjs tests/storePickerConfirm.test.mjs"
,
"knowledge:build"
:
"node scripts/knowledge-graph/knowledge-build.mjs"
,
"knowledge:build"
:
"node scripts/knowledge-graph/knowledge-build.mjs"
,
"knowledge:check"
:
"node scripts/knowledge-graph/knowledge-check.mjs"
,
"knowledge:check"
:
"node scripts/knowledge-graph/knowledge-check.mjs"
,
...
...
tests/subpackage-split/api-contracts.test.mjs
0 → 100644
View file @
9a9c8ae
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import {
AI_API_CONTRACTS,
WORK_REPORT_API_CONTRACTS
} from './fixtures/api-contracts.mjs'
import { loadApiFacade } from './support/load-api-facade.mjs'
const ALL_CONTRACTS = [...AI_API_CONTRACTS, ...WORK_REPORT_API_CONTRACTS]
function createRequestSpy(result = { code: 0 }) {
const calls = []
return {
calls,
post(...args) {
calls.push({
method: args[0],
payload: args[1],
extraArgs: args.slice(2)
})
return Promise.resolve(result)
}
}
}
describe('subpackage split API forwarding contracts', () => {
for (const contract of ALL_CONTRACTS) {
it(`${contract.id} preserves method, payload identity and transport args`, async () => {
const requestSpy = createRequestSpy()
const facade = await loadApiFacade(contract.source, requestSpy)
const payload = { marker: contract.id }
const result = contract.acceptsPayload === false
? await facade[contract.name]()
: await facade[contract.name](payload)
assert.deepEqual(result, { code: 0 })
assert.equal(requestSpy.calls.length, 1)
assert.deepEqual(requestSpy.calls[0], {
method: contract.method,
payload: contract.acceptsPayload === false ? undefined : payload,
extraArgs: contract.extraArgs
})
if (contract.acceptsPayload !== false) {
assert.equal(requestSpy.calls[0].payload, payload)
}
})
}
it('does not swallow transport rejection', async () => {
const transportError = new Error('transport rejected')
const facade = await loadApiFacade('packageEquity/aiApi.js', {
post: () => Promise.reject(transportError)
})
await assert.rejects(
() => facade.sparring({ marker: 'reject' }),
error => error === transportError
)
})
})
tests/subpackage-split/fixtures/api-contracts.mjs
0 → 100644
View file @
9a9c8ae
/**
* @file 分包迁移前后的 API 转发契约。这里只锁定 transport 调用,不推断业务响应。
*/
const freezeContracts = contracts =>
Object.freeze(
contracts.map(contract =>
Object.freeze({
...contract,
extraArgs: Object.freeze([...(contract.extraArgs || [])])
})
)
)
/** AI 页面当前实际使用的 API facade 契约。 */
export const AI_API_CONTRACTS = freezeContracts([
{
id: 'ai.sparring',
source: 'packageEquity/aiApi.js',
name: 'sparring',
method: '',
extraArgs: [[], '/router/sparring/1.0.0', 'AI', false]
},
{
id: 'ai.objectionSparring',
source: 'packageEquity/aiApi.js',
name: 'objectionSparring',
method: '',
extraArgs: [[], '/router/objection/sparring/1.0.0', 'AI', false]
},
{
id: 'ai.inspiration',
source: 'packageEquity/aiApi.js',
name: 'inspiration',
method: '',
extraArgs: [[], '/router/inspiration/1.0.0', 'AI']
},
{
id: 'ai.objectionInspiration',
source: 'packageEquity/aiApi.js',
name: 'objectionInspiration',
method: '',
extraArgs: [[], '/router/objection/inspiration/1.0.0', 'AI']
},
{
id: 'ai.enhancement',
source: 'packageEquity/aiApi.js',
name: 'enhancement',
method: '',
extraArgs: [[], '/router/enhancement/1.0.0', 'AI', false]
},
{
id: 'ai.objectionEnhancement',
source: 'packageEquity/aiApi.js',
name: 'objectionEnhancement',
method: '',
extraArgs: [[], '/router/objection/enhancement/1.0.0', 'AI', false]
},
{
id: 'ai.getSensitive',
source: 'packageEquity/aiApi.js',
name: 'getSensitive',
method: '',
extraArgs: [[], '/router/is/sensitive/1.0.0', 'AI', false]
},
{
id: 'ai.getPhrases',
source: 'packageEquity/aiApi.js',
name: 'getPhrases',
method: '',
extraArgs: [[], '/router/similar/phrases/1.0.0', 'AI', false]
},
{
id: 'ai.getVoice',
source: 'packageEquity/aiApi.js',
name: 'getVoice',
method: '',
extraArgs: [[], '/router/get/voice/to/text/1.0.0', 'AI', false]
},
{
id: 'ai.getSparringPage',
source: 'packageEquity/aiApi.js',
name: 'getSparringPage',
method: 'dj.api.carboutique.ai.sparring.staff.record.page',
extraArgs: [[], '/rop-dj-pairexc/router']
},
{
id: 'ai.setSparringVerify',
source: 'packageEquity/aiApi.js',
name: 'setSparringVerify',
method: 'dj.api.carboutique.ai.sparring.verify',
extraArgs: [[], '/rop-dj-pairexc/router']
},
{
id: 'ai.getToken',
source: 'packageEquity/aiApi.js',
name: 'getToken',
method: 'dj.api.smartcarlife.recepiton.customer.oss.getToken',
acceptsPayload: false
},
{
id: 'car.getInspectionDetail',
source: 'packageEquity/carEquityApi.js',
name: 'getInspectionDetail',
method: 'dj.api.smartcarlife.app.inspection.conversation.check.detail'
},
{
id: 'car.getSparringPage',
source: 'packageEquity/carEquityApi.js',
name: 'getSparringPage',
method: 'dj.api.carboutique.ai.sparring.task.page',
extraArgs: [[], '/rop-dj-pairexc/router']
},
{
id: 'car.getSparringDetail',
source: 'packageEquity/carEquityApi.js',
name: 'getSparringDetail',
method: 'dj.api.carboutique.ai.sparring.task.staff.detail.page',
extraArgs: [[], '/rop-dj-pairexc/router']
},
{
id: 'car.getSparringResult',
source: 'packageEquity/carEquityApi.js',
name: 'getSparringResult',
method: 'dj.api.carboutique.ai.sparring.detail.check.result',
extraArgs: [[], '/rop-dj-pairexc/router']
},
{
id: 'car.sparringCommit',
source: 'packageEquity/carEquityApi.js',
name: 'sparringCommit',
method: 'dj.api.carboutique.ai.sparring.detail.commit',
extraArgs: [[], '/rop-dj-pairexc/router']
},
{
id: 'car.behaviorSave',
source: 'packageEquity/carEquityApi.js',
name: 'behaviorSave',
method: 'dj.api.carboutique.ai.sparring.staff.behavior.save',
extraArgs: [[], '/rop-dj-pairexc/router']
},
{
id: 'car.objectionPage',
source: 'packageEquity/carEquityApi.js',
name: 'objectionPage',
method: 'dj.api.carboutique.ai.sparring.objection.page',
extraArgs: [[], '/rop-dj-pairexc/router']
},
{
id: 'car.sparringRole',
source: 'packageEquity/carEquityApi.js',
name: 'sparringRole',
method: 'dj.api.carboutique.ai.sparring.role.info.page',
extraArgs: [[], '/rop-dj-pairexc/router']
},
{
id: 'car.sparringRrain',
source: 'packageEquity/carEquityApi.js',
name: 'sparringRrain',
method: 'dj.api.carboutique.ai.sparring.start.train',
extraArgs: [[], '/rop-dj-pairexc/router']
}
])
/** 旧版员工、主管日报页面当前实际使用的 API facade 契约。 */
export const WORK_REPORT_API_CONTRACTS = freezeContracts([
['staffDailyReportSave', 'dj.api.smartcarlife.staff.daily.report.save'],
['staffDailyReportDetail', 'dj.api.smartcarlife.staff.daily.report.detail'],
['staffDailyReportDetailWeeklyList', 'dj.api.smartcarlife.staff.daily.report.weekly.list'],
['staffDailyReportApprove', 'dj.api.smartcarlife.staff.daily.report.approve'],
['querySceneRefByShop', 'dj.api.scenemerchantref.querySceneRefByShop'],
['staffDailyReportMerchantCarBand', 'dj.api.smartcarlife.staff.daily.report.car.brand'],
['getDateRecord', 'dj.api.mindworkplate.app.daily.report.mySubmittedDateRecord'],
['getRecordDetail', 'dj.api.mindworkplate.app.daily.report.myRecordDetail'],
['getWeeklyRecordDetail', 'dj.api.carboutique.assign.month.find.staff.weekly.report.submit'],
['getMonthCalWeek', 'dj.api.carboutique.assign.month.cal.week'],
['getMonthlyRecordDetail', 'dj.api.carboutique.assign.year.find.staff.monthly.report.submit'],
['saveTempReport', 'dj.api.mindworkplate.app.daily.report.save'],
['getStaffList', 'dj.api.mindworkplate.app.daily.report.staffBaseInfo.page'],
['dailyReportCheck', 'dj.api.smartcarlife.staff.daily.report.data.check'],
['userStat', 'dj.api.smartcarlife.user.stat'],
['outputValueStatistics', 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.outputValueStatistics']
].map(([name, method]) => ({
id: `report.${name}`,
source: 'tabWorkOrder/api.js',
name,
method
})))
tests/subpackage-split/navigation-baseline.test.mjs
0 → 100644
View file @
9a9c8ae
import { describe, it, mock } from 'node:test'
import assert from 'node:assert/strict'
import {
loadMiniProgramDefinition,
loadSourceExports
} from './support/load-mini-program-source.mjs'
globalThis.wx = {
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'release' } }),
getDeviceInfo: () => ({ platform: 'devtools' }),
getWindowInfo: () => ({
windowWidth: 375,
windowHeight: 667,
statusBarHeight: 20,
pixelRatio: 2,
screenWidth: 375,
screenHeight: 667,
safeArea: { top: 20, bottom: 667, height: 647 }
}),
getAppBaseInfo: () => ({
SDKVersion: '3.0.0',
host: 'WeChat',
version: '8.0.0',
language: 'zh_CN'
}),
$hasPermission: {
isSuper: () => false,
isNotMentor: () => true,
canSelectMultiStore: () => false,
canSelectMultiStoreForStaffDaily: () => false,
canViewMentorship: () => false,
canViewRecruit: () => false,
canViewViolation: () => false
}
}
globalThis.getApp = () => ({ globalData: { isStaff: true } })
const { resolveLegacyStaffDailyRoute } = await import('../../utils/staffDailyReportNavigation.js')
const { EQUITY_MENU_REGISTRY, ASYNC_MENU_REGISTRY: EQUITY_ASYNC_MENUS } =
await import('../../packageEquity/menu/registry.js')
const { MENU_REGISTRY } = await import('../../tabIndex/menu/registry.js')
function findById(items, id) {
const item = items.find(candidate => candidate.id === id)
assert.ok(item, `menu not found: ${id}`)
return item
}
describe('subpackage split navigation baseline', () => {
it('keeps legacy staff report route selection by scene type', () => {
assert.deepEqual(resolveLegacyStaffDailyRoute({ sceneType: 0 }), {
type: 'router',
route: 'tabWorkOrder.staffDaily',
params: { scene: 0 }
})
assert.deepEqual(resolveLegacyStaffDailyRoute({ sceneType: 1 }), {
type: 'router',
route: 'tabWorkOrder.upgradeStaffDaily',
params: {}
})
})
for (const [source, menus] of [
['equity', EQUITY_MENU_REGISTRY],
['home', MENU_REGISTRY]
]) {
it(`${source} work report menus preserve type and reportTypeAttr`, () => {
const expected = [
['work_daily_report', 'daily', '1'],
['work_weekly_report', 'weekly', '2'],
['work_monthly_report', 'monthly', '3']
]
for (const [id, reportTypeAttr, reportTypeVal] of expected) {
const item = findById(menus, id)
assert.equal(item.action.type, 'workReport')
assert.equal(item.action.target, 'tabWorkOrder.supervisorDaily')
assert.equal(item.reportTypeAttr, reportTypeAttr)
assert.equal(item.reportTypeVal, reportTypeVal)
}
})
}
it('AI menu enters the current start alias', () => {
const item = findById(EQUITY_ASYNC_MENUS, 'ai_fun_practice')
assert.deepEqual(item.action, {
type: 'router',
target: 'packageEquity.start'
})
})
it('AI task reminder preserves staff and task query values', async () => {
const go = mock.fn()
const wxMock = {
getStorageSync: () => undefined,
setStorageSync: mock.fn(),
$util: { getUserInfo: () => ({ merchantId: 'merchant-1' }) },
$hasPermission: { canSelectMultiStore: () => false },
$router: { go },
__HAS_NOTLOGIN_MODAL: false
}
class TestDate extends Date {
format() { return '2026-09-04' }
}
const definition = await loadMiniProgramDefinition(
'packageEquity/pages/TabBar/equityPage.js',
{
wx: wxMock,
getApp: () => ({ globalData: { isStaff: true } }),
require: () => ({}),
Date: TestDate,
IMG_URL: 'https://static.example/',
carLifeApi: {
getSparringPage: async () => ({
data: {
list: [{
task: { aiType: 7, promptOnOff: true },
staff: { id: 'staff-9', tryCount: 1 }
}]
}
})
}
}
)
await definition.checkTask.call({
addModalToQueue(_title, _content, _confirmText, _showCancel, _priority, callback) {
callback({ confirm: true })
}
})
assert.equal(
go.mock.calls[0].arguments[0],
'packageEquity.list?staffid=staff-9&tryCount=1&roleType=7&promptOnOff=true'
)
})
it('H5 scene mapping keeps report allowlist and AI login requirement', async () => {
const wxMock = {
$util: { getStorageSync: () => undefined },
$SCENE: null
}
const { checkScene } = await loadSourceExports('store/index.js', {
wx: wxMock,
console: { log() {}, error() {}, warn() {} },
getApp: () => ({ globalData: {} }),
api: {},
envIndex: 0,
removeSystemStorage: () => {},
util: { removeStorage: () => {} },
getSystemInfo: () => ({})
})
for (const [page, path] of [
['staffDaily', 'tabWorkOrder/pages/staffDaily/staffDaily'],
['upgradeStaffDaily', 'tabWorkOrder/pages/upgradeStaffDaily/upgradeStaffDaily']
]) {
const options = { query: { page } }
assert.equal(checkScene(options), undefined)
assert.equal(options.path, path)
}
const aiOptions = { query: { page: 'aiDetail' } }
assert.equal(checkScene(aiOptions), '未登录,请登录。')
assert.equal(aiOptions.path, 'packageEquity/pages/aiExcercise/ai/ai')
})
})
tests/subpackage-split/support/load-api-facade.mjs
0 → 100644
View file @
9a9c8ae
/**
* @file 在 Node 测试中注入 request spy,加载小程序 API facade;不执行真实网络请求。
*/
import { readFile } from 'node:fs/promises'
import path from 'node:path'
const projectRoot = path.resolve(process.cwd())
/**
* 加载 API facade,并以 spy 替代 `~/utils/request/request.js`。
* @param {string} relativePath 仓库内 API 文件路径
* @param {{post: Function}} requestSpy request facade spy
* @returns {Promise<object>} API facade
*/
export async function loadApiFacade(relativePath, requestSpy) {
const absolutePath = path.resolve(projectRoot, relativePath)
const relativeToRoot = path.relative(projectRoot, absolutePath)
if (
relativeToRoot === '..' ||
relativeToRoot.startsWith(`..${path.sep}`) ||
path.isAbsolute(relativeToRoot)
) {
throw new Error(`API facade must stay inside project: ${relativePath}`)
}
const source = await readFile(absolutePath, 'utf8')
const executable = source
.replace(/^\s*import\s+api\s+from\s+['"][^'"]+['"];?\s*$/m, '')
.replace(/export\s+default\s+/, 'const __facade = ')
.replace(/module\.exports\s*=\s*/, 'const __facade = ')
if (!executable.includes('const __facade = ')) {
throw new Error(`Unsupported API facade export: ${relativePath}`)
}
return new Function('api', `${executable}\nreturn __facade;`)(requestSpy)
}
tests/subpackage-split/support/load-mini-program-source.mjs
0 → 100644
View file @
9a9c8ae
/**
* @file 以依赖注入方式加载小程序页面或 ES 模块,仅用于迁移行为特征测试。
*/
import { readFile } from 'node:fs/promises'
import path from 'node:path'
import { parse } from '@babel/parser'
import generatorModule from '@babel/generator'
const generate = generatorModule.default || generatorModule
const projectRoot = path.resolve(process.cwd())
async function transformSource(relativePath) {
const absolutePath = path.resolve(projectRoot, relativePath)
const relativeToRoot = path.relative(projectRoot, absolutePath)
if (
relativeToRoot === '..' ||
relativeToRoot.startsWith(`..${path.sep}`) ||
path.isAbsolute(relativeToRoot)
) {
throw new Error(`Source must stay inside project: ${relativePath}`)
}
const source = await readFile(absolutePath, 'utf8')
const ast = parse(source, { sourceType: 'module' })
const exportNames = []
const body = []
for (const node of ast.program.body) {
if (node.type === 'ImportDeclaration') continue
if (node.type === 'ExportNamedDeclaration') {
if (node.declaration) {
body.push(node.declaration)
if (node.declaration.type === 'VariableDeclaration') {
for (const declaration of node.declaration.declarations) {
if (declaration.id.type === 'Identifier') exportNames.push(declaration.id.name)
}
} else if (node.declaration.id?.name) {
exportNames.push(node.declaration.id.name)
}
}
for (const specifier of node.specifiers || []) {
exportNames.push(specifier.local.name)
}
continue
}
if (node.type === 'ExportDefaultDeclaration') {
body.push({
type: 'VariableDeclaration',
kind: 'const',
declarations: [{
type: 'VariableDeclarator',
id: { type: 'Identifier', name: '__defaultExport' },
init: node.declaration
}]
})
exportNames.push('__defaultExport')
continue
}
body.push(node)
}
ast.program.body = body
return { code: generate(ast).code, exportNames }
}
/**
* 加载模块的命名导出,import 依赖由调用方显式注入。
* @param {string} relativePath 仓库内模块路径
* @param {Record<string, unknown>} [dependencies] 顶层依赖
* @returns {Promise<Record<string, unknown>>} 模块导出
*/
export async function loadSourceExports(relativePath, dependencies = {}) {
const { code, exportNames } = await transformSource(relativePath)
const names = Object.keys(dependencies)
const values = Object.values(dependencies)
const resultExpression = exportNames
.map(name => `${JSON.stringify(name)}: ${name}`)
.join(',')
return new Function(...names, `${code}\nreturn {${resultExpression}};`)(...values)
}
/**
* 捕获 Page/Component 注册对象,便于直接验证页面编排行为。
* @param {string} relativePath 仓库内页面脚本
* @param {Record<string, unknown>} [dependencies] 页面顶层依赖
* @param {'Page'|'Component'} [registerName] 注册函数名
* @returns {Promise<object>} 页面或组件定义
*/
export async function loadMiniProgramDefinition(
relativePath,
dependencies = {},
registerName = 'Page'
) {
const { code } = await transformSource(relativePath)
let definition
const register = value => {
definition = value
}
const injected = { ...dependencies, [registerName]: register }
new Function(...Object.keys(injected), code)(...Object.values(injected))
if (!definition) throw new Error(`${registerName} was not registered: ${relativePath}`)
return definition
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment