// Not meant to extend QContextMenu, just to have utility methods here in case QContextMenu has bugs
|
|
import { QContextMenu } from '../e2elib/lib/api/pageobjects/qcontextmenu.component';
|
|
/**
|
* Context menu item to click on. ContextMenu field to define the parent context menu technical name.
|
*/
|
export interface ContextMenuItemSOP {
|
ContextMenu: string;
|
Name: string;
|
Label: string;
|
}
|
|
export class ContextMenuSOP {
|
/**
|
* If menu disabled but has NO tooltip, we cannot invoke QContextMenu.isMenuItemClickable() as it will return error tooltip not visible.
|
* Caller decide if need verify tooltip so that we use the appropriate method to either check clickable only (without query tooltip) or
|
* invoke the usual QContextMenu.isMenuItemClickable() which returns tuple [boolean clickable, string tooltip].
|
*
|
* @param contextMenu QContextMenu element to verify.
|
* @param menuItemName Context menu item name.
|
* @param needVerifyTooltip Caller decide if needs to verify tooltip. Pass false to skip tooltip check.
|
* @param waitTime [Optional] Miliseconds of how long it should wait for menu to be clickable.
|
* @returns An array of combination of boolean and string, where boolean indicates whether the menuItem is clickable and string indicating the disabled tooltip
|
*/
|
public static async verifyIsMenuItemClickable(contextMenu: QContextMenu, menuItemName: string | string[], needVerifyTooltip: boolean = true): Promise<[boolean, string]> {
|
let disabledTooltip = '';
|
const isEnabled = await contextMenu.isMenuItemClickable(menuItemName);
|
|
// Only query tooltip if caller wants to (else if menu disabled and has NO tooltip, an error tooltip not visible thrown)
|
if (needVerifyTooltip && !isEnabled) {
|
disabledTooltip = await contextMenu.getToolTip(menuItemName);
|
}
|
|
return [isEnabled, disabledTooltip];
|
}
|
|
public static getMenuPaths(menuName: string): string | string[] {
|
const tokens = menuName.split('|');
|
|
return tokens.length === 1 ? menuName : tokens;
|
}
|
}
|