| 123456789101112131415161718192021222324252627282930313233 |
- import { readFileSync } from 'fs'
- import { resolve } from 'path'
- // 契约:shop.checkout.couponAutoSelect (SHOP-AFTERSALES-2026-11-13-V1 §S3-1/2/3)
- // 溯源·需求:docs/需求分析/2026-11-13-订单售后与购买体验优化需求变更.md §S3 优惠券最优选择与明显提示
- // 溯源·实现:cfc-frontend/pages/shop/checkout/checkout.vue
- //
- // 说明:源读取契约(与小程序既有 __tests__ 风格一致)。校验常规结算进入时自动选最优券、
- // 明显提示「有 N 张优惠券可抵,点击选择」、手动取消后本次不再自动选(_couponDismissed)。
- const CHECKOUT_VUE = resolve(__dirname, '../../../pages/shop/checkout/checkout.vue')
- const source = readFileSync(CHECKOUT_VUE, 'utf8')
- describe('checkout.vue 优惠券最优选择与明显提示(SHOP-AFTERSALES-2026-11-13-V1 S3)', () => {
- test('存在 autoSelectCoupon 自动选券方法(S3-1)', () => {
- expect(source).toMatch(/autoSelectCoupon\s*\(/)
- })
- test('常规结算进入自动选面额最优券(selectCoupon(best) + _autoSelected 防重复)', () => {
- expect(source).toMatch(/selectCoupon\s*\(\s*best\s*\)/)
- expect(source).toMatch(/_autoSelected/)
- })
- test('存在明显提示「有 N 张优惠券可抵,点击选择」(S3-2)', () => {
- expect(source).toMatch(/有 .*张优惠券可抵,点击选择/)
- })
- test('手动取消券后置 _couponDismissed=true,本次结算会话不再自动选(S3-3)', () => {
- expect(source).toMatch(/removeCoupon\s*\(/)
- expect(source).toMatch(/_couponDismissed/)
- expect(source).toMatch(/this\._couponDismissed\s*=\s*true/)
- })
- })
|