退回是不可逆动作(按不合格退回、不入库),此前点一下即提交。现改为先弹 wx.showModal 确认:确定才置不合格并退供,取消则原地不动。退回语义、门槛、状态链一字未动;附契约测试与设计文档。Web 验收页同位置未在本次范围。
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
/**
|
|
* 订单入库:「退回」需二次确认(2026-10-16 开发者:「点击后需要触发一个弹窗二次确认才行」)。
|
|
* 设计 docs/design/20261016-订单入库退回二次确认.md。
|
|
*
|
|
* 退回不可逆(按不合格退回、不入库)⇒ 必须**先确认再改状态/提交**;取消则原地不动。
|
|
*/
|
|
const js = readFileSync(
|
|
new URL('../../miniprogram/components/inspection-panel/index.js', import.meta.url),
|
|
'utf8'
|
|
);
|
|
|
|
function markFailBody(): string {
|
|
const start = js.indexOf('async markFailThenSubmit(e) {');
|
|
expect(start).toBeGreaterThanOrEqual(0);
|
|
return js.slice(start, start + 900);
|
|
}
|
|
|
|
describe('订单入库:退回二次确认', () => {
|
|
it('先弹确认,且确认在「置不合格/提交退供」之前', () => {
|
|
const body = markFailBody();
|
|
expect(body).toContain('confirmModal(');
|
|
expect(body).toContain('reject_fulfillment: true');
|
|
expect(body.indexOf('confirmModal(')).toBeLessThan(body.indexOf('reject_fulfillment: true'));
|
|
});
|
|
|
|
it('取消即返回:不置状态、不提交', () => {
|
|
const body = markFailBody();
|
|
expect(body).toMatch(/if \(!ok\) return;/);
|
|
// 取消分支必须出现在「把该行置为不合格」的 setData 之前
|
|
expect(body.indexOf('if (!ok) return;')).toBeLessThan(body.indexOf('input_rating: RESULT_FAIL'));
|
|
});
|
|
|
|
it('确认文案在场(标题 + 正文)', () => {
|
|
const body = markFailBody();
|
|
expect(body).toContain("'确认退回'");
|
|
expect(body).toContain('将按不合格退回、不入库');
|
|
});
|
|
});
|