Commit c373c1e8 by 张立顺

docs: 补充菜单测试基线修复

1 parent dfe1e37d
......@@ -17,6 +17,76 @@
- 只读展示不根据当前场景、门店品牌或客户来源重新推导历史数据的可见性。
- 不修改 API 请求参数、提交 payload、客户来源协议、开单页业务显隐矩阵或 Swagger 文件。
- 不修改未跟踪的 `outputs/` 和 `packageDynamicForm/tests/__pycache__/`。
- 先修复 `tabIndex/tests/menuSync.test.mjs` 缺少 `wx` mock 的测试基础设施问题;不得为此修改生产配置或菜单模块。
- 清空按钮契约测试只验证 WXML 的用户可见操作,不为已删除的 JS 方法名或 Sass 选择器增加长期负向源码断言。
---
### Task 0: 修复 TabIndex 测试导入期缺少 wx mock
**Files:**
- Modify: `tabIndex/tests/menuSync.test.mjs`
**Interfaces:**
- Consumes: `setupWxMock(globalThis)` from `tabIndex/tests/menuTestHelpers.mjs`; existing dynamic imports of `menuSyncHelpers.js` and `menu/context.js`.
- Produces: the standalone `menuSync.test.mjs` and `npm run test:tabIndex` execute without `wx is not defined`; the original global `wx` value is restored after the suite.
- [ ] **Step 1: Verify the existing test is RED**
Run:
```powershell
node --test tabIndex/tests/menuSync.test.mjs
```
Expected: FAIL at `config.js:26` with `ReferenceError: wx is not defined` while dynamically importing `menu/context.js`.
- [ ] **Step 2: Add the existing repository wx mock lifecycle**
Update the test imports and suite setup:
```js
import { describe, it, after } from 'node:test'
import assert from 'node:assert/strict'
import { setupWxMock } from './menuTestHelpers.mjs'
const globalRef = globalThis
const originalWx = globalRef.wx
describe('tabIndex menuSyncHelpers', async () => {
setupWxMock(globalRef)
after(() => {
globalRef.wx = originalWx
})
// keep the existing dynamic imports and assertions unchanged
})
```
Do not change `config.js`, `menu/context.js`, `menu/policies.js` or `menu/constants.js`; the failure is missing test environment setup, and peer `tabIndexMenu.test.mjs` already establishes this pattern.
- [ ] **Step 3: Run the focused test and verify GREEN**
```powershell
node --test tabIndex/tests/menuSync.test.mjs
```
Expected: PASS, 3 tests and 1 suite, with no `wx is not defined`.
- [ ] **Step 4: Run the TabIndex suite**
```powershell
npm run test:tabIndex
```
Expected: exit `0` with no failing suites.
- [ ] **Step 5: Commit the baseline fix**
```powershell
git add -- tabIndex/tests/menuSync.test.mjs
git commit -m "test: 补齐菜单同步 wx 环境"
```
---
......@@ -70,23 +140,16 @@ The first input deliberately uses `salesType: 2` to prove that read-only respons
- [ ] **Step 2: Write failing精品 UI contract tests**
Extend `customerDailyFields.ui.test.mjs` with list JS/WXML reads and assertions:
Extend `customerDailyFields.ui.test.mjs` with the user-visible list WXML contract; helper behavior remains covered by Step 1 rather than source-text assertions against page JavaScript:
```js
it('IT-WO-DAILY-UI-005: list, detail and confirm reuse response display state', () => {
const listJs = read('../../tabWorkOrderRelevance/index.js')
const listWxml = read('../../tabWorkOrderRelevance/index.wxml')
const detailJs = read('../../orderDetail/orderDetail.js')
const confirmJs = read('../../confirmOrder/confirmOrder.js')
assert.match(listJs, /buildBoutiqueCustomerDailyDisplay/)
assert.match(listJs, /customerDailyDisplay\s*=\s*buildBoutiqueCustomerDailyDisplay\(e\.customer\)/)
assert.match(listWxml, /li\.customerDailyDisplay\.showCustomerTags/)
assert.match(listWxml, /li\.customerDailyDisplay\.customerTagsText/)
assert.match(listWxml, /li\.customerDailyDisplay\.showActualDeliveryDate/)
assert.match(listWxml, /li\.customerDailyDisplay\.actualDeliveryDate/)
assert.match(detailJs, /buildBoutiqueCustomerDailyDisplay\(data\.customer\)/)
assert.match(confirmJs, /buildBoutiqueCustomerDailyDisplay\(data\.customer\)/)
})
```
......@@ -238,11 +301,8 @@ Extend `quotationCustomerDailyFields.ui.test.mjs`:
```js
it('IT-EQ-DAILY-UI-007: quotation list renders normalized response fields conditionally', () => {
const listJs = read('../pages/carQuotation/index/index.js')
const listWxml = read('../pages/carQuotation/index/index.wxml')
assert.match(listJs, /buildEquityCustomerDailyDisplay/)
assert.match(listJs, /customerDailyDisplay\s*=\s*buildEquityCustomerDailyDisplay\(item\)/)
assert.match(listWxml, /item\.customerDailyDisplay\.showCustomerTags/)
assert.match(listWxml, /item\.customerDailyDisplay\.customerTagsText/)
assert.match(listWxml, /item\.customerDailyDisplay\.showActualDeliveryDate/)
......@@ -365,12 +425,8 @@ Add to `customerDailyFields.ui.test.mjs`:
```js
it('IT-WO-DAILY-UI-006: create popup has no clear action', () => {
const wxml = read('../createOrder.wxml')
const js = read('../createOrder.js')
const sass = read('../createOrder.sass')
assert.doesNotMatch(wxml, /onClearCustomerTags|customer-tags-sheet__clear/)
assert.doesNotMatch(js, /onClearCustomerTags/)
assert.doesNotMatch(sass, /customer-tags-sheet__clear/)
assert.doesNotMatch(wxml, /bindtap="onClearCustomerTags">清空/)
assert.match(wxml, /onCancelCustomerTags/)
assert.match(wxml, /onConfirmCustomerTags/)
})
......@@ -383,15 +439,8 @@ Add to `quotationCustomerDailyFields.ui.test.mjs`:
```js
it('IT-EQ-DAILY-UI-008: FirstStep popup has no clear action', () => {
const wxml = read('../pages/carQuotation/components/FirstStep/FirstStep.wxml')
const js = read('../pages/carQuotation/components/FirstStep/FirstStep.js')
const sass = read('../pages/carQuotation/components/FirstStep/FirstStep.sass')
assert.doesNotMatch(
wxml,
/onClearEquityCustomerTags|equity-customer-tags-sheet__clear/
)
assert.doesNotMatch(js, /onClearEquityCustomerTags/)
assert.doesNotMatch(sass, /equity-customer-tags-sheet__clear/)
assert.doesNotMatch(wxml, /bindtap="onClearEquityCustomerTags">清空/)
assert.match(wxml, /onCancelEquityCustomerTags/)
assert.match(wxml, /onConfirmEquityCustomerTags/)
})
......@@ -405,7 +454,7 @@ Run:
node --experimental-detect-module --test tabWorkOrder/pages/createOrder/tests/customerDailyFields.ui.test.mjs packageEquity/tests/quotationCustomerDailyFields.ui.test.mjs
```
Expected: FAIL because both WXML files, JS handlers and Sass selectors still contain the clear action.
Expected: FAIL because both WXML files still render the clear action.
- [ ] **Step 4: Remove the精品 clear action**
......@@ -471,7 +520,7 @@ Expected: exit `0`; all create-order, root, dynamic-form, tab-index and equity t
- [ ] **Step 2: Check formatting and whitespace errors**
```powershell
git diff HEAD~3 --check
git diff HEAD~4 --check
```
Expected: no output and exit `0`.
......@@ -489,17 +538,18 @@ Expected: the first command finds both list/detail adapters; the second command
```powershell
git status --short
git diff HEAD~3 --stat
git diff HEAD~4 --stat
```
Expected: only the pre-existing untracked `outputs/` and `packageDynamicForm/tests/__pycache__/` remain outside the committed feature scope; the diff contains only files listed in this plan.
Expected: only the pre-existing untracked `outputs/` and `packageDynamicForm/tests/__pycache__/` remain outside the committed feature scope; the diff contains only files listed in this plan, and the previously failing TabIndex suite is green.
- [ ] **Step 5: Re-read acceptance criteria**
Confirm all five statements against code and fresh test evidence:
Confirm all six statements against code and fresh test evidence:
1. 精品列表 reads `customer.customerTags` and `customer.actualDeliveryDate` through the display helper.
2. 权益列表 reads top-level `customerTags` and `actualDeliveryDate` through the display helper.
3. 精品详情/确认 and权益详情 hide each row independently when its normalized value is empty.
4. Both create popups retain cancel/confirm and contain no clear action.
5. Create/edit submission visibility and payload code was not changed.
6. `menuSync.test.mjs`, `npm run test:tabIndex` and complete `npm test` no longer report `wx is not defined`.
......@@ -50,6 +50,12 @@
- 不修改 API 请求参数、提交 payload、客户来源协议、开单页业务显隐矩阵或 Swagger 文件。
- 不调整无关页面和已有未跟踪的 `outputs/` 内容。
## 测试基线修复
完整测试在业务改动前稳定复现 `tabIndex menuSyncHelpers` 的 `wx is not defined`。根因是 `tabIndex/tests/menuSync.test.mjs` 动态导入 `menu/context.js` 前没有安装仓库已有的 `setupWxMock(globalThis)`;导入链经 `menu/policies.js`、`menu/constants.js` 到达 `config.js`,后者会在模块加载阶段调用 `wx.getAccountInfoSync()`。同目录正常工作的 `tabIndexMenu.test.mjs` 已采用先安装 mock、再动态导入的模式。
本次同时修复该测试基础设施:只在失败测试中补齐 `wx` mock 初始化和恢复,不修改生产配置或菜单实现。修复后完整 `npm test` 必须通过,不再保留该基线例外。
## 错误与兼容处理
- 旧接口不返回新字段时,展示归一化结果为空,对应行自然隐藏,不影响其他列表或详情内容。
......@@ -64,6 +70,8 @@
- 精品列表与权益列表静态 UI 契约:断言两类字段均由归一化展示对象控制,且没有空值占位行。
- 精品详情、精品确认页和权益详情静态/纯函数测试:断言标签与日期分别按自身有效值显示。
- 新建弹窗静态 UI 契约:断言精品、权益两处均不存在“清空”按钮及其绑定事件。
- 标签弹窗测试只验证 WXML 不再渲染“清空”操作,同时保留“取消”和“确定”;不为已删除的 JS 方法名或 Sass 选择器增加长期负向源码断言。
- TabIndex 测试基线:先复现 `menuSync.test.mjs` 导入失败,再补齐与同目录测试一致的 `wx` mock 生命周期,并断言独立 TabIndex 套件通过。
- 运行相关 Node 测试后,再执行项目可用的完整测试命令验证回归。
## 验收标准
......@@ -72,4 +80,4 @@
2. 精品详情、精品确认页和权益详情遵循相同的逐字段规则。
3. 两个新建工单标签弹窗都只有“取消”和“确定”,不再显示“清空”。
4. 创建、编辑和提交逻辑保持原行为。
5. 相关自动化测试及完整可运行测试通过。
5. 相关自动化测试及完整 `npm test` 通过。
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!