Skip to content

Commit d870210

Browse files
committed
fix: align test output with McpResponse
1 parent 6925f5a commit d870210

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

src/McpResponse.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,12 @@ Call browser_handle_dialog to handle it before continuing.`);
185185
response.push('Invalid page token provided. Showing first page.');
186186
}
187187

188+
const { startIndex, endIndex } = paginationResult;
189+
response.push(
190+
`Showing ${startIndex + 1}-${endIndex} of ${requests.length}.`,
191+
);
192+
188193
if (this.#networkRequestsPaginationOptions) {
189-
const { startIndex, endIndex } = paginationResult;
190-
response.push(
191-
`Showing ${startIndex + 1}-${endIndex} of ${requests.length}.`,
192-
);
193194
if (paginationResult.nextPageToken) {
194195
response.push(`Next: ${paginationResult.nextPageToken}`);
195196
}

tests/McpResponse.test.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* Copyright 2025 Google LLC
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
import {describe, it} from 'node:test';
6+
import { describe, it } from 'node:test';
77
import assert from 'assert';
88

9-
import {getMockRequest, html, withBrowser} from './utils.js';
9+
import { getMockRequest, html, withBrowser } from './utils.js';
1010

1111
describe('McpResponse', () => {
1212
it('list pages', async () => {
@@ -120,7 +120,7 @@ Navigation timeout set to 100000 ms`,
120120
});
121121
it('adds image when image is attached', async () => {
122122
await withBrowser(async (response, context) => {
123-
response.attachImage({data: 'imageBase64', mimeType: 'image/png'});
123+
response.attachImage({ data: 'imageBase64', mimeType: 'image/png' });
124124
const result = await response.handle('test', context);
125125
assert.strictEqual(result[0].text, `# test response`);
126126
assert.equal(result[1].type, 'image');
@@ -181,9 +181,13 @@ Call browser_handle_dialog to handle it before continuing.`,
181181
return [getMockRequest()];
182182
};
183183
const result = await response.handle('test', context);
184-
const text = result[0].text as string;
185-
assert.ok(text.includes(`## Network requests`));
186-
assert.ok(text.includes('http://example.com GET [pending]'));
184+
assert.strictEqual(
185+
result[0].text,
186+
`# test response
187+
## Network requests
188+
Showing 1-1 of 1.
189+
http://example.com GET [pending]`,
190+
);
187191
});
188192
});
189193
it('does not include network requests when setting is false', async () => {
@@ -263,7 +267,7 @@ Log>`),
263267
describe('McpResponse network pagination', () => {
264268
it('returns all requests when pagination is not provided', async () => {
265269
await withBrowser(async (response, context) => {
266-
const requests = Array.from({length: 5}, () => getMockRequest());
270+
const requests = Array.from({ length: 5 }, () => getMockRequest());
267271
context.getNetworkRequests = () => requests;
268272
response.setIncludeNetworkRequests(true);
269273
const result = await response.handle('test', context);
@@ -276,13 +280,13 @@ describe('McpResponse network pagination', () => {
276280

277281
it('returns first page by default', async () => {
278282
await withBrowser(async (response, context) => {
279-
const requests = Array.from({length: 30}, (_, idx) =>
280-
getMockRequest({method: `GET-${idx}`}),
283+
const requests = Array.from({ length: 30 }, (_, idx) =>
284+
getMockRequest({ method: `GET-${idx}` }),
281285
);
282286
context.getNetworkRequests = () => {
283287
return requests;
284288
};
285-
response.setIncludeNetworkRequests(true, {pageSize: 10});
289+
response.setIncludeNetworkRequests(true, { pageSize: 10 });
286290
const result = await response.handle('test', context);
287291
const text = (result[0].text as string).toString();
288292
assert.ok(text.includes('Showing 1-10 of 30.'));
@@ -293,8 +297,8 @@ describe('McpResponse network pagination', () => {
293297

294298
it('returns subsequent page when token provided', async () => {
295299
await withBrowser(async (response, context) => {
296-
const requests = Array.from({length: 25}, (_, idx) =>
297-
getMockRequest({method: `GET-${idx}`}),
300+
const requests = Array.from({ length: 25 }, (_, idx) =>
301+
getMockRequest({ method: `GET-${idx}` }),
298302
);
299303
context.getNetworkRequests = () => requests;
300304
response.setIncludeNetworkRequests(true, {
@@ -311,7 +315,7 @@ describe('McpResponse network pagination', () => {
311315

312316
it('handles invalid token by showing first page', async () => {
313317
await withBrowser(async (response, context) => {
314-
const requests = Array.from({length: 5}, () => getMockRequest());
318+
const requests = Array.from({ length: 5 }, () => getMockRequest());
315319
context.getNetworkRequests = () => requests;
316320
response.setIncludeNetworkRequests(true, {
317321
pageSize: 2,

0 commit comments

Comments
 (0)