Title#
feat(bj-16): add AtlassianMockServer for E2E tiers
Problem#
E2E tiers for the Bitbucket and Jira integration (BJ-8, BJ-9) require a live Atlassian tenant to run, blocking CI reliability and local development. A mock server is needed to intercept all Atlassian REST calls and OAuth token exchanges during test runs.
Task / Link#
Closes #556 (BJ-16: E2E mock server — Atlassian REST APIs)
Changes#
- Add
test/mocks/atlassian-mock-server.ts—AtlassianMockServerclass with port-0 HTTP server, Bitbucket/2.0/*and Jira/ex/jira/*route handlers, OAuth fetch shim, and per-request recording - Add
test/mocks/global-setup.ts/global-teardown.ts— Jest lifecycle hooks that boot/stop the singleton mock and exposeATLASSIAN_MOCK_URL - Add
test/mocks/atlassian-mock-server.spec.ts— unit tests covering lifecycle, Bitbucket/Jira routes, OAuth shim, 404 fallback, andreset() - Update
jest.config.js— extendrootDirto.and addtest/mocks/**/*.spec.tstotestMatchso mock unit tests run undernpm run test - Update
jest.module.config.js— wireglobalSetup/globalTeardownto the new files so module-level E2E runs start/stop the mock server
Notes#
- The mock uses Node's built-in
http— no new npm dependencies - OAuth token exchange for
https://bitbucket.org/site/oauth2/access_tokenandhttps://auth.atlassian.com/oauth/tokenis intercepted via aglobalThis.fetchshim (these URLs cannot be overridden via base-URL config) - Tier-specific configs (
jest.smoke.config.js) are left untouched; they can opt in when Atlassian scenarios land resetRequests()is the correct per-test isolation boundary (all workers share one server)
Testing#
- All 6 unit tests in
atlassian-mock-server.spec.tspass: server lifecycle, Bitbucket PR comment, Jira transitions, Jira PUT 204, OAuth shim intercept, reset clears recordings npm run lintpasses (zero warnings)