Skip to content

fix(frontend): RFC 5545-correct calendar export with tests (#65) - #1003

Merged
Smartdevs17 merged 1 commit into
Smartdevs17:mainfrom
sandrawillow001-afk:feat/calendar-export-hardening-65
Sep 30, 2026
Merged

Smartdevs17 merged 1 commit into
Smartdevs17:mainfrom
sandrawillow001-afk:feat/calendar-export-hardening-65

Conversation

@sandrawillow001-afk

@sandrawillow001-afk sandrawillow001-afk commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Coordination note. Issue #65 is currently assigned to @Paulotoide. This PR implements the same subject matter; please coordinate with them before merging so the effort is not duplicated.

Closes #65.

What already existed

The feature was largely present: lib/generateICS.ts, an Add to Calendar button, milestone dates and .ics download — so three of the four acceptance criteria were met. Re-checking the implementation turned up real defects and zero tests.

Defects fixed

  1. allDay was silently ignored. The localized page passed allDay: true, but ICSEvent had no such field, so the intent was dropped and the event was serialised as a timed event.
  2. TEXT values were never escaped. A title such as Redesign, phase 2 produced SUMMARY:Redesign, phase 2, which most clients truncate at the comma. Now escaped per RFC 5545 §3.3.11 (\, ;, ,, newlines).
  3. No line folding. Long descriptions exceeded the 75-octet limit (RFC 5545 §3.1). Now folded with CRLF + space, without splitting UTF-8 sequences.
  4. Invalid dates produced unparseable output. A bad deadline emitted DTSTART:NaNundefinedZ, corrupting the whole calendar. Such events are now skipped.
  5. The two project pages had drifted. They used different UIDs and descriptions for the same milestone. Both now call one shared builder, and UIDs stay stable so re-imports update rather than duplicate.

Acceptance criteria

  • Include project deadlines — Project now exposes the on-chain deadline (via formatProjectData), and a dedicated deadline event is emitted.
  • Include milestone dates — one event per milestone due date.
  • The deadline event is skipped when a milestone already falls on that same UTC day, because the contract currently maps the deadline onto a single milestone; this keeps the calendar duplicate-free.

Verification

cd frontend
npx vitest run lib/__tests__          # generateICS 26 + project-calendar 17 passed
npx tsc --noEmit | grep -cE 'generateICS|project-calendar|projects/\[id\]|lib/types|useAgenticPay'  # 0
npx eslint lib/generateICS.ts lib/project-calendar.ts lib/__tests__  # clean

lib/api.test.ts (2 tests) fails both before and after this change — pre-existing and unrelated.

Note

Changing the non-localized page's UIDs to the shared scheme means events previously added from that page will appear once more if re-added; the two pages now agree, which is the point.


🤖 Generated with Codebuff

…17#65)

Calendar export shipped but was not conformant and had drifted: the generator
accepted an `allDay` flag and silently ignored it, titles containing commas were
truncated because TEXT values were never escaped, long lines were not folded,
invalid dates produced unparseable output, and the two project pages emitted
different UIDs and descriptions for the same milestones. There were no tests.

- generateICS: escape TEXT per RFC 5545 §3.3.11, fold lines at 75 octets without
  splitting UTF-8 (§3.1), render all-day events with an exclusive DTEND, drop
  events with unusable dates/UIDs/summaries instead of emitting NaN, and guard
  downloadICS outside the browser.
- project-calendar: one shared builder used by both project pages, emitting a
  stable event per milestone due date plus a project deadline event that is
  skipped when a milestone already covers that day.
- types/hook: expose the on-chain `deadline` on Project so the deadline event can
  actually be built.
- tests: 43 cases covering escaping, folding, injection of invalid input, the
  deadline deduplication rule and the project-to-.ics path.
- docs: document the event model, UIDs and conformance rules.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@vercel

vercel Bot commented Sep 29, 2026

Copy link
Copy Markdown

@sandrawillow001-afk is attempting to deploy a commit to the smartdevs17's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Smartdevs17
Smartdevs17 merged commit 431581f into Smartdevs17:main Sep 30, 2026
20 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frontend: Add export to calendar

2 participants