@@ -32,13 +32,13 @@ describe('pages', () => {
3232 describe ( 'new_page' , ( ) => {
3333 it ( 'create a page' , async ( ) => {
3434 await withMcpContext ( async ( response , context ) => {
35- assert . strictEqual ( context . getPageByIdx ( 0 ) , context . getSelectedPage ( ) ) ;
35+ assert . strictEqual ( context . getPageById ( 1 ) , context . getSelectedPage ( ) ) ;
3636 await newPage . handler (
3737 { params : { url : 'about:blank' } } ,
3838 response ,
3939 context ,
4040 ) ;
41- assert . strictEqual ( context . getPageByIdx ( 1 ) , context . getSelectedPage ( ) ) ;
41+ assert . strictEqual ( context . getPageById ( 2 ) , context . getSelectedPage ( ) ) ;
4242 assert . ok ( response . includePages ) ;
4343 } ) ;
4444 } ) ;
@@ -47,17 +47,17 @@ describe('pages', () => {
4747 it ( 'closes a page' , async ( ) => {
4848 await withMcpContext ( async ( response , context ) => {
4949 const page = await context . newPage ( ) ;
50- assert . strictEqual ( context . getPageByIdx ( 1 ) , context . getSelectedPage ( ) ) ;
51- assert . strictEqual ( context . getPageByIdx ( 1 ) , page ) ;
52- await closePage . handler ( { params : { pageIdx : 1 } } , response , context ) ;
50+ assert . strictEqual ( context . getPageById ( 2 ) , context . getSelectedPage ( ) ) ;
51+ assert . strictEqual ( context . getPageById ( 2 ) , page ) ;
52+ await closePage . handler ( { params : { pageId : 2 } } , response , context ) ;
5353 assert . ok ( page . isClosed ( ) ) ;
5454 assert . ok ( response . includePages ) ;
5555 } ) ;
5656 } ) ;
5757 it ( 'cannot close the last page' , async ( ) => {
5858 await withMcpContext ( async ( response , context ) => {
5959 const page = context . getSelectedPage ( ) ;
60- await closePage . handler ( { params : { pageIdx : 0 } } , response , context ) ;
60+ await closePage . handler ( { params : { pageId : 1 } } , response , context ) ;
6161 assert . deepStrictEqual (
6262 response . responseLines [ 0 ] ,
6363 `The last open page cannot be closed. It is fine to keep it open.` ,
@@ -71,24 +71,24 @@ describe('pages', () => {
7171 it ( 'selects a page' , async ( ) => {
7272 await withMcpContext ( async ( response , context ) => {
7373 await context . newPage ( ) ;
74- assert . strictEqual ( context . getPageByIdx ( 1 ) , context . getSelectedPage ( ) ) ;
75- await selectPage . handler ( { params : { pageIdx : 0 } } , response , context ) ;
76- assert . strictEqual ( context . getPageByIdx ( 0 ) , context . getSelectedPage ( ) ) ;
74+ assert . strictEqual ( context . getPageById ( 2 ) , context . getSelectedPage ( ) ) ;
75+ await selectPage . handler ( { params : { pageId : 1 } } , response , context ) ;
76+ assert . strictEqual ( context . getPageById ( 1 ) , context . getSelectedPage ( ) ) ;
7777 assert . ok ( response . includePages ) ;
7878 } ) ;
7979 } ) ;
8080 it ( 'selects a page and keeps it focused in the background' , async ( ) => {
8181 await withMcpContext ( async ( response , context ) => {
8282 await context . newPage ( ) ;
83- assert . strictEqual ( context . getPageByIdx ( 1 ) , context . getSelectedPage ( ) ) ;
83+ assert . strictEqual ( context . getPageById ( 2 ) , context . getSelectedPage ( ) ) ;
8484 assert . strictEqual (
85- await context . getPageByIdx ( 0 ) . evaluate ( ( ) => document . hasFocus ( ) ) ,
85+ await context . getPageById ( 1 ) . evaluate ( ( ) => document . hasFocus ( ) ) ,
8686 false ,
8787 ) ;
88- await selectPage . handler ( { params : { pageIdx : 0 } } , response , context ) ;
89- assert . strictEqual ( context . getPageByIdx ( 0 ) , context . getSelectedPage ( ) ) ;
88+ await selectPage . handler ( { params : { pageId : 1 } } , response , context ) ;
89+ assert . strictEqual ( context . getPageById ( 1 ) , context . getSelectedPage ( ) ) ;
9090 assert . strictEqual (
91- await context . getPageByIdx ( 0 ) . evaluate ( ( ) => document . hasFocus ( ) ) ,
91+ await context . getPageById ( 1 ) . evaluate ( ( ) => document . hasFocus ( ) ) ,
9292 true ,
9393 ) ;
9494 assert . ok ( response . includePages ) ;
@@ -115,8 +115,8 @@ describe('pages', () => {
115115 it ( 'throws an error if the page was closed not by the MCP server' , async ( ) => {
116116 await withMcpContext ( async ( response , context ) => {
117117 const page = await context . newPage ( ) ;
118- assert . strictEqual ( context . getPageByIdx ( 1 ) , context . getSelectedPage ( ) ) ;
119- assert . strictEqual ( context . getPageByIdx ( 1 ) , page ) ;
118+ assert . strictEqual ( context . getPageById ( 2 ) , context . getSelectedPage ( ) ) ;
119+ assert . strictEqual ( context . getPageById ( 2 ) , page ) ;
120120
121121 await page . close ( ) ;
122122
0 commit comments