Merge "Semicolon at the end of the Statement and Remove trailing whitespaces at the...
[vid.git] / vid-webpack-master / cypress / support / steps / drawingBoard / drawingBoardTree.steps.ts
1 declare namespace Cypress {
2   interface Chainable {
3     drawingBoardTreeOpenContextMenuByElementDataTestId: typeof drawingBoardTreeOpenContextMenuByElementDataTestId,
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
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});
26     case 'Delete':
27       return cy.getElementByDataTestsId('context-menu-delete').trigger('mouseover').click();
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();
32     default:
33       return cy.getElementByDataTestsId('context-menu-duplicate').click({force : true});
34   }
35 }
36
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
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
69 function IsDeleteTagNotShownOnNode(index: number)
70 {
71   cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "0");
72 }
73
74 Cypress.Commands.add('drawingBoardTreeOpenContextMenuByElementDataTestId', drawingBoardTreeOpenContextMenuByElementDataTestId);
75 Cypress.Commands.add('drawingBoardTreeClickOnContextMenuOptionByName', drawingBoardTreeClickOnContextMenuOptionByName);
76 Cypress.Commands.add('nodeWithLineThrough', nodeWithLineThrough);
77 Cypress.Commands.add('nodeWithoutLineThrough', nodeWithoutLineThrough);
78 Cypress.Commands.add('IsDeleteTagShownOnNode', IsDeleteTagShownOnNode);
79 Cypress.Commands.add('IsDeleteTagNotShownOnNode', IsDeleteTagNotShownOnNode);
80 Cypress.Commands.add('isNodeDeleted', isNodeDeleted);
81 Cypress.Commands.add('isNodeNotDeleted', isNodeNotDeleted);