Web 与小程序共用列表接口,打开时只看未齐备,计划日期从昨天起共 8 天;同时让移动端筛选下拉从筛选条向下展开。 Co-authored-by: Cursor <cursoragent@cursor.com>
50 lines
1.9 KiB
TypeScript
50 lines
1.9 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'
|
|
|
|
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"/)
|
|
})
|
|
|
|
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' })
|
|
})
|