@@ -7,15 +7,24 @@ test('should navigate to app config page for provided plugin id when created', a
77
88test ( 'should wait for plugin config settings API to respond' , async ( { gotoAppConfigPage, page } ) => {
99 const configPage = await gotoAppConfigPage ( { pluginId : 'redis-app' } ) ;
10- await page . route (
11- '/api/plugins/redis-app/settings' ,
12- async ( route ) => {
10+ // only intercept the settings save (POST) so we don't mutate server state. the GET that
11+ // fetches plugin meta - and renders the enable/disable button - must reach the real backend,
12+ // otherwise the button never renders. since Grafana 13.1.0 the meta GET fires after navigation
13+ // completes, so a method-agnostic mock would swallow it and leave the button missing.
14+ await page . route ( '/api/plugins/redis-app/settings' , async ( route ) => {
15+ if ( route . request ( ) . method ( ) === 'POST' ) {
1316 await route . fulfill ( { status : 200 } ) ;
14- } ,
15- { times : 1 }
16- ) ;
17+ } else {
18+ await route . fallback ( ) ;
19+ }
20+ } ) ;
21+
22+ // wait for the enable/disable button to render (meta GET resolved) before listening for the
23+ // save response, so we capture the POST triggered by the click and not the meta GET
24+ const enableDisableButton = page . getByRole ( 'button' , { name : / D i s a b l e | E n a b l e / i } ) . first ( ) ;
25+ await enableDisableButton . waitFor ( { state : 'visible' } ) ;
1726
1827 const response = configPage . waitForSettingsResponse ( ) ;
19- await page . getByRole ( 'button' , { name : / D i s a b l e | E n a b l e / i } ) . first ( ) . click ( ) ;
28+ await enableDisableButton . click ( ) ;
2029 await expect ( response ) . toBeOK ( ) ;
2130} ) ;
0 commit comments