Skip to content

Commit a59811b

Browse files
authored
test(plugin-e2e): fix appConfig settings test for Grafana 13.1.0 (#2743)
1 parent 01fabe9 commit a59811b

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

packages/plugin-e2e/tests/as-admin-user/app/app-config/appConfig.spec.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@ test('should navigate to app config page for provided plugin id when created', a
77

88
test('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: /Disable|Enable/i }).first();
25+
await enableDisableButton.waitFor({ state: 'visible' });
1726

1827
const response = configPage.waitForSettingsResponse();
19-
await page.getByRole('button', { name: /Disable|Enable/i }).first().click();
28+
await enableDisableButton.click();
2029
await expect(response).toBeOK();
2130
});

0 commit comments

Comments
 (0)