Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame^] | 1 | declare namespace Cypress { |
| 2 | interface Chainable { |
| 3 | drawingBoardTreeOpenContextMenuByElementDataTestId: typeof drawingBoardTreeOpenContextMenuByElementDataTestId, |
| 4 | drawingBoardTreeClickOnContextMenuOptionByName: typeof drawingBoardTreeClickOnContextMenuOptionByName |
| 5 | } |
| 6 | } |
| 7 | |
| 8 | function drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId : string, index ?: number) : Chainable<any> { |
| 9 | return cy.getElementByDataTestsId(dataTestId + "-menu-btn").eq(index != null ? index : 0).click({force: true}); |
| 10 | } |
| 11 | |
| 12 | function drawingBoardTreeClickOnContextMenuOptionByName(optionName : string) : Chainable<any> { |
| 13 | switch (optionName) { |
| 14 | case 'Duplicate': |
| 15 | return cy.getElementByDataTestsId('context-menu-duplicate').click({force : true}); |
| 16 | case 'Remove': |
| 17 | return cy.getElementByDataTestsId('context-menu-remove').click({force : true}); |
| 18 | case 'Edit': |
| 19 | return cy.getElementByDataTestsId('context-menu-edit').click({force : true}); |
| 20 | default: |
| 21 | return cy.getElementByDataTestsId('context-menu-duplicate').click({force : true}); |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | |
| 26 | Cypress.Commands.add('drawingBoardTreeOpenContextMenuByElementDataTestId', drawingBoardTreeOpenContextMenuByElementDataTestId); |
| 27 | Cypress.Commands.add('drawingBoardTreeClickOnContextMenuOptionByName', drawingBoardTreeClickOnContextMenuOptionByName); |