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(); |
Einat Vinouze | e1f7974 | 2019-08-27 16:01:01 +0300 | [diff] [blame] | 28 | case 'Upgrade': |
| 29 | return cy.getElementByDataTestsId('context-menu-upgrade').trigger('mouseover').click(); |
| 30 | case 'Undo Upgrade': |
| 31 | return cy.getElementByDataTestsId('context-menu-undoUpgrade').trigger('mouseover').click(); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 32 | default: |
| 33 | return cy.getElementByDataTestsId('context-menu-duplicate').click({force : true}); |
| 34 | } |
| 35 | } |
| 36 | |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 37 | function isNodeDeleted(index: number) |
| 38 | { |
| 39 | cy.get('.tree-node').eq(1).find('[data-tests-id="node-name"]').eq(index).should('have.css', 'text-decoration').and('contain', 'line-through'); |
| 40 | cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "1"); |
| 41 | } |
| 42 | |
| 43 | function isNodeNotDeleted(index: number) |
| 44 | { |
| 45 | cy.get('.tree-node').eq(1).find('[data-tests-id="node-name"]').eq(index).should('have.css', 'text-decoration').and('not.contain', 'line-through'); |
| 46 | cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "0"); |
| 47 | } |
| 48 | function nodeWithLineThrough(index: number) |
| 49 | { |
| 50 | cy.getElementByDataTestsId('node-name').eq(index).should('have.css', 'text-decoration').and('contain', 'line-through') |
| 51 | } |
| 52 | |
| 53 | function nodeWithoutLineThrough(index: number) |
| 54 | { |
| 55 | cy.getElementByDataTestsId('node-name').eq(index).should('have.css', 'text-decoration').and('not.contain', 'line-through') |
| 56 | } |
| 57 | |
| 58 | |
| 59 | function IsDeleteTagShownOnNode(index: number) |
| 60 | { |
| 61 | cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "1"); |
| 62 | } |
| 63 | |
Einat Vinouze | e1f7974 | 2019-08-27 16:01:01 +0300 | [diff] [blame] | 64 | function IsUpgradeTagShownOnNode(index: number) |
| 65 | { |
| 66 | cy.getElementByDataTestsId('upgrade-status-type').eq(index).should("contain.text", "Upgrade").should("contain.css", "opacity", "1"); |
| 67 | } |
| 68 | |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 69 | function IsDeleteTagNotShownOnNode(index: number) |
| 70 | { |
| 71 | cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "0"); |
| 72 | } |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 73 | |
| 74 | Cypress.Commands.add('drawingBoardTreeOpenContextMenuByElementDataTestId', drawingBoardTreeOpenContextMenuByElementDataTestId); |
| 75 | Cypress.Commands.add('drawingBoardTreeClickOnContextMenuOptionByName', drawingBoardTreeClickOnContextMenuOptionByName); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 76 | Cypress.Commands.add('nodeWithLineThrough', nodeWithLineThrough); |
| 77 | Cypress.Commands.add('nodeWithoutLineThrough', nodeWithoutLineThrough); |
| 78 | Cypress.Commands.add('IsDeleteTagShownOnNode', IsDeleteTagShownOnNode); |
| 79 | Cypress.Commands.add('IsDeleteTagNotShownOnNode', IsDeleteTagNotShownOnNode); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 80 | Cypress.Commands.add('isNodeDeleted', isNodeDeleted); |
| 81 | Cypress.Commands.add('isNodeNotDeleted', isNodeNotDeleted); |