Commit 480ed35
committed
fix(test): extend provider-http mock with readProviderJsonResponse (#96036)
Addresses the ClawSweeper P1 finding that
`src/plugin-sdk/test-helpers/provider-http-mocks.ts` mocks the
`openclaw/plugin-sdk/provider-http` module without exporting
`readProviderJsonResponse`, causing import-time failure in Qwen/Alibaba
video tests now that `dashscope-compatible.ts` routes submit/poll
through the bounded helper.
Changes:
- `src/plugin-sdk/test-helpers/provider-http-mocks.ts` (+22):
- Added `readProviderJsonResponse` type import
- Added `ReadProviderJsonResponseParams` type alias
- Added `readProviderJsonResponseMock` field to `ProviderHttpMocks`
- Added hoisted mock default implementation that calls `response.json()`
(parity with the legacy unbounded read, leaves cap enforcement to the
production helper)
- Added to `vi.mock(openclaw/plugin-sdk/provider-http, ...)` export map
- Added to `installProviderHttpMockCleanup` mockClear list
- `scripts/repro/issue-dashscope-response-cap.mjs` (+100):
- Existing helper-only assertion kept (proves helper stops early)
- New assertion: drives `pollDashscopeVideoTaskUntilComplete` end-to-end
with a 100 MiB streaming body, asserts bounded-reader error surfaces
before the runtime buffers the full payload
- New assertion: drives `runDashscopeVideoGenerationTask` end-to-end
with a 100 MiB streaming body on the submit response, asserts the
submit path is also bounded
- Negative control kept (raw `response.json()` buffers full body)
Verified on commit:
- `node scripts/run-vitest.mjs extensions/qwen/video-generation-provider.test.ts`
— 5/5 passed (was 3/5 fail before this fix)
- `node scripts/run-vitest.mjs extensions/alibaba/video-generation-provider.test.ts`
— 3/3 passed
- `node scripts/run-vitest.mjs src/video-generation/dashscope-compatible.bounded-json.test.ts`
— 4/4 passed
- `pnpm exec tsx scripts/repro/issue-dashscope-response-cap.mjs`
— 4/4 PASS (helper + poll path + submit path + negative control)
- `npx oxlint --import-plugin --config .oxlintrc.json` on changed files — exit 0
- `node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json`
— exit 01 parent ee14da9 commit 480ed35
2 files changed
Lines changed: 120 additions & 6 deletions
File tree
- scripts/repro
- src/plugin-sdk/test-helpers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
23 | 30 | | |
24 | 31 | | |
25 | 32 | | |
| |||
74 | 81 | | |
75 | 82 | | |
76 | 83 | | |
77 | | - | |
| 84 | + | |
78 | 85 | | |
79 | 86 | | |
80 | 87 | | |
81 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
82 | 176 | | |
83 | 177 | | |
84 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
51 | 60 | | |
52 | 61 | | |
53 | 62 | | |
| |||
68 | 77 | | |
69 | 78 | | |
70 | 79 | | |
| 80 | + | |
71 | 81 | | |
72 | 82 | | |
73 | 83 | | |
| |||
164 | 174 | | |
165 | 175 | | |
166 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
167 | 185 | | |
168 | 186 | | |
169 | 187 | | |
| |||
233 | 251 | | |
234 | 252 | | |
235 | 253 | | |
| 254 | + | |
236 | 255 | | |
237 | 256 | | |
238 | 257 | | |
| |||
261 | 280 | | |
262 | 281 | | |
263 | 282 | | |
| 283 | + | |
264 | 284 | | |
265 | 285 | | |
0 commit comments