test(payment): 售后契约测试同步结构化表单与可再次申请新行为

This commit is contained in:
2026-10-06 18:08:08 +00:00
parent 7b5dcf16a1
commit c200427358
@@ -193,7 +193,11 @@ test('after-sale tickets persist evidence images and expose the latest row', ()
)
const service = read('src/Payment/AfterSaleService.php')
assert.match(service, /public function create\(int \$user_id, string \$order_number, string \$reason, array \$images = \[\]\)/)
assert.match(service, /public function create\(int \$user_id, string \$order_number, string \$reason, array \$images = \[\], array \$apply_form = \[\]\)/)
// 结构化申请表单:预置原因 / 申请资料 / 申请说明独立入库(reason 融合串保持原样)
assert.match(service, /\$apply_form = \$this->sanitize_apply_form\(\$apply_form\);/)
assert.match(service, /private function sanitize_apply_form\(array \$form\): array/)
assert.match(service, /'apply_form' => \$apply_form === \[\] \? null : wp_json_encode\(\$apply_form/)
assert.match(service, /\$images = \$this->sanitize_images\(\$images\);/)
assert.match(service, /'images' => wp_json_encode\(\$images\)/)
assert.match(service, /private function sanitize_images\(array \$images\): array \{[\s\S]*?count\(\$clean\) >= 3[\s\S]*?esc_url_raw/)
@@ -210,7 +214,10 @@ test('after-sale tickets persist evidence images and expose the latest row', ()
assert.match(service, /'images' => \['required' => false, 'type' => 'array'[\s\S]*?count\(\$value\) <= 3/)
// 提交 REST 透传 images
assert.match(service, /is_array\(\$images\) \? \$images : \[\]\)/)
// rest_submit 同步上报结构化申请表单(reason_label / materials / description)
assert.match(service, /'reason_label' => \(string\) \$request->get_param\('reason_label'\),/)
assert.match(service, /'materials' +\=> is_array\(\$materials\) \? \$materials : \[\],/)
assert.match(service, /'description' +\=> \(string\) \$request->get_param\('description'\),/)
// 既有售后资产契约(锁 / 退款 / 完成)不受影响
assert.match(service, /GET_LOCK\(%s, 5\)/)
@@ -227,8 +234,12 @@ test('order view model exposes the after-sale button matrix', () => {
assert.match(userOrders, /'has_application' => \$has_application,/)
assert.match(userOrders, /'open'\s*=> \$open,/)
assert.match(userOrders, /'can_apply'\s*=> \$enabled && !\$expired && !\$open,/)
assert.match(userOrders, /'can_reapply'\s*=> \$enabled && !\$expired && !\$open && \$has_application,/)
// 可再次申请售后按工单状态推理:rejected(被拒绝)/ cancelled(已取消)允许再次申请;
// pending / processing / approved(流转中)与 completed(已完结)不允许
assert.match(userOrders, /\$reapplyable_statuses = \[AfterSaleService::STATUS_REJECTED, AfterSaleService::STATUS_CANCELLED\];/)
assert.match(userOrders, /'can_reapply'\s*=> \$enabled && !\$expired && \$has_application && in_array\(\$latest_status, \$reapplyable_statuses, true\),/)
assert.match(userOrders, /'latest'\s*=> \$has_application \? \[/)
assert.match(userOrders, /'apply_form'\s*=> is_array\(\$latest\['apply_form'\] \?\? null\) \? \$latest\['apply_form'\] : null,/)
// 仅已支付订单开放;开关关闭整体不处理售后
assert.match(userOrders, /\$enabled = \$group === OrderCenterQuery::STATUS_PAID && !empty\(\$settings\['enabled'\]\);/)
@@ -275,14 +286,21 @@ test('frontend after-sale modals are standalone and config-driven', () => {
assert.match(js, /\/after-sale\/upload-image'/)
assert.match(js, /data-aksrt-after-sale-image-remove/)
assert.match(js, /images: collectImages\(shell\)/)
assert.match(js, /reason_label: selectedReasonLabel\(shell\)/)
assert.match(js, /materials: collectMaterials\(shell\)/)
assert.match(js, /description: reasonText,/)
// 申请说明(HTML)+ 超时效提示(HTML)由后台配置直出
assert.match(js, /var desc = String\(cfg\.desc \|\| ''\)/)
assert.match(js, /var text = String\(settings\(\)\.expiredText \|\| '抱歉,您的订单已超过售后申请时效'\)/)
// 售后详细:状态徽章 / 明细行 / 图片缩略图;不可再申请提示原文 + 我知道了
// 申请表单分行展示:原因 / 申请资料 / 申请说明各自独立成行(与申请时间同格式);
// 老数据无 apply_form 时兜底展示融合串
assert.match(js, /detailRow\('原因', String\(applyForm\.reason_label \|\| ''\)\)/)
assert.match(js, /detailRow\('申请说明', String\(applyForm\.description \|\| ''\)\)/)
assert.match(js, /STATUS_LABELS = \{[\s\S]*?pending: '待审核'[\s\S]*?completed: '已完成',/)
assert.match(js, /REAPPLY_BLOCKED_TEXT = '该无法再次申请售后,该订单已售后,暂不支持再次申请售后。'/)
assert.match(js, /REAPPLY_BLOCKED_TEXT = '该订单当前状态暂不支持再次申请售后。'/)
assert.match(js, /escapeHtml\(REAPPLY_BLOCKED_TEXT\)/)
assert.match(js, /data-aksrt-modal-close>我知道了</)
assert.match(js, /data-aksrt-after-sale-reapply data-aksrt-after-sale-payload="/)