MCPcopy Create free account
hub / github.com/Rello/analytics / openNavigationEntryMenu

Function openNavigationEntryMenu

tests/playwright/common.js:244–293  ·  view source on GitHub ↗
(page, name)

Source from the content-addressed store, hash-verified

242}
243
244async function openNavigationEntryMenu(page, name) {
245 const buttons = page.locator(`button[data-name="${name.replace(/"/g, '\\"')}"]`);
246 await buttons.first().waitFor({ state: 'attached', timeout: 15000 });
247
248 let button = buttons.filter({ visible: true }).first();
249 if (!(await button.count())) {
250 await ensureNavigationSection(page, 'reports');
251 button = buttons.filter({ visible: true }).first();
252 }
253
254 if (!(await button.count())) {
255 button = buttons.first();
256 }
257
258 let menu = button.locator('xpath=ancestor::div[contains(@class,"app-navigation-entry-utils")]/following-sibling::div[@id="navigationMenu"][1]').first();
259 if (!(await menu.count())) {
260 menu = page.locator(`.app-navigation-entry-menu.open[data-name="${name.replace(/"/g, '\\"')}"]`).first();
261 }
262 if (!(await menu.count())) {
263 menu = navigationEntryMenu(page, name).filter({ visible: true }).first();
264 }
265 if (!(await menu.count())) {
266 menu = navigationEntryMenu(page, name).first();
267 }
268
269 const openMenu = async () => {
270 await button.hover().catch(() => {});
271 await button.click().catch(() => {});
272 const visibleAfterClick = await menu.isVisible().catch(() => false);
273 if (visibleAfterClick) {
274 return true;
275 }
276
277 await button.evaluate((element) => element.click()).catch(() => {});
278 return page.waitForFunction((target) => {
279 return target instanceof HTMLElement &&
280 target.classList.contains('open') &&
281 window.getComputedStyle(target).display !== 'none' &&
282 window.getComputedStyle(target).visibility !== 'hidden';
283 }, await menu.elementHandle(), { timeout: 3000 }).then(() => true).catch(() => false);
284 };
285
286 const opened = await openMenu();
287 if (!opened) {
288 await button.click({ force: true }).catch(() => {});
289 }
290
291 await menu.waitFor({ state: 'visible', timeout: 10000 });
292 return menu;
293}
294
295async function clickNavigationMenuAction(menu, action, label = action) {
296 const actions = {

Callers 6

renameNavigationEntryFunction · 0.85
deleteNavigationEntryFunction · 0.85
openReportBasicSettingsFunction · 0.85
openReportAutomationTabFunction · 0.85
setReportFavoriteFunction · 0.85

Calls 6

ensureNavigationSectionFunction · 0.85
navigationEntryMenuFunction · 0.85
openMenuFunction · 0.85
filterMethod · 0.80
countMethod · 0.80
firstMethod · 0.45

Tested by

no test coverage detected