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