diff --git a/cypress/integration/control_link.js b/cypress/integration/control_link.js index 918155b99b..70a644bfcd 100644 --- a/cypress/integration/control_link.js +++ b/cypress/integration/control_link.js @@ -29,8 +29,7 @@ context('Control Link', () => { it('should set the valid value', () => { get_dialog_with_link().as('dialog'); - cy.server(); - cy.route('POST', '/api/method/frappe.desk.search.search_link').as('search_link'); + cy.intercept('POST', '/api/method/frappe.desk.search.search_link').as('search_link'); cy.get('.frappe-control[data-fieldname=link] input').focus().as('input'); cy.wait('@search_link'); @@ -50,8 +49,7 @@ context('Control Link', () => { it('should unset invalid value', () => { get_dialog_with_link().as('dialog'); - cy.server(); - cy.route('GET', '/api/method/frappe.desk.form.utils.validate_link*').as('validate_link'); + cy.intercept('GET', '/api/method/frappe.desk.form.utils.validate_link*').as('validate_link'); cy.get('.frappe-control[data-fieldname=link] input') .type('invalid value', { delay: 100 }) @@ -63,9 +61,8 @@ context('Control Link', () => { it('should route to form on arrow click', () => { get_dialog_with_link().as('dialog'); - cy.server(); - cy.route('GET', '/api/method/frappe.desk.form.utils.validate_link*').as('validate_link'); - cy.route('POST', '/api/method/frappe.desk.search.search_link').as('search_link'); + cy.intercept('GET', '/api/method/frappe.desk.form.utils.validate_link*').as('validate_link'); + cy.intercept('POST', '/api/method/frappe.desk.search.search_link').as('search_link'); cy.get('@todos').then(todos => { cy.get('.frappe-control[data-fieldname=link] input').as('input'); diff --git a/cypress/integration/file_uploader.js b/cypress/integration/file_uploader.js index 9c5e5b8d52..23023bb3fe 100644 --- a/cypress/integration/file_uploader.js +++ b/cypress/integration/file_uploader.js @@ -31,10 +31,9 @@ context('FileUploader', () => { }); cy.get_open_dialog().find('.file-name').should('contain', 'example.json'); - cy.server(); - cy.route('POST', '/api/method/upload_file').as('upload_file'); + cy.intercept('POST', '/api/method/upload_file').as('upload_file'); cy.get_open_dialog().find('.btn-modal-primary').click(); - cy.wait('@upload_file').its('status').should('eq', 200); + cy.wait('@upload_file').its('response.statusCode').should('eq', 200); cy.get('.modal:visible').should('not.exist'); }); }); @@ -45,8 +44,7 @@ context('FileUploader', () => { cy.get_open_dialog().find('.btn-file-upload div:contains("Library")').click(); cy.get('.file-filter').type('example.json'); cy.get_open_dialog().find('.tree-label:contains("example.json")').first().click(); - cy.server(); - cy.route('POST', '/api/method/upload_file').as('upload_file'); + cy.intercept('POST', '/api/method/upload_file').as('upload_file'); cy.get_open_dialog().find('.btn-primary').click(); cy.wait('@upload_file').its('response.body.message') .should('have.property', 'file_url', '/private/files/example.json'); @@ -58,8 +56,7 @@ context('FileUploader', () => { cy.get_open_dialog().find('.btn-file-upload div:contains("Link")').click(); cy.get_open_dialog().find('.file-web-link input').type('https://github.com', { delay: 100, force: true }); - cy.server(); - cy.route('POST', '/api/method/upload_file').as('upload_file'); + cy.intercept('POST', '/api/method/upload_file').as('upload_file'); cy.get_open_dialog().find('.btn-primary').click(); cy.wait('@upload_file').its('response.body.message') .should('have.property', 'file_url', 'https://github.com'); diff --git a/cypress/integration/form.js b/cypress/integration/form.js index f471858d8c..9c63fe4e8b 100644 --- a/cypress/integration/form.js +++ b/cypress/integration/form.js @@ -11,13 +11,12 @@ context('Form', () => { cy.fill_field('description', 'this is a test todo', 'Text Editor').blur(); cy.wait(300); cy.get('.page-title').should('contain', 'Not Saved'); - cy.server(); - cy.route({ + cy.intercept({ method: 'POST', url: 'api/method/frappe.desk.form.save.savedocs' }).as('form_save'); cy.get('.primary-action').click(); - cy.wait('@form_save').its('status').should('eq', 200); + cy.wait('@form_save').its('response.statusCode').should('eq', 200); cy.visit('/app/todo'); cy.get('.title-text').should('be.visible').and('contain', 'To Do'); cy.get('.list-row').should('contain', 'this is a test todo'); diff --git a/cypress/integration/list_view.js b/cypress/integration/list_view.js index 49525f2a16..633d1335ab 100644 --- a/cypress/integration/list_view.js +++ b/cypress/integration/list_view.js @@ -14,17 +14,18 @@ context('List View', () => { cy.get('.dropdown-menu li:visible .dropdown-item').should('have.length', 8).each((el, index) => { cy.wrap(el).contains(actions[index]); }).then((elements) => { - cy.server(); - cy.route({ + cy.intercept({ method: 'POST', url: 'api/method/frappe.model.workflow.bulk_workflow_approval' }).as('bulk-approval'); - cy.route({ + cy.intercept({ method: 'POST', url: 'api/method/frappe.desk.reportview.get' }).as('real-time-update'); cy.wrap(elements).contains('Approve').click(); cy.wait(['@bulk-approval', '@real-time-update']); + cy.hide_dialog(); + cy.clear_filters(); cy.get('.list-row-container:visible').should('contain', 'Approved'); }); }); diff --git a/cypress/integration/login.js b/cypress/integration/login.js index ee889df6b8..6b109dd18d 100644 --- a/cypress/integration/login.js +++ b/cypress/integration/login.js @@ -2,7 +2,7 @@ context('Login', () => { beforeEach(() => { cy.request('/api/method/logout'); cy.visit('/login'); - cy.location().should('be', '/login'); + cy.location('pathname').should('eq', '/login'); }); it('greets with login screen', () => { diff --git a/cypress/integration/recorder.js b/cypress/integration/recorder.js index 87495ac00a..bde6626ea1 100644 --- a/cypress/integration/recorder.js +++ b/cypress/integration/recorder.js @@ -30,9 +30,8 @@ context('Recorder', () => { cy.get('.msg-box').should('contain', 'No Requests'); - cy.server(); cy.visit('/app/List/DocType/List'); - cy.route('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh'); + cy.intercept('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh'); cy.wait('@list_refresh'); cy.get('.title-text').should('contain', 'DocType'); @@ -53,9 +52,8 @@ context('Recorder', () => { cy.get('#page-recorder .btn-secondary').should('contain', 'Clear').click(); cy.get('.primary-action').should('contain', 'Start').click(); - cy.server(); cy.visit('/app/List/DocType/List'); - cy.route('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh'); + cy.intercept('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh'); cy.wait('@list_refresh'); cy.get('.title-text').should('contain', 'DocType'); diff --git a/cypress/integration/relative_time_filters.js b/cypress/integration/relative_time_filters.js index 380d488547..d2a2ed68e7 100644 --- a/cypress/integration/relative_time_filters.js +++ b/cypress/integration/relative_time_filters.js @@ -18,14 +18,13 @@ context('Relative Timeframe', () => { cy.get('.fieldname-select-area input').type("Due Date{enter}", { delay: 100 }); cy.get('select.condition.form-control').select("Timespan"); cy.get('.filter-field select.input-with-feedback.form-control').select("last week"); - cy.server(); - cy.route('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh'); + cy.intercept('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh'); // cy.get('.filter-box .btn:contains("Apply")').click(); cy.get('.filter-popover .apply-filters').click({ force: true }); cy.wait('@list_refresh'); cy.get('.list-row-container').its('length').should('eq', 1); cy.get('.list-row-container').should('contain', 'this is second todo'); - cy.route('POST', '/api/method/frappe.model.utils.user_settings.save') + cy.intercept('POST', '/api/method/frappe.model.utils.user_settings.save') .as('save_user_settings'); cy.clear_filters(); cy.wait('@save_user_settings'); @@ -38,14 +37,13 @@ context('Relative Timeframe', () => { cy.get('.fieldname-select-area input').type("Due Date{enter}", { delay: 100 }); cy.get('select.condition.form-control').select("Timespan"); cy.get('.filter-field select.input-with-feedback.form-control').select("next week"); - cy.server(); - cy.route('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh'); + cy.intercept('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh'); // cy.get('.filter-box .btn:contains("Apply")').click(); cy.get('.filter-popover .apply-filters').click({ force: true }); cy.wait('@list_refresh'); // cy.get('.list-row-container').its('length').should('eq', 1); // cy.get('.list-row').should('contain', 'this is first todo'); - cy.route('POST', '/api/method/frappe.model.utils.user_settings.save') + cy.intercept('POST', '/api/method/frappe.model.utils.user_settings.save') .as('save_user_settings'); // cy.get('.remove-filter').click(); cy.clear_filters(); diff --git a/cypress/integration/report_view.js b/cypress/integration/report_view.js index d1a3e4dfd8..ea76246ae2 100644 --- a/cypress/integration/report_view.js +++ b/cypress/integration/report_view.js @@ -16,8 +16,7 @@ context('Report View', () => { }, true).as('doc'); }); it('Field with enabled allow_on_submit should be editable.', () => { - cy.server(); - cy.route('POST', 'api/method/frappe.client.set_value').as('value-update'); + cy.intercept('POST', 'api/method/frappe.client.set_value').as('value-update'); cy.visit(`/app/List/${doctype_name}/Report`); // check status column added from docstatus cy.get('.dt-row-0 > .dt-cell--col-3').should('contain', 'Submitted'); diff --git a/cypress/integration/table_multiselect.js b/cypress/integration/table_multiselect.js index be3f52f971..8b83a0d914 100644 --- a/cypress/integration/table_multiselect.js +++ b/cypress/integration/table_multiselect.js @@ -17,11 +17,10 @@ context('Table MultiSelect', () => { .as('selected-value'); cy.get('@selected-value').should('contain', 'test@erpnext.com'); - cy.server(); - cy.route('POST', '/api/method/frappe.desk.form.save.savedocs').as('save_form'); + cy.intercept('POST', '/api/method/frappe.desk.form.save.savedocs').as('save_form'); // trigger save cy.get('.primary-action').click(); - cy.wait('@save_form').its('status').should('eq', 200); + cy.wait('@save_form').its('response.statusCode').should('eq', 200); cy.get('@selected-value').should('contain', 'test@erpnext.com'); }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index fd1db96b55..fac4a9330c 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -320,4 +320,7 @@ Cypress.Commands.add('clear_filters', () => { cy.wait(300); cy.get('.filter-popover').should('exist'); cy.get('.filter-popover').find('.clear-filters').click(); + cy.window().its('cur_list').then(cur_list => { + cur_list && cur_list.filter_area && cur_list.filter_area.clear(); + }); });