mirror of
https://github.com/tiennm99/ccs.git
synced 2026-08-07 04:23:41 +00:00
test(browser): 扩展 fulfill interception harness
为 Phase 6B 增加 Fetch.fulfillRequest 记录能力,便于后续 mock response TDD。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
a93e0b6494
commit
23eccb24f3
@@ -107,10 +107,18 @@ type MockInterceptRuleMatch = {
|
|||||||
requestId?: string;
|
requestId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type MockFulfilledRequest = {
|
||||||
|
requestId: string;
|
||||||
|
responseCode?: number;
|
||||||
|
responseHeaders?: Array<{ name: string; value: string }>;
|
||||||
|
body?: string;
|
||||||
|
};
|
||||||
|
|
||||||
type MockInterceptState = {
|
type MockInterceptState = {
|
||||||
pausedRequests?: MockInterceptRuleMatch[];
|
pausedRequests?: MockInterceptRuleMatch[];
|
||||||
continuedRequestIds?: string[];
|
continuedRequestIds?: string[];
|
||||||
failedRequests?: Array<{ requestId: string; errorReason?: string }>;
|
failedRequests?: Array<{ requestId: string; errorReason?: string }>;
|
||||||
|
fulfilledRequests?: MockFulfilledRequest[];
|
||||||
fetchEnabledPatterns?: unknown[];
|
fetchEnabledPatterns?: unknown[];
|
||||||
enableError?: string;
|
enableError?: string;
|
||||||
pauseDispatchDelayMs?: number;
|
pauseDispatchDelayMs?: number;
|
||||||
@@ -734,6 +742,22 @@ function createMockBrowser(pagesInput: MockPageState[]) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message.method === 'Fetch.fulfillRequest') {
|
||||||
|
page.intercept = page.intercept || {};
|
||||||
|
page.intercept.fulfilledRequests = page.intercept.fulfilledRequests || [];
|
||||||
|
page.intercept.fulfilledRequests.push({
|
||||||
|
requestId: String(message.params?.requestId || ''),
|
||||||
|
responseCode:
|
||||||
|
typeof message.params?.responseCode === 'number' ? message.params.responseCode : undefined,
|
||||||
|
responseHeaders: Array.isArray(message.params?.responseHeaders)
|
||||||
|
? (message.params.responseHeaders as Array<{ name: string; value: string }>)
|
||||||
|
: [],
|
||||||
|
body: typeof message.params?.body === 'string' ? message.params.body : '',
|
||||||
|
});
|
||||||
|
reply({});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (message.method !== 'Runtime.evaluate') {
|
if (message.method !== 'Runtime.evaluate') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user