Skip to content

feat: add integration test infrastructure for CLI#2

Merged
andrzejchm merged 9 commits intomainfrom
feat/testing-infrastructure
Mar 23, 2026
Merged

feat: add integration test infrastructure for CLI#2
andrzejchm merged 9 commits intomainfrom
feat/testing-infrastructure

Conversation

@andrzejchm
Copy link
Copy Markdown
Owner

@andrzejchm andrzejchm commented Mar 17, 2026

Summary

Adds integration tests that run the built CLI binary against a real Notion workspace. Also adds an LLM agent test skill for on-demand exploratory testing. Unit tests are unchanged.

Changes

Integration Test Infrastructure

  • vitest.config.integration.ts - serial execution, 30s timeouts
  • test:integration npm script + dotenv-cli devDependency
  • vitest.config.ts - exclude patterns so unit tests and integration tests stay separate

Test Helpers (tests/integration/helpers/)

  • fixture.ts - duplicates Notion pages/databases per test, cleans up after
  • cli-runner.ts - shells out to dist/cli.js with NOTION_API_TOKEN
  • validate-env.ts - fails fast when env vars are missing

Integration Tests - 15 test cases across 8 files

Command Tests
read 4 (rich page, empty page, JSON output, invalid ID)
append 2 (append + read-back verification)
search 1
db query 3 (unfiltered, filtered, empty DB)
db schema 1
comments 1
comment 2 (add + verify)
ls 1

CI Workflow

  • New integration job in ci.yml - depends on ci, PR-only, passes 8 Notion secrets

LLM Agent Testing

  • .agents/skills/testing-notion-cli/SKILL.md - on-demand exploratory test skill
  • tests/e2e/scenarios.yaml - 4 initial scenarios

Documentation

  • docs/testing-setup.md - Notion workspace setup guide + CI secrets config
  • .env.test.example - template with all 8 env vars

Setup Required

To run integration tests, set up GitHub Actions secrets listed in docs/testing-setup.md:
NOTION_TEST_TOKEN, NOTION_TEST_ROOT_PAGE_ID, NOTION_FIXTURE_RICH_PAGE_ID, NOTION_FIXTURE_SIMPLE_PAGE_ID, NOTION_FIXTURE_EMPTY_PAGE_ID, NOTION_FIXTURE_TASK_DB_ID, NOTION_FIXTURE_EMPTY_DB_ID, NOTION_FIXTURE_COMMENTS_PAGE_ID

Verification

  • npm test - 77 unit tests pass (unchanged)
  • npm run typecheck - clean
  • npm run check - 70 files, no issues

- Add .env.test to .gitignore
- Add test:integration npm script
- Create vitest.config.integration.ts for serial integration tests
- Create docs/testing-setup.md with Notion workspace setup guide
- Add .env.test.example template with all 8 fixture env vars
- Add dotenv-cli devDependency for local test runs
- Create fixture duplication helper (page + database support)
- Create CLI runner helper (shells out to dist/cli.js)
- Add env var validation setup file for 8 required vars
- Update vitest config for serial execution (forks, single worker)
- Add read tests (rich page, empty page, JSON output, invalid ID)
- Add append tests (append + read-back verification)
- Add search test (find fixture by title)
- Add db query tests (unfiltered, filtered, empty database)
- Add db schema test (verify column names)
- Add comments test (list page comments)
- Add comment-add tests (add + verify comment)
- Add ls test (list workspace content)
- Add integration job to ci.yml (depends on ci, PR-only)
- Build CLI and run integration tests with 8 Notion secrets
- Add 10-minute timeout for safety
- Document required GitHub Actions secrets in testing-setup.md
- Create testing-notion-cli skill for on-demand exploratory testing
- Add 4 initial scenarios: read, append, db query, search
- Document fixture-to-env-var mapping and placeholder substitution
- Include scenario discovery and authoring guidance
- Add exclude patterns to vitest.config.ts for tests/integration/**,
  tests/e2e/**, node_modules/**, .opencode/**
- Remove stale passWithNoTests note from testing-setup.md
duplicatePage was creating title-only copies, causing read.test.ts to
fail with empty stdout. Now fetches markdown via retrieveMarkdown and
passes it to pages.create so the duplicate includes all blocks.
@andrzejchm andrzejchm merged commit 6fcf091 into main Mar 23, 2026
4 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.

1 participant