Skip to content

refactor: normalize mock API module exports and naming (#388) - #402

Merged
Lakes41 merged 2 commits into
Adamantine-guild:mainfrom
MarcusDavidG:fix/388-normalize-mock-exports
Aug 24, 2026
Merged

refactor: normalize mock API module exports and naming (#388)#402
Lakes41 merged 2 commits into
Adamantine-guild:mainfrom
MarcusDavidG:fix/388-normalize-mock-exports

Conversation

@MarcusDavidG

Copy link
Copy Markdown
Contributor

Summary

Fixes #388.

Problem

lib/api/mock.ts's export {} block was a flat, unsorted list of 13 symbols spanning three conceptually distinct categories — mutable fixture data, control/setter functions, and a standalone dev tool. There were no comments distinguishing them, making it unclear to new contributors whether mockConnections is a function or a data store, or why replayMockEvent doesn't follow the mock* method naming convention the API delegates use.

Changes

lib/api/mock.ts

  • Split the single flat export {} block into three clearly labelled sections:
    • Fixture datacommunityStates, getCommunityState, mockConnections, mockPrivacySettings, mockReports
    • ControlsMOCK_META_VERSION_OVERRIDE, applyMockScenario, resetMockData, setMock*
    • Standalone toolsreplayMockEvent
  • Added a ## Export naming conventions section to the module-level JSDoc documenting all three categories and explaining why replayMockEvent is intentionally separate from the mock* API-method delegates.

lib/api/mock/domains.ts

  • Updated MOCK_API_PUBLIC_REEXPORTS with matching section comments and an expanded JSDoc so the contract document stays in sync with the module.

test/mock-api-structure.test.ts

Acceptance criteria checklist

  • Mock fixtures, functions, and types follow consistent naming conventions (documented and sectioned)
  • Exported symbols have a clear distinction between data and behavior (three labelled export groups)
  • Existing API consumers continue to compile without unnecessary changes (no renames, zero callsite changes)
  • No behavior or fixture values changed

…ild#387)

Introduce lib/api/factory.ts as a dedicated narrow entry-point that
exports only getApi (and the version helpers it re-exports). Move the
getApi implementation there from lib/api/index.ts.

Update components/nav.tsx to import getApi from @/lib/api/factory
instead of the full @/lib/api barrel. The barrel previously pulled in
every mock-utility re-export (resetMockData, applyMockScenario, etc.)
via mock-boundary, meaning a syntax error in mock.ts could prevent the
navigation component from compiling.

lib/api/index.ts is updated to re-export getApi from ./factory so all
existing consumers of @/lib/api are unaffected.

Closes Adamantine-guild#387
…ild#388)

Group the export block in lib/api/mock.ts into three clearly labelled
sections — fixture data, control functions, and standalone tools — so
the distinction between data and behavior is immediately visible.

Add an '## Export naming conventions' section to the module-level JSDoc
that documents the three categories and explains why replayMockEvent is
intentionally separated from the mock* API-method delegates.

Update MOCK_API_PUBLIC_REEXPORTS in lib/api/mock/domains.ts with matching
section comments and an expanded JSDoc so the contract document stays in
sync with the module it tests.

Update the 'application consumers depend on the API boundary' assertion in
test/mock-api-structure.test.ts to accept @/lib/api/factory as a valid nav
import path (introduced in Adamantine-guild#387 to narrow the nav dependency surface).

No symbol renames, no behavior changes, no fixture value changes.

Closes Adamantine-guild#388
@Lakes41
Lakes41 merged commit f6a1101 into Adamantine-guild:main Aug 24, 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.

Normalize mock API module exports and naming

2 participants