blob: a940ae15ea554ce74835ab36cfef02e51637733c [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();
Ittay Stern6f900cc2018-08-29 17:01:32 +030028 default:
29 return cy.getElementByDataTestsId('context-menu-duplicate').click({force : true});
30 }
31}
32
Ittay Sternf7926712019-07-07 19:23:03 +030033function 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
39function 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}
44function nodeWithLineThrough(index: number)
45{
46 cy.getElementByDataTestsId('node-name').eq(index).should('have.css', 'text-decoration').and('contain''line-through')
47}
48
49function nodeWithoutLineThrough(index: number)
50{
51 cy.getElementByDataTestsId('node-name').eq(index).should('have.css', 'text-decoration').and('not.contain''line-through')
52}
53
54
55function IsDeleteTagShownOnNode(index: number)
56{
57 cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "1");
58}
59
60function IsDeleteTagNotShownOnNode(index: number)
61{
62 cy.getElementByDataTestsId('delete-status-type').eq(index).should("contain.text", "Delete").should("contain.css", "opacity", "0");
63}
Ittay Stern6f900cc2018-08-29 17:01:32 +030064
65Cypress.Commands.add('drawingBoardTreeOpenContextMenuByElementDataTestId', drawingBoardTreeOpenContextMenuByElementDataTestId);
66Cypress.Commands.add('drawingBoardTreeClickOnContextMenuOptionByName', drawingBoardTreeClickOnContextMenuOptionByName);
Ittay Sternf7926712019-07-07 19:23:03 +030067Cypress.Commands.add('nodeWithLineThrough', nodeWithLineThrough);
68Cypress.Commands.add('nodeWithoutLineThrough', nodeWithoutLineThrough);
69Cypress.Commands.add('IsDeleteTagShownOnNode', IsDeleteTagShownOnNode);
70Cypress.Commands.add('IsDeleteTagNotShownOnNode', IsDeleteTagNotShownOnNode);
71
72Cypress.Commands.add('isNodeDeleted', isNodeDeleted);
73Cypress.Commands.add('isNodeNotDeleted', isNodeNotDeleted);