Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 1 | declare namespace Cypress { |
| 2 | interface Chainable { |
| 3 | drawingBoardTreeOpenContextMenuByElementDataTestId: typeof drawingBoardTreeOpenContextMenuByElementDataTestId, |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame^] | 4 | drawingBoardTreeClickOnContextMenuOptionByName: typeof drawingBoardTreeClickOnContextMenuOptionByName, |
| 5 | nodeWithLineThrough: typeof nodeWithLineThrough, |
| 6 | nodeWithoutLineThrough: typeof nodeWithoutLineThrough, |
| 7 | IsDeleteTagShownOnNode: typeof IsDeleteTagShownOnNode, |
| 8 | IsDeleteTagNotShownOnNode: typeof IsDeleteTagNotShownOnNode, |
| 9 | isNodeDeleted: typeof isNodeDeleted, |
| 10 | isNodeNotDeleted: typeof isNodeNotDeleted |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 11 | } |
| 12 | } |
| 13 | |
| 14 | function drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId : string, index ?: number) : Chainable<any> { |
| 15 | return cy.getElementByDataTestsId(dataTestId + "-menu-btn").eq(index != null ? index : 0).click({force: true}); |
| 16 | } |
| 17 | |
| 18 | function drawingBoardTreeClickOnContextMenuOptionByName(optionName : string) : Chainable<any> { |
| 19 | switch (optionName) { |
| 20 | case 'Duplicate': |
| 21 | return cy.getElementByDataTestsId('context-menu-duplicate').click({force : true}); |
| 22 | case 'Remove': |
| 23 | return cy.getElementByDataTestsId('context-menu-remove').click({force : true}); |
| 24 | case 'Edit': |
| 25 | return cy.getElementByDataTestsId('context-menu-edit').click({force : true}); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame^] | 26 | case 'Delete': |
| 27 | return cy.getElementByDataTestsId('context-menu-delete').trigger('mouseover').click(); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 28 | default: |
| 29 | return cy.getElementByDataTestsId('context-menu-duplicate').click({force : true}); |
| 30 | } |
| 31 | } |
| 32 | |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame^] | 33 | function isNodeDeleted(index: number) |
| 34 | { |
| 35 | cy.get('.tree-node').eq(1).find('[data-tests-id="node-name"]').eq(index).should('have.css', 'text-decoration').and('contain', 'line-through'); |
| 36 | cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "1"); |
| 37 | } |
| 38 | |
| 39 | function isNodeNotDeleted(index: number) |
| 40 | { |
| 41 | cy.get('.tree-node').eq(1).find('[data-tests-id="node-name"]').eq(index).should('have.css', 'text-decoration').and('not.contain', 'line-through'); |
| 42 | cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "0"); |
| 43 | } |
| 44 | function nodeWithLineThrough(index: number) |
| 45 | { |
| 46 | cy.getElementByDataTestsId('node-name').eq(index).should('have.css', 'text-decoration').and('contain', 'line-through') |
| 47 | } |
| 48 | |
| 49 | function nodeWithoutLineThrough(index: number) |
| 50 | { |
| 51 | cy.getElementByDataTestsId('node-name').eq(index).should('have.css', 'text-decoration').and('not.contain', 'line-through') |
| 52 | } |
| 53 | |
| 54 | |
| 55 | function IsDeleteTagShownOnNode(index: number) |
| 56 | { |
| 57 | cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "1"); |
| 58 | } |
| 59 | |
| 60 | function IsDeleteTagNotShownOnNode(index: number) |
| 61 | { |
| 62 | cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "0"); |
| 63 | } |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 64 | |
| 65 | Cypress.Commands.add('drawingBoardTreeOpenContextMenuByElementDataTestId', drawingBoardTreeOpenContextMenuByElementDataTestId); |
| 66 | Cypress.Commands.add('drawingBoardTreeClickOnContextMenuOptionByName', drawingBoardTreeClickOnContextMenuOptionByName); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame^] | 67 | Cypress.Commands.add('nodeWithLineThrough', nodeWithLineThrough); |
| 68 | Cypress.Commands.add('nodeWithoutLineThrough', nodeWithoutLineThrough); |
| 69 | Cypress.Commands.add('IsDeleteTagShownOnNode', IsDeleteTagShownOnNode); |
| 70 | Cypress.Commands.add('IsDeleteTagNotShownOnNode', IsDeleteTagNotShownOnNode); |
| 71 | |
| 72 | Cypress.Commands.add('isNodeDeleted', isNodeDeleted); |
| 73 | Cypress.Commands.add('isNodeNotDeleted', isNodeNotDeleted); |