Skip to content

test: add behavior tests for connectors - #27

Open
Chemaclass wants to merge 5 commits into
mainfrom
test/connector-behavior-tests
Open

test: add behavior tests for connectors#27
Chemaclass wants to merge 5 commits into
mainfrom
test/connector-behavior-tests

Conversation

@Chemaclass

@Chemaclass Chemaclass commented Jun 24, 2026

Copy link
Copy Markdown
Member

TL;DR — how much to trust the test data

These are characterization tests: they lock in the connectors' current observable behaviour rather than verify against live APIs. The fixtures are hand-built inputs typed against each connector's client interfaces, so the tests run with no real connection to Notion, Grain, Granola, Pylon, etc.

Confidence is two-layered:

  • High (~95%) that fixtures match the declared types. Every builder is typed (Partial<Recording>, Partial<PylonIssue>, Partial<Note>, NotionNode), so tsc rejects any fixture that drifts from its interface. Values are realistic (ISO timestamps, UUID-shaped ids, Slack message_ts format, Pylon custom_fields value/values split, Granola source enum).
  • Moderate that the types themselves match live API responses. The interfaces are hand-authored from docs/observation, not generated from a schema, and nothing here validates a fixture against a real payload. So the suite proves: given a correctly-shaped input, the serialize/parse logic is correct. It cannot catch a shape we mis-modeled, since fixture and type share the same assumption.

Soft spots to know about: notion/properties.test.ts casts property fixtures as never, bypassing type checking (plausible but unprotected); the HTTP/JSON-parse client layer is still ~0% covered.

To close the type-vs-reality gap later (when a real connection is available): capture one sanitized real response per source as a recorded JSON fixture and run it through the client's .json() parse + serializer once.


What

Adds happy-path, behavior-focused unit tests for the connectors that previously had no coverage. One commit per connector.

Connector Coverage
grain serializeRecording/idOf, keepRecording (GRAIN_AFTER cutoff + shouldSync)
granola serializeNote (both transcript disclaimer branches), idOf/updatedAtOf
notion serializePage/sanitizeBody/computePaths + property normalization across all Notion types
pylon serializeTicket/serializeAccount ordering & links, filename slugs, parse* round-trips
repo repoName/remoteUrl URL helpers

Approach

  • Tests assert on observable output (markdown strings, decisions, round-trips) — no coupling to private helpers or internals.
  • Network- and filesystem-free: minimal typed fixtures built from the real client types, explicit timestamps (no Date.now).
  • Matches the existing zendesk/web test style (bun:test, inline snapshots, toContain, round-trips).
  • repo/sync.ts: exported repoName/remoteUrl and guarded the auto-run with import.meta.main so helpers import cleanly under test (CI invocation unaffected).

Verification

bun test103 pass / 0 fail. Lint, typecheck, and prettier all clean.


Note

Low Risk
Changes are overwhelmingly new tests; the small sync.ts export/guard is a standard testability pattern with minimal runtime impact when run as the main script.

Overview
Adds behavior-focused unit tests (bun:test, fixtures, inline snapshots, round-trips) for connectors that previously had little or no coverage: Grain (keepRecording cutoff rules; recording markdown/idOf), Granola (note serialization, transcript disclaimers, idOf/updatedAtOf), Notion (paths, body sanitization, page frontmatter, property normalization), Pylon (tickets/accounts, filenames, parsers), and repo URL helpers.

The only production tweak is in repo/sync.ts: repoName and remoteUrl are exported for testing, and syncRepo auto-run is wrapped in import.meta.main so importing the module in tests does not trigger a sync (CLI/CI entry unchanged).

Reviewed by Cursor Bugbot for commit 6bf84b7. Bugbot is set up for automated code reviews on this repo. Configure here.

@Chemaclass Chemaclass self-assigned this Jun 24, 2026
@Chemaclass
Chemaclass force-pushed the test/connector-behavior-tests branch 3 times, most recently from cc014d2 to fbe8c59 Compare June 24, 2026 15:22
@Chemaclass
Chemaclass force-pushed the test/connector-behavior-tests branch 2 times, most recently from eff9ee6 to 3d999da Compare June 24, 2026 15:38
Happy-path tests for serializeRecording/idOf and keepRecording (GRAIN_AFTER cutoff + shouldSync), network-free.
Tests serializeNote frontmatter and both transcript disclaimer branches, plus idOf/updatedAtOf round-trips, network-free.
Tests serializePage/sanitizeBody/computePaths and normalizeValue/normalizeProperties/personRef/summarizeSchema across Notion property types, network-free.
Tests serializeTicket/serializeAccount ordering and links, filename slugs, and parse* round-trips, network-free.
Tests repoName/remoteUrl; exports them and guards the auto-run with import.meta.main so helpers import cleanly under test.
@Chemaclass
Chemaclass force-pushed the test/connector-behavior-tests branch from 3d999da to 6bf84b7 Compare June 24, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant