blob: 0150b44aa29e4c0f1f70f1dd195c2a414bede578 [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001declare namespace Cypress {
2 interface Chainable {
3 drawingBoardTreeOpenContextMenuByElementDataTestId: typeof drawingBoardTreeOpenContextMenuByElementDataTestId,
4 drawingBoardTreeClickOnContextMenuOptionByName: typeof drawingBoardTreeClickOnContextMenuOptionByName
5 }
6}
7
8function drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId : string, index ?: number) : Chainable<any> {
9 return cy.getElementByDataTestsId(dataTestId + "-menu-btn").eq(index != null ? index : 0).click({force: true});
10}
11
12function 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
26Cypress.Commands.add('drawingBoardTreeOpenContextMenuByElementDataTestId', drawingBoardTreeOpenContextMenuByElementDataTestId);
27Cypress.Commands.add('drawingBoardTreeClickOnContextMenuOptionByName', drawingBoardTreeClickOnContextMenuOptionByName);