fix(tests): add ui tests for grid pagination
This commit is contained in:
parent
731c041762
commit
f3a656d515
2 changed files with 57 additions and 0 deletions
45
cypress/integration/grid_pagination.js
Normal file
45
cypress/integration/grid_pagination.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
context('Grid Pagination', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/desk#Form/Contact/Test Contact');
|
||||
});
|
||||
before(() => {
|
||||
cy.login();
|
||||
cy.visit('/desk');
|
||||
cy.window().its('frappe').then(frappe => {
|
||||
frappe.call("frappe.tests.ui_test_helpers.create_contact_phone_nos_records");
|
||||
});
|
||||
});
|
||||
it('creates pages for child table', () => {
|
||||
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
|
||||
cy.get('@table').find('.current-page-number').should('contain', '1');
|
||||
cy.get('@table').find('.total-page-number').should('contain', '50');
|
||||
cy.get('@table').find('.grid-body .grid-row').should('have.length', 20);
|
||||
});
|
||||
it('goes to the next and previous page', () => {
|
||||
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
|
||||
cy.get('@table').find('.next-page').click();
|
||||
cy.get('@table').find('.current-page-number').should('contain', '2');
|
||||
cy.get('@table').find('.grid-body .grid-row').first().should('have.attr', 'data-idx', '21');
|
||||
cy.get('@table').find('.prev-page').click();
|
||||
cy.get('@table').find('.current-page-number').should('contain', '1');
|
||||
cy.get('@table').find('.grid-body .grid-row').first().should('have.attr', 'data-idx', '1');
|
||||
});
|
||||
it('adds and deletes rows and changes page', ()=> {
|
||||
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
|
||||
cy.get('@table').find('button.grid-add-row').click();
|
||||
cy.get('@table').find('.grid-body .row-index').should('contain', 1001);
|
||||
cy.get('@table').find('.current-page-number').should('contain', '51');
|
||||
cy.get('@table').find('.total-page-number').should('contain', '51');
|
||||
cy.get('@table').find('.grid-body .grid-row .grid-row-check').click({force: true});
|
||||
cy.get('@table').find('button.grid-remove-rows').click();
|
||||
cy.get('@table').find('.grid-body .row-index').last().should('contain', 1000);
|
||||
cy.get('@table').find('.current-page-number').should('contain', '50');
|
||||
cy.get('@table').find('.total-page-number').should('contain', '50');
|
||||
});
|
||||
it('deletes all rows', ()=> {
|
||||
cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
|
||||
cy.get('@table').find('.grid-heading-row .grid-row-check').click({force: true});
|
||||
cy.get('@table').find('button.grid-remove-all-rows').click();
|
||||
cy.get('@table').find('.grid-body .grid-row').should('have.length', 0);
|
||||
});
|
||||
});
|
||||
|
|
@ -63,3 +63,15 @@ def setup_workflow():
|
|||
create_todo_workflow()
|
||||
create_todo_records()
|
||||
frappe.clear_cache()
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_contact_phone_nos_records():
|
||||
if frappe.db.get_all('Contact', {'first_name': 'Test Contact'}):
|
||||
return
|
||||
|
||||
doc = frappe.new_doc('Contact')
|
||||
doc.first_name = 'Test Contact'
|
||||
doc.insert()
|
||||
for x in range(1000):
|
||||
doc.append('phone_nos', {'phone': '123456789'})
|
||||
doc.save()
|
||||
Loading…
Add table
Reference in a new issue