Skip to content

test: headless integration harness for the assembled plugin (PR-1)#90

Merged
vreshch merged 2 commits into
masterfrom
test/e2e-harness
Jul 8, 2026
Merged

test: headless integration harness for the assembled plugin (PR-1)#90
vreshch merged 2 commits into
masterfrom
test/e2e-harness

Conversation

@vreshch

@vreshch vreshch commented Jul 8, 2026

Copy link
Copy Markdown
Member

PR-1 - the e2e harness (foundation only)

Stacks on #89 (feature/couch-only-sync, couch-only architecture - git channel deleted). Base is feature/couch-only-sync, not master; review/merge #89 first.

What this is

A headless integration harness that boots the real plugin onload() against a fully-mocked Obsidian host plus in-memory fake couch/auth/discovery, all routed through requestUrl, under vitest. It needs no real Obsidian binary and makes no network calls.

  • test/fakes/obsidian.ts - the vi.mock('obsidian') factory (lifted from src/main.test.ts) + a property-shaped fake App + a chainable element/Setting/Modal so the status-bar build + settings re-render run as no-ops.
  • test/fakes/fake-vault.ts - the colocated FakeVault, extended with on()/trigger() so vault create/modify/delete/rename events drive the live handlers.
  • test/fakes/fake-secrets.ts - the colocated fakeSecrets, extended with a throwing (keyring-less) mode.
  • test/fakes/fake-couch.ts - an in-memory CouchDB matching the exact wire couch-sync.ts speaks (f:/h: docs + _rev, ordered _changes log, _bulk_docs/PUT/DELETE/GET, 409 on stale rev). Fault knobs (failNext, unauthorizeUntilRemint, dropLeaf, failLeafOnBulk, injectRemoteChange) are wired now for PR-2.
  • test/fakes/fake-auth-server.ts - discovery + DCR + token + refresh (rotating) + revoke + couch-token minter + GET/POST /api/memories.
  • test/fakes/router.ts - the requestUrl router: dispatch by host (sync./auth./api./couch.) to the fakes; counts calls.
  • test/fakes/boot.ts - bootPlugin(): constructs AgentageMemoryPlugin(fakeApp, manifest), stubs window/Platform, points AGENTAGE_CONFIG_DIR at a mkdtemp dir, runs the real onload(), returns handles + teardown. signIn() drives the full obsidian:// deep-link flow.

The one smoke it proves (test/integration/first-sync.test.ts)

connect (discovery -> DCR -> authorize -> code exchange) -> pick memory -> first sync seeds the local vault from couch -> re-sync does zero write HTTP. It asserts both the vault content AND the fake-couch state.

Injection-seam caveat

main.ts has no DI constructor - the only seams are the mocked requestUrl and the property-shaped fake app. test/fakes/boot.ts is therefore the single point that must change when the plugin's Obsidian wiring changes.

Wiring

vitest.config.ts include now globs test/**/*.test.ts alongside src/**, so both run in one pass; npm run test:e2e runs just the integration dir. Coverage thresholds are unchanged (70%, actual ~96%). main.ts + couch-sync.ts are now additionally exercised through the assembled plugin (they remain coverage-excluded as Obsidian-coupled entry points, as before).

Verify

npm run verify is fully green (type-check + lint + format + 110 tests + build + host/docs/bundle checks). The single lint warning is pre-existing in settings-tab.ts (0 errors).

Follow-ups (separate PRs)

  • PR-2: the scenario fan-out (conflict/merge, offline queue+flush, 401 re-mint, delete durability, remote-change pull) using the fault knobs already in fake-couch.ts.
  • The real-Electron Playwright-Electron smoke against the live wire (lives in agentage/e2e).

Do not merge.

Boot the real onload() against a fully-mocked Obsidian host + in-memory
fake couch/auth/discovery routed through requestUrl, under vitest. No
src/ changes - the only injection seams are the requestUrl mock and a
property-shaped fake app; boot.ts is the single update point.

One smoke proves the harness: connect (discovery -> DCR -> obsidian://
callback) -> pick memory -> first sync seeds the vault from couch ->
re-sync does zero write HTTP. Fault knobs on fake-couch are wired now
for the PR-2 scenario fan-out.
@vreshch
vreshch force-pushed the test/e2e-harness branch from 363568f to 84c9d45 Compare July 8, 2026 22:59
@vreshch
vreshch changed the base branch from feature/couch-only-sync to master July 8, 2026 22:59
@vreshch
vreshch marked this pull request as ready for review July 8, 2026 23:05
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

🎉 PR Validation ✅ PASSED

Commit: ac0c42ccfbeda1a6155ba1252d7014d53d3adc64
Branch: test/e2e-harness

Checks:

  • ✅ Dependencies installed
  • ✅ Type check passed
  • ✅ Linting passed
  • ✅ Format check passed
  • ✅ Tests + coverage passed
  • ✅ Build successful
  • ✅ Store-compliance checks passed
  • ✅ Bundle is mobile-safe

Ready to merge!


🔗 View workflow run

@vreshch
vreshch merged commit 282b832 into master Jul 8, 2026
1 check 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