test: headless integration harness for the assembled plugin (PR-1)#90
Merged
Conversation
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.
|
🎉 PR Validation ✅ PASSED Commit: Checks:
Ready to merge! ✨ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR-1 - the e2e harness (foundation only)
Stacks on #89 (
feature/couch-only-sync, couch-only architecture - git channel deleted). Base isfeature/couch-only-sync, notmaster; 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 throughrequestUrl, under vitest. It needs no real Obsidian binary and makes no network calls.test/fakes/obsidian.ts- thevi.mock('obsidian')factory (lifted fromsrc/main.test.ts) + a property-shaped fake App + a chainable element/Setting/Modalso the status-bar build + settings re-render run as no-ops.test/fakes/fake-vault.ts- the colocatedFakeVault, extended withon()/trigger()so vault create/modify/delete/rename events drive the live handlers.test/fakes/fake-secrets.ts- the colocatedfakeSecrets, extended with a throwing (keyring-less) mode.test/fakes/fake-couch.ts- an in-memory CouchDB matching the exact wirecouch-sync.tsspeaks (f:/h:docs +_rev, ordered_changeslog,_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- therequestUrlrouter: dispatch by host (sync./auth./api./couch.) to the fakes; counts calls.test/fakes/boot.ts-bootPlugin(): constructsAgentageMemoryPlugin(fakeApp, manifest), stubswindow/Platform, pointsAGENTAGE_CONFIG_DIRat amkdtempdir, runs the realonload(), 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.tshas no DI constructor - the only seams are the mockedrequestUrland the property-shaped fakeapp.test/fakes/boot.tsis therefore the single point that must change when the plugin's Obsidian wiring changes.Wiring
vitest.config.tsinclude now globstest/**/*.test.tsalongsidesrc/**, so both run in one pass;npm run test:e2eruns just the integration dir. Coverage thresholds are unchanged (70%, actual ~96%).main.ts+couch-sync.tsare now additionally exercised through the assembled plugin (they remain coverage-excluded as Obsidian-coupled entry points, as before).Verify
npm run verifyis fully green (type-check + lint + format + 110 tests + build + host/docs/bundle checks). The single lint warning is pre-existing insettings-tab.ts(0 errors).Follow-ups (separate PRs)
fake-couch.ts.agentage/e2e).Do not merge.