From 2ed2cd6af703eb4fc7016f72edd6cbc31c158528 Mon Sep 17 00:00:00 2001 From: JuliobaCR Date: Fri, 21 Aug 2026 08:27:13 -0600 Subject: [PATCH] test: add regression guard for mock API module wiring (#382) lib/api/mock.ts previously grew into a single 2000+ line file that reached EOF with an unmatched block delimiter, breaking parsing of the module and, transitively, lib/api/index.ts and components/nav.tsx. That file has since been split into focused lib/api/mock/*.ts domain modules aggregated by MockAccessApi (see the module-boundary comment at the top of lib/api/mock.ts), which resolves the parse failure. This adds a test that exercises the public API boundary and one method from each domain module, so a future regression in the module wiring or a reintroduced parse error is caught by the test suite instead of surfacing as a root-route HTTP 500. --- test/mock-api-module-wiring.test.ts | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/mock-api-module-wiring.test.ts diff --git a/test/mock-api-module-wiring.test.ts b/test/mock-api-module-wiring.test.ts new file mode 100644 index 0000000..5e54159 --- /dev/null +++ b/test/mock-api-module-wiring.test.ts @@ -0,0 +1,35 @@ +import './setup-env' +import { describe, it } from 'node:test' +import assert from 'node:assert' +import { MockAccessApi } from '../lib/api/mock' +import { getApi } from '../lib/api' + +// Regression guard for #382: lib/api/mock.ts previously grew into a single +// 2000+ line file with an unmatched block delimiter, which broke parsing of +// the whole module and, transitively, lib/api/index.ts and components/nav.tsx. +// It has since been split into lib/api/mock/*.ts domain modules aggregated +// by MockAccessApi. This test exercises one method from each domain module +// through the public boundary to catch a future wiring/parse regression. +describe('MockAccessApi module wiring (#382)', () => { + const TEST_ADDRESS = '0x1234567890123456789012345678901234567890' + + it('lib/api/index.ts imports the mock boundary without a parse error', () => { + assert.strictEqual(typeof getApi, 'function') + }) + + it('composes every domain module onto a single MockAccessApi instance', async () => { + const api = new MockAccessApi(TEST_ADDRESS) + + await assert.doesNotReject(api.getMeta()) + await assert.doesNotReject(api.getSession()) + await assert.doesNotReject(api.getCommunity()) + await assert.doesNotReject(api.listMembers()) + await assert.doesNotReject(api.listWebhookEvents()) + await assert.doesNotReject(api.getAnalyticsSummary()) + await assert.doesNotReject(api.getPendingActions()) + await assert.doesNotReject(api.getConnections(TEST_ADDRESS)) + await assert.doesNotReject(api.listReports()) + await assert.doesNotReject(api.listProposals()) + assert.ok(api.analytics) + }) +})