blob: a0bfdb6b36bf32fa2dbb5b4d4af98794093da9cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
declare namespace Cypress {
interface Chainable {
assertMenuItemsForNode: typeof assertMenuItemsForNode
}
}
function assertMenuItemsForNode(enabledActions: string[], nodeName: string, index: number = 0) : Chainable<any> {
let node = cy.getElementByDataTestsId(nodeName).eq(+index);
node.trigger('mouseover').click().then(()=> {
//waiting to the menu to appear to catch options that shall not exist but actually exist
cy.get('.ngx-contextmenu').should('exist').then(()=> {
for (let option of ['duplicate', 'showAuditInfo', 'addGroupMember', 'delete', 'undoDelete', 'remove', ...enabledActions]) {
cy.getElementByDataTestsId(`context-menu-${option}`).should(enabledActions.some(s => s === option) ? 'exist' : 'not.exist');
}});
});
return node;
}
Cypress.Commands.add('assertMenuItemsForNode', assertMenuItemsForNode);
|