diff --git a/maps/tests/Metadata/customMenu.js b/maps/tests/Metadata/customMenu.js
index 7cedb632..a04cb760 100644
--- a/maps/tests/Metadata/customMenu.js
+++ b/maps/tests/Metadata/customMenu.js
@@ -1,7 +1,7 @@
let menuIframeApi = undefined;
WA.ui.registerMenuCommand('custom callback menu', () => {
- WA.nav.openTab("https://workadventu.re/");
+ WA.chat.sendChatMessage('Custom menu clicked', 'Mr Robot');
})
WA.ui.registerMenuCommand('custom iframe menu', {iframe: 'customIframeMenu.html'});
diff --git a/maps/tests/index.html b/maps/tests/index.html
index 9adba52d..610337ee 100644
--- a/maps/tests/index.html
+++ b/maps/tests/index.html
@@ -224,7 +224,7 @@
Success Failure Pending
- Testing add a custom menu by scripting API
+ Testing add a custom menu by scripting API (already automated in E2E tests)
|
diff --git a/tests/tests/iframe_script.spec.ts b/tests/tests/iframe_script.spec.ts
index ab4e17ae..5da011d2 100644
--- a/tests/tests/iframe_script.spec.ts
+++ b/tests/tests/iframe_script.spec.ts
@@ -13,4 +13,26 @@ test.describe('Iframe API', () => {
await expect(page.locator('p.other-text')).toHaveText('The iframe opened by a script works !', {useInnerText: true});
});
+
+ test('can add a custom menu by scripting API', async ({
+ page,
+ }) => {
+ await page.goto(
+ 'http://play.workadventure.localhost/_/global/maps.workadventure.localhost/tests/Metadata/customMenu.json'
+ );
+
+ await login(page);
+
+ await page.click('.menuIcon img:first-child');
+
+ await page.click('button:has-text("custom iframe menu")');
+
+ const iframeParagraph = page
+ .frameLocator('.menu-submenu-container iframe')
+ .locator('p');
+ await expect(iframeParagraph).toHaveText('This is an iframe in a custom menu.');
+
+ await page.click('button:has-text("custom callback menu")');
+ await expect(page.locator('p.other-text')).toHaveText('Custom menu clicked', {useInnerText: true});
+ });
});