test(03-10): add RED tests for ICS builder wiring + WR-04 + CR-02

- vevent.test.ts: D-13 form-parsed contract block — timed and all-day cases
  (all-day DTEND+1 fails: emits 20260610 not 20260611)
- outboxWorker.test.ts: worker integration — create/update must pass BEGIN:VCALENDAR
  to CalDAV write functions (fails: raw JSON passes through today)
- worker: unparseable payload must mark row failed (fails: marks done today)
- Update makeRow default payload to form JSON shape the worker should parse
This commit is contained in:
Lucas Berger
2026-06-05 20:46:50 -04:00
parent 1fc56f42d0
commit 813a7ba697
2 changed files with 108 additions and 1 deletions
+43
View File
@@ -116,3 +116,46 @@ describe('buildVeventString', () => {
expect(result.uid.length).toBeGreaterThan(10)
})
})
describe('buildVeventString — D-13 form-parsed contract', () => {
it('timed event: produces BEGIN:VCALENDAR, SUMMARY, UID, timed DTSTART (Z suffix), and DTEND', () => {
// Simulates the field shape parsed by the worker from the stored form JSON
const result = buildVeventString({
uid: 'u1@familysync',
summary: 'Lunch',
allDay: false,
dtstart: new Date('2026-06-10T12:00:00Z'),
dtend: new Date('2026-06-10T13:00:00Z'),
})
expect(result.icsString).toContain('BEGIN:VCALENDAR')
expect(result.icsString).toContain('SUMMARY:Lunch')
expect(result.icsString).toContain('UID:u1@familysync')
// D-13 timed contract: DATETIME in UTC → 'Z' suffix, no TZID
expect(result.icsString).toMatch(/DTSTART:\d{8}T\d{6}Z/)
// DTEND must be present
expect(result.icsString).toMatch(/DTEND:\d{8}T\d{6}Z/)
})
it('single-day all-day event: DTSTART is DATE format and DTEND = DTSTART + 1 day (RFC-5545 exclusive end, WR-04)', () => {
// Simulates a single-day all-day event where start and end are the same calendar day.
// WR-04: the outbox worker passes the user-entered inclusive end; vevent.ts must advance it.
const result = buildVeventString({
summary: 'Birthday',
allDay: true,
dtstart: '2026-06-10',
dtend: '2026-06-10',
})
// DTSTART must be DATE format (no time component, no TZID) — D-13 all-day contract
expect(result.icsString).toMatch(/DTSTART[^:]*:20260610/)
expect(result.icsString).not.toMatch(/DTSTART[^:]*:20260610T/)
// WR-04: DTEND must be DTSTART + 1 day (RFC-5545 exclusive end)
expect(result.icsString).toMatch(/DTEND[^:]*:20260611/)
// DTEND date string must NOT equal DTSTART date string (owning-boundary assertion)
const dtendMatch = result.icsString.match(/DTEND[^:]*:(\d{8})/)
const dtstartMatch = result.icsString.match(/DTSTART[^:]*:(\d{8})/)
expect(dtendMatch?.[1]).not.toBe(dtstartMatch?.[1])
})
})