@@ -10,6 +10,10 @@ import {tmpdir} from 'node:os';
1010import { join } from 'node:path' ;
1111import { describe , it } from 'node:test' ;
1212
13+ import sinon from 'sinon' ;
14+
15+ import { AggregatedIssue } from '../node_modules/chrome-devtools-frontend/mcp/mcp.js' ;
16+
1317import {
1418 getMockRequest ,
1519 getMockResponse ,
@@ -295,6 +299,46 @@ describe('McpResponse', () => {
295299 t . assert . snapshot ?.( result [ 0 ] . text ) ;
296300 } ) ;
297301 } ) ;
302+
303+ it ( 'doesn\'t list the issue message if mapping returns null' , async ( ) => {
304+ await withBrowser ( async ( response , context ) => {
305+ const mockAggregatedIssue = sinon . createStubInstance ( AggregatedIssue ) ;
306+ const mockDescription = {
307+ file : 'not-existing-description-file.md' ,
308+ links : [ ] ,
309+ } ;
310+ mockAggregatedIssue . getDescription . returns ( mockDescription ) ;
311+ response . setIncludeConsoleData ( true ) ;
312+ context . getConsoleData = ( ) => {
313+ return [ mockAggregatedIssue ] ;
314+ } ;
315+
316+ const result = await response . handle ( 'test' , context ) ;
317+ const text = ( result [ 0 ] . text as string ) . toString ( ) ;
318+ assert . ok ( text . includes ( '<no console messages found>' ) ) ;
319+ } ) ;
320+ } ) ;
321+
322+ it ( 'throws error if mapping returns null on get issue details' , async ( ) => {
323+ await withBrowser ( async ( response , context ) => {
324+ const mockAggregatedIssue = sinon . createStubInstance ( AggregatedIssue ) ;
325+ const mockDescription = {
326+ file : 'not-existing-description-file.md' ,
327+ links : [ ] ,
328+ } ;
329+ mockAggregatedIssue . getDescription . returns ( mockDescription ) ;
330+ response . attachConsoleMessage ( 1 ) ;
331+ context . getConsoleMessageById = ( ) => {
332+ return mockAggregatedIssue ;
333+ } ;
334+
335+ try {
336+ await response . handle ( 'test' , context ) ;
337+ } catch ( e ) {
338+ assert . ok ( e . message . includes ( 'Can\'t prpovide detals for the msgid 1' ) ) ;
339+ }
340+ } ) ;
341+ } ) ;
298342} ) ;
299343
300344describe ( 'McpResponse network request filtering' , ( ) => {
0 commit comments