From c2abb0088658dbd4ccd1b6d1b0caf4661e029176 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 8 Mar 2022 15:44:14 +0530 Subject: [PATCH] test: failing report_view UI test fix --- cypress/integration/list_paging.js | 35 ++++++++++++++++++++++++++++++ cypress/integration/report_view.js | 31 -------------------------- frappe/tests/ui_test_helpers.py | 11 ++++++---- 3 files changed, 42 insertions(+), 35 deletions(-) create mode 100644 cypress/integration/list_paging.js diff --git a/cypress/integration/list_paging.js b/cypress/integration/list_paging.js new file mode 100644 index 0000000000..b6832f5a53 --- /dev/null +++ b/cypress/integration/list_paging.js @@ -0,0 +1,35 @@ +context('List Paging', () => { + before(() => { + cy.login(); + cy.visit('/app/website'); + return cy.window().its('frappe').then(frappe => { + return frappe.call("frappe.tests.ui_test_helpers.create_multiple_todo_records"); + }); + }); + + it('test load more with count selection buttons', () => { + cy.visit('/app/todo/view/report'); + + cy.get('.list-paging-area .list-count').should('contain.text', '20 of'); + cy.get('.list-paging-area .btn-more').click(); + cy.get('.list-paging-area .list-count').should('contain.text', '40 of'); + cy.get('.list-paging-area .btn-more').click(); + cy.get('.list-paging-area .list-count').should('contain.text', '60 of'); + + cy.get('.list-paging-area .btn-group .btn-paging[data-value="100"]').click(); + + cy.get('.list-paging-area .list-count').should('contain.text', '100 of'); + cy.get('.list-paging-area .btn-more').click(); + cy.get('.list-paging-area .list-count').should('contain.text', '200 of'); + cy.get('.list-paging-area .btn-more').click(); + cy.get('.list-paging-area .list-count').should('contain.text', '300 of'); + + // check if refresh works after load more + cy.get('.page-head .standard-actions [data-original-title="Refresh"]').click(); + cy.get('.list-paging-area .list-count').should('contain.text', '300 of'); + + cy.get('.list-paging-area .btn-group .btn-paging[data-value="500"]').click(); + + cy.get('.list-paging-area .list-count').should('contain.text', '500 of'); + }); +}); diff --git a/cypress/integration/report_view.js b/cypress/integration/report_view.js index 6e3a28bbfc..bacbf9c172 100644 --- a/cypress/integration/report_view.js +++ b/cypress/integration/report_view.js @@ -13,9 +13,6 @@ context('Report View', () => { 'enabled': 0, 'docstatus': 1 // submit document }, true); - return cy.window().its('frappe').then(frappe => { - return frappe.call("frappe.tests.ui_test_helpers.create_multiple_contact_records"); - }); }); it('Field with enabled allow_on_submit should be editable.', () => { @@ -43,32 +40,4 @@ context('Report View', () => { expect(r.message.enabled).to.equals(1); }); }); - - it('test load more with count selection buttons', () => { - cy.visit('/app/contact/view/report'); - - cy.get('.list-paging-area .list-count').should('contain.text', '20 of'); - cy.get('.list-paging-area .btn-more').click(); - cy.get('.list-paging-area .list-count').should('contain.text', '40 of'); - cy.get('.list-paging-area .btn-more').click(); - cy.get('.list-paging-area .list-count').should('contain.text', '60 of'); - - cy.get('.list-paging-area .btn-group .btn-paging[data-value="100"]').click(); - - cy.get('.list-paging-area .list-count').should('contain.text', '100 of'); - cy.get('.list-paging-area .btn-more').click(); - cy.get('.list-paging-area .list-count').should('contain.text', '200 of'); - cy.get('.list-paging-area .btn-more').click(); - cy.get('.list-paging-area .list-count').should('contain.text', '300 of'); - - // check if refresh works after load more - cy.get('.page-head .standard-actions [data-original-title="Refresh"]').click(); - cy.get('.list-paging-area .list-count').should('contain.text', '300 of'); - - cy.get('.list-paging-area .btn-group .btn-paging[data-value="500"]').click(); - - cy.get('.list-paging-area .list-count').should('contain.text', '500 of'); - cy.get('.list-paging-area .btn-more').click(); - cy.get('.list-paging-area .list-count').should('contain.text', '1000 of'); - }); }); diff --git a/frappe/tests/ui_test_helpers.py b/frappe/tests/ui_test_helpers.py index 26c20f3d18..473f9b22d3 100644 --- a/frappe/tests/ui_test_helpers.py +++ b/frappe/tests/ui_test_helpers.py @@ -135,11 +135,14 @@ def create_contact_records(): insert_contact('Test Form Contact 3', '12345') @frappe.whitelist() -def create_multiple_contact_records(): - if frappe.db.get_all('Contact', {'first_name': 'Multiple Contact 1'}): +def create_multiple_todo_records(): + if frappe.db.get_all('ToDo', {'description': 'Multiple ToDo 1'}): return - for index in range(1001): - insert_contact('Multiple Contact {}'.format(index+1), '12345{}'.format(index+1)) + for index in range(501): + frappe.get_doc({ + 'doctype': 'ToDo', + 'description': 'Multiple ToDo {}'.format(index+1) + }).insert() def insert_contact(first_name, phone_number): doc = frappe.get_doc({