TaskExpiry.contract.spec.js 1.0 KB

123456789101112131415161718192021
  1. import { readFileSync } from 'fs'
  2. import { resolve } from 'path'
  3. // 契约:任务过期机制(expired_at + 自动标记 overdue + 去重修复)
  4. const REM = resolve(__dirname, '../../../cfc-backend/src/main/java/com/etotem/cfc/task/TaskCheckinWebhookReminderTask.java')
  5. const SCHEMA = resolve(__dirname, '../../../cfc-backend/src/main/resources/schema.sql')
  6. const INIT = resolve(__dirname, '../../../cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java')
  7. const rem = readFileSync(REM, 'utf8'), schema = readFileSync(SCHEMA, 'utf8'), init = readFileSync(INIT, 'utf8')
  8. describe('任务过期机制', () => {
  9. test('提醒去重按 userId(与通知写入口径一致)', () => {
  10. expect(rem).toMatch(/alreadySentToday\(userId, task\.getId\(\), dayStart\)/)
  11. })
  12. test('expired_at 列在 schema + 迁移', () => {
  13. expect(schema).toMatch(/expired_at/)
  14. expect(init).toMatch(/expired_at/)
  15. })
  16. test('存在过期扫描调度器(每分钟)', () => {
  17. expect(init).toMatch(/TaskExpiry/)
  18. })
  19. })