From b897a41b088a564f63f80b28d4413bd2aaa1485f Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Thu, 12 Aug 2021 13:25:24 +0530 Subject: [PATCH 1/3] test: Added test script for dashboard links (tests if any doc is added to any dashboard connection, the counter for it is updated or not) --- cypress/integration/dashboard_links.js | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 cypress/integration/dashboard_links.js diff --git a/cypress/integration/dashboard_links.js b/cypress/integration/dashboard_links.js new file mode 100644 index 0000000000..4a3a7e25ed --- /dev/null +++ b/cypress/integration/dashboard_links.js @@ -0,0 +1,39 @@ +context('Dashboard links', () => { + before(() => { + cy.visit('/login'); + cy.login(); + cy.visit('/app/user'); + }); + + it('Adding a new contact, checking for the counter on the dashboard and deleting the created contact', () => { + cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click(); + + //To check if initially the dashboard contains only the "Contact" link and there is no counter + cy.get('[data-doctype="Contact"]').should('contain','Contact'); + + //Adding a new contact + cy.get('.btn[data-doctype="Contact"]').click(); + cy.get('.has-error > .form-group > .control-input-wrapper > .control-input > .input-with-feedback').type('Admin'); + cy.get('#page-Contact > .page-head > .container > .row > .col > .standard-actions > .primary-action').click(); + cy.visit('/app/user'); + cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click(); + + //To check if the counter for contact doc is "1" after adding the contact + cy.get('[data-doctype="Contact"] > .count').should('contain','1'); + cy.get('[data-doctype="Contact"]').contains('Contact').click(); + + //Deleting the newly created contact + cy.visit('/app/contact'); + cy.get('.list-subject > .select-like > .list-row-checkbox').eq(0).click(); + cy.get('.actions-btn-group > .btn').contains('Actions').click(); + cy.get('.actions-btn-group > .dropdown-menu > li > .grey-link').eq(5).click(); + cy.get('.modal-footer > .standard-actions > .btn-primary').contains('Yes').click({delay : 700}); + + + //To check if the counter from the "Contact" doc link is removed + cy.visit('/app/user'); + cy.wait(700); + cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click(); + cy.get('[data-doctype="Contact"]').should('contain','Contact'); + }); +}); \ No newline at end of file From 06efca0fa659afb6437cc8ad525807baa37c14e2 Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Thu, 12 Aug 2021 13:48:03 +0530 Subject: [PATCH 2/3] test: Fixed sider issues --- cypress/integration/dashboard_links.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress/integration/dashboard_links.js b/cypress/integration/dashboard_links.js index 4a3a7e25ed..6bf2d22dad 100644 --- a/cypress/integration/dashboard_links.js +++ b/cypress/integration/dashboard_links.js @@ -9,7 +9,7 @@ context('Dashboard links', () => { cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click(); //To check if initially the dashboard contains only the "Contact" link and there is no counter - cy.get('[data-doctype="Contact"]').should('contain','Contact'); + cy.get('[data-doctype="Contact"]').should('contain', 'Contact'); //Adding a new contact cy.get('.btn[data-doctype="Contact"]').click(); @@ -19,7 +19,7 @@ context('Dashboard links', () => { cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click(); //To check if the counter for contact doc is "1" after adding the contact - cy.get('[data-doctype="Contact"] > .count').should('contain','1'); + cy.get('[data-doctype="Contact"] > .count').should('contain', '1'); cy.get('[data-doctype="Contact"]').contains('Contact').click(); //Deleting the newly created contact @@ -27,13 +27,13 @@ context('Dashboard links', () => { cy.get('.list-subject > .select-like > .list-row-checkbox').eq(0).click(); cy.get('.actions-btn-group > .btn').contains('Actions').click(); cy.get('.actions-btn-group > .dropdown-menu > li > .grey-link').eq(5).click(); - cy.get('.modal-footer > .standard-actions > .btn-primary').contains('Yes').click({delay : 700}); + cy.get('.modal-footer > .standard-actions > .btn-primary').contains('Yes').click({delay: 700}); //To check if the counter from the "Contact" doc link is removed cy.visit('/app/user'); cy.wait(700); cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click(); - cy.get('[data-doctype="Contact"]').should('contain','Contact'); + cy.get('[data-doctype="Contact"]').should('contain', 'Contact'); }); }); \ No newline at end of file From de3050cd81478de35a9c78e660195480f95c7523 Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Fri, 20 Aug 2021 12:47:51 +0530 Subject: [PATCH 3/3] test: Corrected selectors and shorten them (Using the added testing-library) --- cypress/integration/dashboard_links.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cypress/integration/dashboard_links.js b/cypress/integration/dashboard_links.js index 6bf2d22dad..e6c9a7e08c 100644 --- a/cypress/integration/dashboard_links.js +++ b/cypress/integration/dashboard_links.js @@ -13,8 +13,8 @@ context('Dashboard links', () => { //Adding a new contact cy.get('.btn[data-doctype="Contact"]').click(); - cy.get('.has-error > .form-group > .control-input-wrapper > .control-input > .input-with-feedback').type('Admin'); - cy.get('#page-Contact > .page-head > .container > .row > .col > .standard-actions > .primary-action').click(); + cy.get('[data-doctype="Contact"][data-fieldname="first_name"]').type('Admin'); + cy.findByRole('button', {name: 'Save'}).click(); cy.visit('/app/user'); cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click(); @@ -25,15 +25,15 @@ context('Dashboard links', () => { //Deleting the newly created contact cy.visit('/app/contact'); cy.get('.list-subject > .select-like > .list-row-checkbox').eq(0).click(); - cy.get('.actions-btn-group > .btn').contains('Actions').click(); - cy.get('.actions-btn-group > .dropdown-menu > li > .grey-link').eq(5).click(); - cy.get('.modal-footer > .standard-actions > .btn-primary').contains('Yes').click({delay: 700}); + cy.findByRole('button', {name: 'Actions'}).click(); + cy.get('.actions-btn-group [data-label="Delete"]').click(); + cy.findByRole('button', {name: 'Yes'}).click({delay: 700}); //To check if the counter from the "Contact" doc link is removed - cy.visit('/app/user'); cy.wait(700); + cy.visit('/app/user'); cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click(); cy.get('[data-doctype="Contact"]').should('contain', 'Contact'); }); -}); \ No newline at end of file +});