Files
knowledge-governance/web/src/qaPeriodInput.test.ts
T
姚章浩 87f97a2f9b
build / build (push) Successful in 1m7s
feat(qaops): 完成详情下拉与每周自动保存草稿
详情使用共享主表字典,稀疏修改所选字段并保留原始问答及旧复核审计。
月周统计提供文本和下拉双入口;每租户每周一份持久草稿,按技能六节双语模板真实预填。
加入幂等自动保存、冲突保留、未知响应重试、切周及离开保护和schema58非破坏降级保护。

验证:完整make verify、隔离PostgreSQL全mirror竞态回归、真实恢复库浏览器验收通过。
浏览器实测字段精确读回、月周双输入、模板预填、MD/CSV、自动保存、冲突、失败重试与API重启恢复。
未连接或改写DobotAI生产源库,未运行付费模型;提交时尚未部署。
2026-10-20 05:44:02 +08:00

18 lines
1.1 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { validPeriodInput, periodInputOptions } from './qaPeriodInput'
describe('typed or dropdown natural periods', () => {
it('accepts canonical months and real cross-year weeks and rejects incomplete, future or impossible inputs', () => {
expect(validPeriodInput('month', '2026-02', '2026-10')).toBe(true)
expect(validPeriodInput('week', '2020-W53', '2021-W01')).toBe(true)
for (const value of ['', '2026-1', '2026-00', '2026-13', '2027-01', ' 2026-02', '1999-12'])
expect(validPeriodInput('month', value, '2026-10')).toBe(false)
for (const value of ['', '2021-W53', '2021-W1', '2021-W00', '2026-W44', '2020-W+1', '2020-W53 '])
expect(validPeriodInput('week', value, '2026-W43')).toBe(false)
})
it('offers selectable periods across year boundaries without replacing the typed value with an invalid date', () => {
expect(periodInputOptions('week', '2021-W01').slice(0, 2)).toEqual(['2021-W01', '2020-W53'])
expect(periodInputOptions('month', '2026-01').slice(0, 2)).toEqual(['2026-01', '2025-12'])
expect(periodInputOptions('week', '2021-W53')).toEqual([])
})
})