backend-manager 5.3.0 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/test/helpers/webhook-forward.js +26 -0
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
14
14
|
- `Fixed` for any bug fixes.
|
|
15
15
|
- `Security` in case of vulnerabilities.
|
|
16
16
|
|
|
17
|
+
# [5.3.1] - 2026-06-02
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- **Leaking `wonderful-fetch` mock in the webhook-forward unit test.** `test/helpers/webhook-forward.js` installs a stub into `require.cache['wonderful-fetch']` at module load (the sanctioned cross-project fan-out exception — there's no second BEM emulator to receive the real fan-out POSTs), but never restored it. Because every test file is `require()`d into the same process, the stub leaked process-wide: every later test whose route did `require('wonderful-fetch')` got `{ received: true }` in 0ms instead of a real HTTP round-trip (observed breaking consumer sponsorship + inbound-email route tests). The helper now saves the original cache entry and restores it in a suite-level `cleanup()`, confining the mock to its own file.
|
|
21
|
+
|
|
17
22
|
# [5.3.0] - 2026-06-02
|
|
18
23
|
|
|
19
24
|
### Added
|
package/package.json
CHANGED
|
@@ -21,7 +21,15 @@
|
|
|
21
21
|
|
|
22
22
|
// Mock wonderful-fetch before requiring the route — the route does
|
|
23
23
|
// `require('wonderful-fetch')` at module load time.
|
|
24
|
+
//
|
|
25
|
+
// CRITICAL: every test file is `require()`d into the SAME Node process by the
|
|
26
|
+
// runner, so the require cache is shared. We MUST save the original
|
|
27
|
+
// wonderful-fetch cache entry here and restore it in the suite-level `cleanup`
|
|
28
|
+
// below — otherwise this mock leaks into every test file that runs afterwards
|
|
29
|
+
// (e.g. emulator route tests whose `Manager.require('wonderful-fetch')` would
|
|
30
|
+
// then return our stub instead of doing a real HTTP round-trip).
|
|
24
31
|
const originalFetchPath = require.resolve('wonderful-fetch');
|
|
32
|
+
const originalFetchCacheEntry = require.cache[originalFetchPath];
|
|
25
33
|
const fetchCalls = [];
|
|
26
34
|
let fetchMockBehavior = () => ({ received: true });
|
|
27
35
|
|
|
@@ -38,6 +46,17 @@ require.cache[originalFetchPath] = {
|
|
|
38
46
|
|
|
39
47
|
const route = require('../../src/manager/routes/marketing/webhook/forward/post.js');
|
|
40
48
|
|
|
49
|
+
// Restore the real wonderful-fetch in the require cache so the mock is confined
|
|
50
|
+
// to this file. Without this, the stub leaks process-wide and poisons every
|
|
51
|
+
// later test file's HTTP calls.
|
|
52
|
+
function restoreFetch() {
|
|
53
|
+
if (originalFetchCacheEntry) {
|
|
54
|
+
require.cache[originalFetchPath] = originalFetchCacheEntry;
|
|
55
|
+
} else {
|
|
56
|
+
delete require.cache[originalFetchPath];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
41
60
|
// --- Test scaffolding ---
|
|
42
61
|
|
|
43
62
|
function makeFirestoreMock(brandDocs) {
|
|
@@ -114,6 +133,13 @@ function withEnv(envOverrides, fn) {
|
|
|
114
133
|
module.exports = {
|
|
115
134
|
description: 'webhook/forward unit tests (mocked admin + fetch)',
|
|
116
135
|
type: 'group',
|
|
136
|
+
|
|
137
|
+
// Restore the real wonderful-fetch after this file's tests so the require-cache
|
|
138
|
+
// stub does not leak into any test file that runs later in the same process.
|
|
139
|
+
cleanup() {
|
|
140
|
+
restoreFetch();
|
|
141
|
+
},
|
|
142
|
+
|
|
117
143
|
tests: [
|
|
118
144
|
// ─── Gating ───
|
|
119
145
|
|