@@ -18,7 +18,6 @@ import {
1818 reloadExtension ,
1919 triggerExtensionAction ,
2020} from '../../src/tools/extensions.js' ;
21- import { listPages } from '../../src/tools/pages.js' ;
2221import { extractExtensionId , withMcpContext } from '../utils.js' ;
2322
2423const EXTENSION_WITH_SW_PATH = path . join (
@@ -125,58 +124,29 @@ describe('extension', () => {
125124 assert . ok ( reinstalled , 'Extension should be present after reload' ) ;
126125 } ) ;
127126 } ) ;
128- it ( 'triggers an extension action' , async t => {
127+ it ( 'triggers an extension action' , async ( ) => {
129128 await withMcpContext (
130129 async ( response , context ) => {
131130 const extensionId = await context . installExtension (
132131 EXTENSION_WITH_SW_PATH ,
133132 ) ;
134133
135- const listPageDef = listPages ( {
136- categoryExtensions : true ,
137- } as ParsedArguments ) ;
138- await listPageDef . handler (
139- { params : { } , page : context . getSelectedMcpPage ( ) } ,
140- response ,
141- context ,
142- ) ;
143- let result = await response . handle ( listPageDef . name , context ) ;
144- let textContent = result . content . find ( c => c . type === 'text' ) as {
145- type : 'text' ;
146- text : string ;
147- } ;
148- t . assert . snapshot ?.(
149- textContent . text . replaceAll ( extensionId , '<extension-id>' ) ,
134+ const targetsBefore = context . browser . targets ( ) ;
135+ const pageTargetBefore = targetsBefore . find (
136+ t => t . type ( ) === 'page' && t . url ( ) . includes ( extensionId ) ,
150137 ) ;
138+ assert . ok ( ! pageTargetBefore , 'Page should not exist before action' ) ;
151139
152140 await triggerExtensionAction . handler (
153141 { params : { id : extensionId } } ,
154142 response ,
155143 context ,
156144 ) ;
157145
158- const swTarget = await context . browser . waitForTarget (
159- t => t . type ( ) === 'service_worker' && t . url ( ) . includes ( extensionId ) ,
160- ) ;
161- const swUrl = swTarget . url ( ) ;
162-
163- response . resetResponseLineForTesting ( ) ;
164- await listPageDef . handler (
165- { params : { } , page : context . getSelectedMcpPage ( ) } ,
166- response ,
167- context ,
168- ) ;
169- result = await response . handle ( listPageDef . name , context ) ;
170- textContent = result . content . find ( c => c . type === 'text' ) as {
171- type : 'text' ;
172- text : string ;
173- } ;
174- t . assert . snapshot ?.(
175- textContent . text
176- . replaceAll ( extensionId , '<extension-id>' )
177- . replaceAll ( swUrl , '<sw-url>' )
178- . replaceAll ( / l o c a l h o s t : \d + / g, 'localhost:<port>' ) ,
146+ const pageTargetAfter = await context . browser . waitForTarget (
147+ t => t . type ( ) === 'page' && t . url ( ) . includes ( extensionId ) ,
179148 ) ;
149+ assert . ok ( pageTargetAfter , 'Page should exist after action' ) ;
180150 } ,
181151 {
182152 executablePath : process . env . CANARY_EXECUTABLE_PATH ,
0 commit comments