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

Function openNavigationEntryMenu

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

Source from the content-addressed store, hash-verified

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

Callers 6

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

Calls 4

ensureNavigationSectionFunction · 0.85
navigationEntryMenuFunction · 0.85
openMenuFunction · 0.85
firstMethod · 0.80

Tested by

no test coverage detected