blob: 3bd60d7855161743fd15565b5f36e6710c333c9c [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001declare namespace Cypress {
2 interface Chainable {
3 drawingBoardTreeOpenContextMenuByElementDataTestId: typeof drawingBoardTreeOpenContextMenuByElementDataTestId,
Ittay Sternf7926712019-07-07 19:23:03 +03004 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 Stern6f900cc2018-08-29 17:01:32 +030011 }
12}
13
14function drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId : string, index ?: number) : Chainable<any> {
15 return cy.getElementByDataTestsId(dataTestId + "-menu-btn").eq(index != null ? index : 0).click({force: true});
16}
17
18function 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 Sternf7926712019-07-07 19:23:03 +030026 case 'Delete':
27 return cy.getElementByDataTestsId('context-menu-delete').trigger('mouseover').click();
Einat Vinouzee1f79742019-08-27 16:01:01 +030028 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 Stern6f900cc2018-08-29 17:01:32 +030032 default:
33 return cy.getElementByDataTestsId('context-menu-duplicate').click({force : true});
34 }
35}
36
Ittay Sternf7926712019-07-07 19:23:03 +030037function 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
43function 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}
48function nodeWithLineThrough(index: number)
49{
50 cy.getElementByDataTestsId('node-name').eq(index).should('have.css', 'text-decoration').and('contain''line-through')
51}
52
53function nodeWithoutLineThrough(index: number)
54{
55 cy.getElementByDataTestsId('node-name').eq(index).should('have.css', 'text-decoration').and('not.contain''line-through')
56}
57
58
59function IsDeleteTagShownOnNode(index: number)
60{
61 cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "1");
62}
63
Einat Vinouzee1f79742019-08-27 16:01:01 +030064function IsUpgradeTagShownOnNode(index: number)
65{
66 cy.getElementByDataTestsId('upgrade-status-type').eq(index).should("contain.text", "Upgrade").should("contain.css", "opacity", "1");
67}
68
Ittay Sternf7926712019-07-07 19:23:03 +030069function IsDeleteTagNotShownOnNode(index: number)
70{
71 cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "0");
72}
Ittay Stern6f900cc2018-08-29 17:01:32 +030073
74Cypress.Commands.add('drawingBoardTreeOpenContextMenuByElementDataTestId', drawingBoardTreeOpenContextMenuByElementDataTestId);
75Cypress.Commands.add('drawingBoardTreeClickOnContextMenuOptionByName', drawingBoardTreeClickOnContextMenuOptionByName);
Ittay Sternf7926712019-07-07 19:23:03 +030076Cypress.Commands.add('nodeWithLineThrough', nodeWithLineThrough);
77Cypress.Commands.add('nodeWithoutLineThrough', nodeWithoutLineThrough);
78Cypress.Commands.add('IsDeleteTagShownOnNode', IsDeleteTagShownOnNode);
79Cypress.Commands.add('IsDeleteTagNotShownOnNode', IsDeleteTagNotShownOnNode);
Ittay Sternf7926712019-07-07 19:23:03 +030080Cypress.Commands.add('isNodeDeleted', isNodeDeleted);
81Cypress.Commands.add('isNodeNotDeleted', isNodeNotDeleted);