feat(02-01): schema columns, PWA vitest harness, ICS fixtures, RED test stubs
- Add calendarEvents.hasRrule boolean + idx_calendar_events_has_rrule index (Phase 2 pre-filter) - Add calendars.isShared boolean for shared-family calendar identification - Create apps/pwa/vitest.config.ts with jsdom environment - Add vitest, @testing-library/react, jsdom, @testing-library/jest-dom to PWA devDependencies - Add "test": "vitest run" script to apps/pwa/package.json - Create three ICS fixtures: weekly-dst.ics (DST spanning), allday-birthday.ics, exdate-series.ics - Create RED test stub expand.test.ts with concrete DST wall-clock assertions (10:00 local both sides of March 2026 boundary) - Create RED test stub events.test.ts with 400 validation and color/isShared field contracts - Create RED test stub hydrateEvents.test.ts with Temporal type and calendarId routing contracts (shared→"shared", personal→String(ownerUserId)) - Create RED test stub calendarConfig.test.ts with firstDayOfWeek 0→7 translation contract
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* RED test stubs for calendarConfig — Wave 0 state.
|
||||
*
|
||||
* These tests encode the contracts for calendarConfig.ts.
|
||||
* The tests reference the not-yet-built module apps/pwa/src/lib/calendarConfig.ts.
|
||||
*
|
||||
* Contracts locked here:
|
||||
* 1. WEEK_START_DAY === 0 (JS/date-fns Sunday convention) → Schedule-X firstDayOfWeek === 7
|
||||
* (Temporal convention: 7 = Sunday, not 0)
|
||||
* Passing 0 would silently default to Monday in Schedule-X v4.
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest'
|
||||
|
||||
// Not yet built — import will fail (RED state) until Plan 03 implements calendarConfig.ts
|
||||
import { WEEK_START_DAY, buildCalendarConfig } from './calendarConfig.js'
|
||||
|
||||
describe('calendarConfig — RED stubs (Wave 0)', () => {
|
||||
|
||||
it('WEEK_START_DAY constant equals 0 (Sunday in JS/date-fns convention)', () => {
|
||||
// The project uses 0 = Sunday (JS/date-fns convention).
|
||||
// This constant is translated to 7 before passing to Schedule-X.
|
||||
expect(WEEK_START_DAY).toBe(0)
|
||||
})
|
||||
|
||||
it('WEEK_START_DAY=0 translates to Schedule-X firstDayOfWeek === 7', () => {
|
||||
// Schedule-X v4 uses Temporal numbering: 1=Mon, 7=Sun.
|
||||
// WEEK_START_DAY=0 (JS Sunday) must become 7 (Temporal Sunday).
|
||||
// This avoids the Pitfall 1 silent failure where weeks start on Monday.
|
||||
const config = buildCalendarConfig([])
|
||||
expect(config.firstDayOfWeek).toBe(7)
|
||||
})
|
||||
|
||||
it('buildCalendarConfig includes shared-family calendar with id "shared"', () => {
|
||||
const config = buildCalendarConfig([])
|
||||
expect(config.calendars).toHaveProperty('shared')
|
||||
expect(config.calendars['shared'].colorName).toBe('shared')
|
||||
})
|
||||
|
||||
it('buildCalendarConfig includes per-member calendars keyed by String(userId)', () => {
|
||||
const members = [
|
||||
{ id: '1', name: 'Lucas', color: '#4A90D9' },
|
||||
{ id: '2', name: 'Spouse', color: '#E8734A' },
|
||||
]
|
||||
const config = buildCalendarConfig(members)
|
||||
expect(config.calendars).toHaveProperty('1')
|
||||
expect(config.calendars).toHaveProperty('2')
|
||||
expect(config.calendars['1'].lightColors.main).toBe('#4A90D9')
|
||||
expect(config.calendars['2'].lightColors.main).toBe('#E8734A')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user