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, /: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\(\[\.\.\.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' }) })