|
| 1 | +/** |
| 2 | + * Test matrix for `DispatchChatCreatedOpts` richer fields persisting into |
| 3 | + * ChatContext + welcome card on FIRST dispatch (no "send empty card, then |
| 4 | + * update" anti-pattern). |
| 5 | + * |
| 6 | + * Spec: docs/superpowers/plans/2026-05-24-p1-main-bot-subtask-spawn.md §1.5 |
| 7 | + * |
| 8 | + * **Commit #1 (this commit)** — types-only. All runtime assertions are |
| 9 | + * `it.todo` placeholders; opened in commit #5 when dispatchChatCreated |
| 10 | + * body actually persists the new fields. |
| 11 | + * |
| 12 | + * Run: pnpm vitest run test/dispatch-chat-created-rich-context.test.ts |
| 13 | + */ |
| 14 | +import { describe, it, expect } from 'vitest'; |
| 15 | +import type { DispatchChatCreatedOpts } from '../src/im/lark/chat-created-handler.js'; |
| 16 | + |
| 17 | +describe('dispatchChatCreated: rich context plumbing', () => { |
| 18 | + describe('Types — opts contract', () => { |
| 19 | + it('DispatchChatCreatedOpts accepts the richer fields (compile-time only)', () => { |
| 20 | + const opts: DispatchChatCreatedOpts = { |
| 21 | + chatId: 'oc_compile_test', |
| 22 | + larkAppId: 'cli_x', |
| 23 | + originType: 'bot_spawned', |
| 24 | + parentChatId: 'oc_parent', |
| 25 | + purpose: 'analyse PRD', |
| 26 | + participants: [{ openId: 'ou_a', role: 'main bot' }], |
| 27 | + relatedRefs: ['https://wiki/p1'], |
| 28 | + activeTodoRefs: ['om_root_msg'], |
| 29 | + rules: ['先读 PRD 全文'], |
| 30 | + parentDigest: 'parent chat 24h digest text', |
| 31 | + taskType: 'prd', |
| 32 | + }; |
| 33 | + // Compile-time success is the assertion. Runtime sanity: |
| 34 | + expect(opts.taskType).toBe('prd'); |
| 35 | + expect(opts.rules?.length).toBe(1); |
| 36 | + }); |
| 37 | + }); |
| 38 | + |
| 39 | + describe('D1 — ChatContext.read() after dispatch has all rich fields', () => { |
| 40 | + it.todo('dispatch with rich opts persists taskType / rules / relatedRefs / activeTodoRefs / parentDigest into ChatContext'); |
| 41 | + }); |
| 42 | + |
| 43 | + describe('D2 — first welcome card sees rich ctx (mock sendContextCard)', () => { |
| 44 | + it.todo('first welcome card render receives ctx containing rules + relatedRefs + activeTodoRefs + participants — not empty defaults'); |
| 45 | + }); |
| 46 | + |
| 47 | + describe('D3 — second dispatch is idempotent (no rewrite/resend)', () => { |
| 48 | + it.todo('same chatId second dispatch hits ChatContext.create idempotency, no second card sent'); |
| 49 | + }); |
| 50 | + |
| 51 | + describe('D-PP — three-bot participants array persists fully', () => { |
| 52 | + it.todo('participants=三 bot 数组 → ChatContext.participants length=3, all three openIds present'); |
| 53 | + }); |
| 54 | +}); |
0 commit comments