Files
shanxia2.0/web-admin/scripts/cert-ready-default.test.ts
T
wuzilongandCursor 66bad6b219 fix(pl): 拆分小程序运输证件页签权限,并让证书齐备列表避开证件类型路由。
页签按独立菜单显示,销售办证员默认不含证书齐备;证书齐备接口先于通配证件路径注册,避免 plans 被当成证件类型。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-07 12:19:28 +08:00

98 lines
3.5 KiB
TypeScript

import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { effectScope } from 'vue'
import { useServerColumnFilters } from '../src/composables/useServerColumnFilters'
import { certReadyDefaultPlanDates } from '../src/utils/cert-ready-plan-date'
import { PL_PLAN_CERT_READY_DEFAULT_FOLLOW_STATUSES } from '../src/utils/pl-display'
test('incomplete certificate filter is sent as quotaCertWaivedIn=0', () => {
const scope = effectScope()
const params = scope.run(() =>
useServerColumnFilters(
[
{
prop: 'quotaCertWaived',
label: '证书齐备',
type: 'enum',
queryKey: 'quotaCertWaived'
}
],
{ initialFilters: { quotaCertWaived: { text: '', selected: ['0'] } } }
).toQueryParams()
)
scope.stop()
assert.deepEqual(params, { quotaCertWaivedIn: '0' })
})
test('web funnel and miniprogram status dropdown default to incomplete', () => {
const web = readFileSync(new URL('../src/views/pl/cert-ready/index.vue', import.meta.url), 'utf8')
const mobile = readFileSync(
new URL('../src/views/m/pl/plan-cert/index.vue', import.meta.url),
'utf8'
)
assert.match(web, /quotaCertWaived:\s*\{\s*text:\s*'',\s*selected:\s*\['0'\]\s*\}/)
assert.match(mobile, /const readyState = ref\('0'\)/)
assert.match(mobile, /text:\s*'未齐备',\s*value:\s*'0'/)
assert.match(
web,
/planDate:\s*\{\s*from:\s*defaultPlanDates\.from,\s*to:\s*defaultPlanDates\.to\s*\}/
)
assert.match(mobile, /certReadyDefaultPlanDates\(\)/)
assert.match(mobile, /mini:pl:quota-cert:list/)
assert.match(mobile, /mini:pl:contract-quota:list/)
assert.match(mobile, /mini:pl:certificate-usage:list/)
assert.match(mobile, /mini:pl:plan-cert:segment/)
assert.match(mobile, /mini:pl:cert-ready:list/)
assert.match(mobile, /:plan-date-from="readyDateFrom"/)
assert.match(
web,
/followStatus:\s*\{\s*text:\s*'',\s*selected:\s*\[\.\.\.PL_PLAN_CERT_READY_DEFAULT_FOLLOW_STATUSES\]\s*\}/
)
assert.match(
mobile,
/const readyFollow = ref<string\[\]>\(\[\.\.\.PL_PLAN_CERT_READY_DEFAULT_FOLLOW_STATUSES\]\)/
)
assert.match(mobile, /text:\s*'全部跟进状态'/)
assert.match(mobile, /:follow-status="readyFollowQuery"/)
const ready = readFileSync(
new URL('../src/views/m/pl/plan-cert/ReadyTab.vue', import.meta.url),
'utf8'
)
assert.match(ready, /followStatusIn: props\.followStatus/)
})
test('certificate ready follow status defaults to drafting, waiting and pending', () => {
assert.deepEqual(
[...PL_PLAN_CERT_READY_DEFAULT_FOLLOW_STATUSES],
['drafting', 'wait_notice', 'pending_arrange']
)
const scope = effectScope()
const params = scope.run(() =>
useServerColumnFilters(
[
{
prop: 'followStatus',
label: '跟进状态',
type: 'enum',
queryKey: 'followStatus'
}
],
{
initialFilters: {
followStatus: { text: '', selected: [...PL_PLAN_CERT_READY_DEFAULT_FOLLOW_STATUSES] }
}
}
).toQueryParams()
)
scope.stop()
assert.deepEqual(params, { followStatusIn: 'drafting,wait_notice,pending_arrange' })
})
test('default plan dates run from yesterday through seven days later', () => {
const range = certReadyDefaultPlanDates(new Date(2026, 10, 5))
assert.deepEqual(range, { from: '2026-11-04', to: '2026-11-11' })
const yearTurn = certReadyDefaultPlanDates(new Date(2026, 0, 1))
assert.deepEqual(yearTurn, { from: '2025-12-31', to: '2026-01-07' })
})