Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 1 | declare 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 | |
| 19 | Cypress.Commands.add('assertMenuItemsForNode', assertMenuItemsForNode); |