From b9ebe88c5ae12c540c9dd8fcac8605aaefe6ab1b Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 25 Oct 2021 16:53:59 +0530 Subject: [PATCH 01/23] ci: install dev dependency without condition --- .github/helper/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/helper/install.sh b/.github/helper/install.sh index 454cc89694..8cc3d01a6c 100644 --- a/.github/helper/install.sh +++ b/.github/helper/install.sh @@ -50,7 +50,7 @@ if [ "$TYPE" == "server" ]; then sed -i 's/^socketio:/# socketio:/g' Procfile; f if [ "$TYPE" == "server" ]; then sed -i 's/^redis_socketio:/# redis_socketio:/g' Procfile; fi if [ "$TYPE" == "ui" ]; then bench setup requirements --node; fi -if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi +bench setup requirements --dev # install node-sass which is required for website theme test cd ./apps/frappe || exit From d79c8a0f2704c1797704b707cd7373216e0862f6 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 25 Oct 2021 16:54:51 +0530 Subject: [PATCH 02/23] test: Removing cypress ui test retry --- cypress.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cypress.json b/cypress.json index f2508ca66e..97ac41bb61 100644 --- a/cypress.json +++ b/cypress.json @@ -3,9 +3,5 @@ "projectId": "92odwv", "adminPassword": "admin", "defaultCommandTimeout": 20000, - "pageLoadTimeout": 15000, - "retries": { - "runMode": 2, - "openMode": 2 - } + "pageLoadTimeout": 15000 } From 748e5dab4472cfb2a0c80a0c0cc0dea93b9d07ad Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 25 Oct 2021 17:28:15 +0530 Subject: [PATCH 03/23] test: enable video for cypres ci --- cypress.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cypress.json b/cypress.json index 97ac41bb61..9a81ca5ede 100644 --- a/cypress.json +++ b/cypress.json @@ -3,5 +3,7 @@ "projectId": "92odwv", "adminPassword": "admin", "defaultCommandTimeout": 20000, - "pageLoadTimeout": 15000 + "pageLoadTimeout": 15000, + "video": true, + "videoUploadOnPasses": false } From 2dc74994e98b243d25e23c6387e3b04c8e39d342 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 2 Nov 2021 11:31:07 +0530 Subject: [PATCH 04/23] revert: "ci: install dev dependency without condition" This reverts commit b9ebe88c5ae12c540c9dd8fcac8605aaefe6ab1b. --- .github/helper/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/helper/install.sh b/.github/helper/install.sh index 8cc3d01a6c..454cc89694 100644 --- a/.github/helper/install.sh +++ b/.github/helper/install.sh @@ -50,7 +50,7 @@ if [ "$TYPE" == "server" ]; then sed -i 's/^socketio:/# socketio:/g' Procfile; f if [ "$TYPE" == "server" ]; then sed -i 's/^redis_socketio:/# redis_socketio:/g' Procfile; fi if [ "$TYPE" == "ui" ]; then bench setup requirements --node; fi -bench setup requirements --dev +if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi # install node-sass which is required for website theme test cd ./apps/frappe || exit From 7a6bee9dab1b7eb9c409b5495feab4b55b454627 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 2 Nov 2021 15:37:57 +0530 Subject: [PATCH 05/23] test: fixed failing test(timeline, recorder, navigation) --- cypress/integration/navigation.js | 4 +-- cypress/integration/recorder.js | 26 +++++++-------- cypress/integration/timeline.js | 55 +++++++++++++++---------------- cypress/support/commands.js | 10 +++++- 4 files changed, 50 insertions(+), 45 deletions(-) diff --git a/cypress/integration/navigation.js b/cypress/integration/navigation.js index c4d0638f26..fdb3284b44 100644 --- a/cypress/integration/navigation.js +++ b/cypress/integration/navigation.js @@ -13,10 +13,10 @@ context('Navigation', () => { it.only('Navigate to previous page after login', () => { cy.visit('/app/todo'); - cy.findByTitle('To Do').should('be.visible'); + cy.get('.page-head').findByTitle('To Do').should('be.visible'); cy.request('/api/method/logout'); cy.reload(); - cy.get('.btn-primary').contains('Login').click(); + cy.get('.page-card .btn-primary').contains('Login').click(); cy.location('pathname').should('eq', '/login'); cy.login(); cy.visit('/app'); diff --git a/cypress/integration/recorder.js b/cypress/integration/recorder.js index caf1349e6e..0add1d585c 100644 --- a/cypress/integration/recorder.js +++ b/cypress/integration/recorder.js @@ -14,48 +14,48 @@ context('Recorder', () => { }); it('Recorder Empty State', () => { - cy.findByTitle('Recorder').should('exist'); + cy.get('.page-head').findByTitle('Recorder').should('exist'); cy.get('.indicator-pill').should('contain', 'Inactive').should('have.class', 'red'); - cy.findByRole('button', {name: 'Start'}).should('exist'); - cy.findByRole('button', {name: 'Clear'}).should('exist'); + cy.get('.page-actions').findByRole('button', {name: 'Start'}).should('exist'); + cy.get('.page-actions').findByRole('button', {name: 'Clear'}).should('exist'); - cy.get('.msg-box').should('contain', 'Inactive'); - cy.findByRole('button', {name: 'Start Recording'}).should('exist'); + cy.get('.msg-box').should('contain', 'Recorder is Inactive'); + cy.get('.msg-box').findByRole('button', {name: 'Start Recording'}).should('exist'); }); it('Recorder Start', () => { - cy.findByRole('button', {name: 'Start'}).click(); + cy.get('.page-actions').findByRole('button', {name: 'Start'}).click(); cy.get('.indicator-pill').should('contain', 'Active').should('have.class', 'green'); - cy.get('.msg-box').should('contain', 'No Requests'); + cy.get('.msg-box').should('contain', 'No Requests found'); cy.visit('/app/List/DocType/List'); cy.intercept('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh'); cy.wait('@list_refresh'); - cy.get('.title-text').should('contain', 'DocType'); + cy.get('.page-head').findByTitle('DocType').should('exist'); cy.get('.list-count').should('contain', '20 of '); cy.visit('/app/recorder'); - cy.findByTitle('Recorder').should('exist'); - cy.get('.result-list').should('contain', '/api/method/frappe.desk.reportview.get'); + cy.get('.page-head').findByTitle('Recorder').should('exist'); + cy.get('.frappe-list .result-list').should('contain', '/api/method/frappe.desk.reportview.get'); }); it('Recorder View Request', () => { - cy.findByRole('button', {name: 'Start'}).click(); + cy.get('.page-actions').findByRole('button', {name: 'Start'}).click(); cy.visit('/app/List/DocType/List'); cy.intercept('POST', '/api/method/frappe.desk.reportview.get').as('list_refresh'); cy.wait('@list_refresh'); - cy.get('.title-text').should('contain', 'DocType'); + cy.get('.page-head').findByTitle('DocType').should('exist'); cy.get('.list-count').should('contain', '20 of '); cy.visit('/app/recorder'); - cy.get('.list-row-container span').contains('/api/method/frappe').click(); + cy.get('.frappe-list .list-row-container span').contains('/api/method/frappe').should('be.visible').click(); cy.url().should('include', '/recorder/request'); cy.get('form').should('contain', '/api/method/frappe'); diff --git a/cypress/integration/timeline.js b/cypress/integration/timeline.js index 191b5a2b2c..4322d01e4a 100644 --- a/cypress/integration/timeline.js +++ b/cypress/integration/timeline.js @@ -8,22 +8,18 @@ context('Timeline', () => { it('Adding new ToDo, adding new comment, verifying comment addition & deletion and deleting ToDo', () => { //Adding new ToDo + cy.visit('/app/todo/new-todo-1'); + cy.get('[data-fieldname="description"] .ql-editor.ql-blank').type('Test ToDo', {force: true}).wait(200); + cy.get('.page-head .page-actions').findByRole('button', {name: 'Save'}).click(); + cy.visit('/app/todo'); - cy.click_listview_primary_button('Add ToDo'); - cy.findByRole('button', {name: 'Edit in full page'}).click(); - cy.findByTitle('New ToDo').should('be.visible'); - cy.get('[data-fieldname="description"] .ql-editor').eq(0).type('Test ToDo', {force: true}); - cy.wait(200); - cy.findByRole('button', {name: 'Save'}).click(); - cy.wait(700); - cy.visit('/app/todo'); - cy.get('.level-item.ellipsis').eq(0).click(); + cy.click_first_row_in_list(); //To check if the comment box is initially empty and tying some text into it cy.get('[data-fieldname="comment"] .ql-editor').should('contain', '').type('Testing Timeline'); //Adding new comment - cy.findByRole('button', {name: 'Comment'}).click(); + cy.get('.comment-box').findByRole('button', {name: 'Comment'}).click(); //To check if the commented text is visible in the timeline content cy.get('.timeline-content').should('contain', 'Testing Timeline'); @@ -38,21 +34,21 @@ context('Timeline', () => { //Discarding comment cy.click_timeline_action_btn("Edit"); - cy.findByRole('button', {name: 'Dismiss'}).click(); + cy.click_timeline_action_btn("Dismiss"); //To check if after discarding the timeline content is same as previous cy.get('.timeline-content').should('contain', 'Testing Timeline 123'); //Deleting the added comment - cy.get('.more-actions > .action-btn').click(); - cy.get('.more-actions .dropdown-item').contains('Delete').click(); - cy.findByRole('button', {name: 'Yes'}).click(); + cy.get('.timeline-message-box .more-actions > .action-btn').click(); //Menu button in timeline item + cy.get('.timeline-message-box .more-actions .dropdown-item').contains('Delete').click(); + cy.get_open_dialog().findByRole('button', {name: 'Yes'}).click(); cy.click_modal_primary_button('Yes'); //Deleting the added ToDo - cy.get('[id="page-ToDo"] .menu-btn-group [data-original-title="Menu"]').click(); - cy.get('[id="page-ToDo"] .menu-btn-group .dropdown-item').contains('Delete').click(); - cy.findByRole('button', {name: 'Yes'}).click(); + cy.get('[id="page-ToDo"] .page-actions .menu-btn-group [data-original-title="Menu"]').click(); + cy.get('[id="page-ToDo"] .page-actions .menu-btn-group .dropdown-item').contains('Delete').click(); + cy.get_open_dialog().findByRole('button', {name: 'Yes'}).click(); }); it('Timeline should have submit and cancel activity information', () => { @@ -66,31 +62,32 @@ context('Timeline', () => { //Adding a new entry for the created custom doctype cy.fill_field('title', 'Test'); - cy.findByRole('button', {name: 'Save'}).click(); - cy.findByRole('button', {name: 'Submit'}).click(); + cy.click_modal_primary_button('Save'); + cy.click_modal_primary_button('Submit'); + cy.visit('/app/custom-submittable-doctype'); - cy.get('.list-subject > .bold > .ellipsis').eq(0).click(); + cy.click_first_row_in_list(); //To check if the submission of the documemt is visible in the timeline content cy.get('.timeline-content').should('contain', 'Administrator submitted this document'); - cy.findByRole('button', {name: 'Cancel'}).click({delay: 900}); - cy.findByRole('button', {name: 'Yes'}).click(); + cy.get('[id="page-Custom Submittable DocType"] .page-actions').findByRole('button', {name: 'Cancel'}).click(); + cy.get_open_dialog().findByRole('button', {name: 'Yes'}).click(); //To check if the cancellation of the documemt is visible in the timeline content cy.get('.timeline-content').should('contain', 'Administrator cancelled this document'); //Deleting the document cy.visit('/app/custom-submittable-doctype'); - cy.get('.list-subject > .select-like > .list-row-checkbox').eq(0).click(); - cy.findByRole('button', {name: 'Actions'}).click(); - cy.get('.actions-btn-group > .dropdown-menu > li > .dropdown-item').contains("Delete").click(); - cy.click_modal_primary_button('Yes', {force: true, delay: 700}); + cy.select_first_row_checkbox(); + cy.get('.page-actions').findByRole('button', {name: 'Actions'}).click(); + cy.get('.page-actions .actions-btn-group [data-label="Delete"]').click(); + cy.click_modal_primary_button('Yes'); //Deleting the custom doctype cy.visit('/app/doctype'); - cy.get('.list-subject > .select-like > .list-row-checkbox').eq(0).click(); - cy.findByRole('button', {name: 'Actions'}).click(); - cy.get('.actions-btn-group [data-label="Delete"]').click(); + cy.select_first_row_checkbox(); + cy.get('.page-actions').findByRole('button', {name: 'Actions'}).click(); + cy.get('.page-actions .actions-btn-group [data-label="Delete"]').click(); cy.click_modal_primary_button('Yes'); }); }); \ No newline at end of file diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 64a3b18b2f..548887a0f4 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -353,5 +353,13 @@ Cypress.Commands.add('click_listview_primary_button', (btn_name) => { }); Cypress.Commands.add('click_timeline_action_btn', (btn_name) => { - cy.get('.timeline-message-box .custom-actions > .btn').contains(btn_name).click(); + cy.get('.timeline-message-box .actions .action-btn').contains(btn_name).click(); +}); + +Cypress.Commands.add('click_first_row_in_list', () => { + cy.get('.frappe-list .list-row-container .level-item.ellipsis').first().click(); +}); + +Cypress.Commands.add('select_first_row_checkbox', () => { + cy.get('.frappe-list .select-like > .list-row-checkbox').first().click(); }); From 06d8d8535f71323d05705a543fa155b440953bb2 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 2 Nov 2021 18:20:36 +0530 Subject: [PATCH 06/23] test: Fixed form.js --- cypress/integration/form.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/cypress/integration/form.js b/cypress/integration/form.js index f860a742ef..d2c7bdc7a9 100644 --- a/cypress/integration/form.js +++ b/cypress/integration/form.js @@ -8,11 +8,7 @@ context('Form', () => { }); it('create a new form', () => { cy.visit('/app/todo/new'); - cy.get('[data-fieldname="description"] .ql-editor') - .first() - .click() - .type('this is a test todo'); - cy.wait(300); + cy.get_field('description', 'Text Editor').type('this is a test todo').wait(200); cy.get('.page-title').should('contain', 'Not Saved'); cy.intercept({ method: 'POST', @@ -20,29 +16,35 @@ context('Form', () => { }).as('form_save'); cy.get('.primary-action').click(); cy.wait('@form_save').its('response.statusCode').should('eq', 200); + cy.visit('/app/todo'); - cy.wait(300); - cy.get('.title-text').should('be.visible').and('contain', 'To Do'); + cy.get('.page-head').findByTitle('To Do').should('exist'); cy.get('.list-row').should('contain', 'this is a test todo'); }); + it('navigates between documents with child table list filters applied', () => { cy.visit('/app/contact'); cy.add_filter(); - cy.get('.filter-field .input-with-feedback.form-control').type('123', { force: true }); - cy.findByRole('button', {name: 'Apply Filters'}).click({ force: true }); + cy.get('.filter-field input[data-fieldname="name"]').type('123', { force: true }); + cy.get('.filter-action-buttons').findByRole('button', {name: 'Apply Filters'}).click({ force: true }); + cy.visit('/app/contact/Test Form Contact 3'); + cy.get('.prev-doc').should('be.visible').click(); cy.get('.msgprint-dialog .modal-body').contains('No further records').should('be.visible'); cy.hide_dialog(); - cy.get('.next-doc').click(); - cy.wait(200); + + cy.get('.next-doc').should('be.visible').click(); + cy.get('.msgprint-dialog .modal-body').contains('No further records').should('be.visible'); cy.hide_dialog(); - cy.contains('Test Form Contact 2').should('not.exist'); - cy.get('.title-text').should('contain', 'Test Form Contact 3'); + + cy.get('.page-head').findByTitle('Test Form Contact 3').should('exist'); + // clear filters cy.visit('/app/contact'); cy.clear_filters(); }); + it('validates behaviour of Data options validations in child table', () => { // test email validations for set_invalid controller let website_input = 'website.in'; From d7b06299af33c1ad09c8007828907e263f4ae98d Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 2 Nov 2021 18:43:58 +0530 Subject: [PATCH 07/23] test: Minor fix --- cypress/integration/form.js | 2 +- cypress/integration/recorder.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cypress/integration/form.js b/cypress/integration/form.js index d2c7bdc7a9..88262cdb9b 100644 --- a/cypress/integration/form.js +++ b/cypress/integration/form.js @@ -25,7 +25,7 @@ context('Form', () => { it('navigates between documents with child table list filters applied', () => { cy.visit('/app/contact'); cy.add_filter(); - cy.get('.filter-field input[data-fieldname="name"]').type('123', { force: true }); + cy.get('.filter-field .input-with-feedback').type('123', { force: true }); cy.get('.filter-action-buttons').findByRole('button', {name: 'Apply Filters'}).click({ force: true }); cy.visit('/app/contact/Test Form Contact 3'); diff --git a/cypress/integration/recorder.js b/cypress/integration/recorder.js index 0add1d585c..7d4c83abf5 100644 --- a/cypress/integration/recorder.js +++ b/cypress/integration/recorder.js @@ -55,7 +55,10 @@ context('Recorder', () => { cy.visit('/app/recorder'); - cy.get('.frappe-list .list-row-container span').contains('/api/method/frappe').should('be.visible').click(); + cy.get('.frappe-list .list-row-container span') + .contains('/api/method/frappe') + .should('be.visible') + .click({force: true}); cy.url().should('include', '/recorder/request'); cy.get('form').should('contain', '/api/method/frappe'); From cf416aa779338cd569e61c7ddf3b22d18c6563ef Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 8 Nov 2021 11:00:45 +0530 Subject: [PATCH 08/23] test: minor fix --- cypress/integration/timeline.js | 8 ++++---- cypress/support/commands.js | 10 +++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cypress/integration/timeline.js b/cypress/integration/timeline.js index 4322d01e4a..d39c413703 100644 --- a/cypress/integration/timeline.js +++ b/cypress/integration/timeline.js @@ -13,7 +13,7 @@ context('Timeline', () => { cy.get('.page-head .page-actions').findByRole('button', {name: 'Save'}).click(); cy.visit('/app/todo'); - cy.click_first_row_in_list(); + cy.click_listview_row_item(0); //To check if the comment box is initially empty and tying some text into it cy.get('[data-fieldname="comment"] .ql-editor').should('contain', '').type('Testing Timeline'); @@ -66,7 +66,7 @@ context('Timeline', () => { cy.click_modal_primary_button('Submit'); cy.visit('/app/custom-submittable-doctype'); - cy.click_first_row_in_list(); + cy.click_listview_row_item(0); //To check if the submission of the documemt is visible in the timeline content cy.get('.timeline-content').should('contain', 'Administrator submitted this document'); @@ -78,14 +78,14 @@ context('Timeline', () => { //Deleting the document cy.visit('/app/custom-submittable-doctype'); - cy.select_first_row_checkbox(); + cy.select_listview_row_checkbox(0); cy.get('.page-actions').findByRole('button', {name: 'Actions'}).click(); cy.get('.page-actions .actions-btn-group [data-label="Delete"]').click(); cy.click_modal_primary_button('Yes'); //Deleting the custom doctype cy.visit('/app/doctype'); - cy.select_first_row_checkbox(); + cy.select_listview_row_checkbox(0); cy.get('.page-actions').findByRole('button', {name: 'Actions'}).click(); cy.get('.page-actions .actions-btn-group [data-label="Delete"]').click(); cy.click_modal_primary_button('Yes'); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 548887a0f4..933f6a1758 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -341,7 +341,7 @@ Cypress.Commands.add('click_sidebar_button', (btn_name) => { }); Cypress.Commands.add('click_listview_row_item', (row_no) => { - cy.get('.list-row > .level-left > .list-subject > .bold > .ellipsis').eq(row_no).click({force: true}); + cy.get('.list-row > .level-left > .list-subject > .level-item > .ellipsis').eq(row_no).click({force: true}); }); Cypress.Commands.add('click_filter_button', () => { @@ -356,10 +356,6 @@ Cypress.Commands.add('click_timeline_action_btn', (btn_name) => { cy.get('.timeline-message-box .actions .action-btn').contains(btn_name).click(); }); -Cypress.Commands.add('click_first_row_in_list', () => { - cy.get('.frappe-list .list-row-container .level-item.ellipsis').first().click(); -}); - -Cypress.Commands.add('select_first_row_checkbox', () => { - cy.get('.frappe-list .select-like > .list-row-checkbox').first().click(); +Cypress.Commands.add('select_listview_row_checkbox', (row_no) => { + cy.get('.frappe-list .select-like > .list-row-checkbox').eq(row_no).click(); }); From 754caca3cac4b0a511644e9b8b17c4d4b651eb3c Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 8 Nov 2021 11:48:51 +0530 Subject: [PATCH 09/23] test: Updated query_report UI test --- cypress/integration/query_report.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cypress/integration/query_report.js b/cypress/integration/query_report.js index 9bd542977d..43f26f8b50 100644 --- a/cypress/integration/query_report.js +++ b/cypress/integration/query_report.js @@ -8,6 +8,10 @@ context('Query Report', () => { 'report_type': 'Query Report', 'query': 'select * from tabToDo' }, true).as('doc'); + cy.create_records({ + doctype: 'ToDo', + description: 'this is a test todo for query report' + }).as('todos'); }); it('add custom column in report', () => { From 417ef53dfa0c14a1d849c0c59e7f43d7a9972355 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 8 Nov 2021 13:04:56 +0530 Subject: [PATCH 10/23] test: Updated form.js --- cypress/integration/form.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cypress/integration/form.js b/cypress/integration/form.js index 88262cdb9b..1f4a5136c3 100644 --- a/cypress/integration/form.js +++ b/cypress/integration/form.js @@ -24,11 +24,10 @@ context('Form', () => { it('navigates between documents with child table list filters applied', () => { cy.visit('/app/contact'); - cy.add_filter(); - cy.get('.filter-field .input-with-feedback').type('123', { force: true }); - cy.get('.filter-action-buttons').findByRole('button', {name: 'Apply Filters'}).click({ force: true }); - cy.visit('/app/contact/Test Form Contact 3'); + cy.clear_filters(); + cy.get('.standard-filter-section [data-fieldname="name"] input').type('Test Form Contact 3').blur(); + cy.click_listview_row_item(0); cy.get('.prev-doc').should('be.visible').click(); cy.get('.msgprint-dialog .modal-body').contains('No further records').should('be.visible'); @@ -38,7 +37,7 @@ context('Form', () => { cy.get('.msgprint-dialog .modal-body').contains('No further records').should('be.visible'); cy.hide_dialog(); - cy.get('.page-head').findByTitle('Test Form Contact 3').should('exist'); + cy.get('#page-Contact .page-head').findByTitle('Test Form Contact 3').should('exist'); // clear filters cy.visit('/app/contact'); From 25ffd6ddec1f79b042aeb60e5d273b94b414081d Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 8 Nov 2021 18:52:52 +0530 Subject: [PATCH 11/23] test: Updated report_view.js --- cypress/integration/report_view.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cypress/integration/report_view.js b/cypress/integration/report_view.js index e762eebea1..b999461433 100644 --- a/cypress/integration/report_view.js +++ b/cypress/integration/report_view.js @@ -23,8 +23,7 @@ context('Report View', () => { let cell = cy.get('.dt-row-0 > .dt-cell--col-4'); // select the cell cell.dblclick(); - cell.findByRole('checkbox').check({ force: true }); - cy.get('.dt-row-0 > .dt-cell--col-5').click(); + cell.findByRole('checkbox').check({ force: true }).blur(); cy.wait('@value-update'); cy.get('@doc').then(doc => { cy.call('frappe.client.get_value', { From 1b00f56e698a8c3edfa9e7c387a3d29d03bbf983 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 8 Nov 2021 19:26:21 +0530 Subject: [PATCH 12/23] test: Updated navigation.js --- cypress/integration/navigation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/integration/navigation.js b/cypress/integration/navigation.js index fdb3284b44..b4e023c53e 100644 --- a/cypress/integration/navigation.js +++ b/cypress/integration/navigation.js @@ -15,8 +15,8 @@ context('Navigation', () => { cy.visit('/app/todo'); cy.get('.page-head').findByTitle('To Do').should('be.visible'); cy.request('/api/method/logout'); - cy.reload(); - cy.get('.page-card .btn-primary').contains('Login').click(); + cy.reload().as('reload'); + cy.get('@reload').get('.page-card .btn-primary').contains('Login').click(); cy.location('pathname').should('eq', '/login'); cy.login(); cy.visit('/app'); From c6483467425c28973717a159103ac4bf1412caa4 Mon Sep 17 00:00:00 2001 From: Pruthvi Patel Date: Tue, 9 Nov 2021 12:54:17 +0530 Subject: [PATCH 13/23] refactor: a better way to cleanup older assets when newer ones are built --- esbuild/build-cleanup.js | 38 ++++++++++++++++++++++++++++++++++++++ esbuild/esbuild.js | 27 +++++---------------------- 2 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 esbuild/build-cleanup.js diff --git a/esbuild/build-cleanup.js b/esbuild/build-cleanup.js new file mode 100644 index 0000000000..cf03606a34 --- /dev/null +++ b/esbuild/build-cleanup.js @@ -0,0 +1,38 @@ +/* eslint-disable no-console */ +const path = require("path"); +const fs = require("fs"); +const glob = require("fast-glob"); + +module.exports = { + name: 'build_cleanup', + setup(build) { + build.onEnd(result => { + if (result.errors.length) return; + clean_dist_files(Object.keys(result.metafile.outputs)); + }); + }, +}; + +function clean_dist_files(new_files) { + new_files.forEach( + file => { + if (file.endsWith(".map")) return; + + const pattern = file.split(".").slice(0, -2).join(".") + "*"; + glob.sync(pattern).forEach( + file_to_delete => { + if (file_to_delete.startsWith(file)) return; + + fs.unlink(path.resolve(file_to_delete), err => { + if (!err) return; + + console.error( + `Error deleting ${file.split(path.sep).pop()}` + ); + }); + } + + ); + } + ); +} \ No newline at end of file diff --git a/esbuild/esbuild.js b/esbuild/esbuild.js index 18de95b40d..e10e3b7804 100644 --- a/esbuild/esbuild.js +++ b/esbuild/esbuild.js @@ -12,6 +12,8 @@ let rtlcss = require('rtlcss'); let postCssPlugin = require("esbuild-plugin-postcss2").default; let ignore_assets = require("./ignore-assets"); let sass_options = require("./sass_options"); +let build_cleanup_plugin = require("./build-cleanup"); + let { app_list, assets_path, @@ -98,9 +100,6 @@ if (WATCH_MODE) { async function execute() { console.time(TOTAL_BUILD_TIME); - if (!FILES_TO_BUILD.length) { - await clean_dist_folders(APPS); - } let results; try { @@ -231,12 +230,13 @@ function get_files_to_build(files) { function build_files({ files, outdir }) { let build_plugins = [ html_plugin, + build_cleanup_plugin, vue(), ]; return esbuild.build(get_build_options(files, outdir, build_plugins)); } -function build_style_files({ files, outdir, rtl_style=false }) { +function build_style_files({ files, outdir, rtl_style = false }) { let plugins = []; if (rtl_style) { plugins.push(rtlcss); @@ -244,6 +244,7 @@ function build_style_files({ files, outdir, rtl_style=false }) { let build_plugins = [ ignore_assets, + build_cleanup_plugin, postCssPlugin({ plugins: plugins, sassOptions: sass_options @@ -313,24 +314,6 @@ function get_watch_config() { return null; } -async function clean_dist_folders(apps) { - for (let app of apps) { - let public_path = get_public_path(app); - let paths = [ - path.resolve(public_path, "dist", "js"), - path.resolve(public_path, "dist", "css"), - path.resolve(public_path, "dist", "css-rtl") - ]; - for (let target of paths) { - if (fs.existsSync(target)) { - // rmdir is deprecated in node 16, this will work in both node 14 and 16 - let rmdir = fs.promises.rm || fs.promises.rmdir; - await rmdir(target, { recursive: true }); - } - } - } -} - function log_built_assets(results) { let outputs = {}; for (const result of results) { From 30452c8b9cddce7d115a2452f950950f9ae98f73 Mon Sep 17 00:00:00 2001 From: Pruthvi Patel Date: Tue, 9 Nov 2021 13:00:15 +0530 Subject: [PATCH 14/23] style: use `const` instead of `let` --- esbuild/esbuild.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/esbuild/esbuild.js b/esbuild/esbuild.js index e10e3b7804..792cb56198 100644 --- a/esbuild/esbuild.js +++ b/esbuild/esbuild.js @@ -1,20 +1,20 @@ /* eslint-disable no-console */ -let path = require("path"); -let fs = require("fs"); -let glob = require("fast-glob"); -let esbuild = require("esbuild"); -let vue = require("esbuild-vue"); -let yargs = require("yargs"); -let cliui = require("cliui")(); -let chalk = require("chalk"); -let html_plugin = require("./frappe-html"); -let rtlcss = require('rtlcss'); -let postCssPlugin = require("esbuild-plugin-postcss2").default; -let ignore_assets = require("./ignore-assets"); -let sass_options = require("./sass_options"); -let build_cleanup_plugin = require("./build-cleanup"); +const path = require("path"); +const fs = require("fs"); +const glob = require("fast-glob"); +const esbuild = require("esbuild"); +const vue = require("esbuild-vue"); +const yargs = require("yargs"); +const cliui = require("cliui")(); +const chalk = require("chalk"); +const html_plugin = require("./frappe-html"); +const rtlcss = require('rtlcss'); +const postCssPlugin = require("esbuild-plugin-postcss2").default; +const ignore_assets = require("./ignore-assets"); +const sass_options = require("./sass_options"); +const build_cleanup_plugin = require("./build-cleanup"); -let { +const { app_list, assets_path, apps_path, @@ -28,7 +28,7 @@ let { get_redis_subscriber } = require("./utils"); -let argv = yargs +const argv = yargs .usage("Usage: node esbuild [options]") .option("apps", { type: "string", From cbbf09e1cc883d1539b37fd10f643775c56cef74 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 9 Nov 2021 15:36:56 +0530 Subject: [PATCH 15/23] revert: 'test: Removing cypress ui test retry' --- cypress.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cypress.json b/cypress.json index 9a81ca5ede..ae4495cfa8 100644 --- a/cypress.json +++ b/cypress.json @@ -5,5 +5,9 @@ "defaultCommandTimeout": 20000, "pageLoadTimeout": 15000, "video": true, - "videoUploadOnPasses": false + "videoUploadOnPasses": false, + "retries": { + "runMode": 2, + "openMode": 2 + } } From 990b9f0ec3a17efa749955f7b8d8cf8622a57538 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 10 Nov 2021 11:45:53 +0530 Subject: [PATCH 16/23] test: Changing cypress browser to chrome --- frappe/commands/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index 416f014164..e311b8db6a 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -723,7 +723,7 @@ def run_ui_tests(context, app, headless=False, parallel=True, with_coverage=Fals frappe.commands.popen("yarn add cypress@^6 cypress-file-upload@^5 @testing-library/cypress@^8 @cypress/code-coverage@^3 --no-lockfile") # run for headless mode - run_or_open = 'run --browser firefox --record' if headless else 'open' + run_or_open = 'run --browser chrome --record' if headless else 'open' formatted_command = f'{site_env} {password_env} {coverage_env} {cypress_path} {run_or_open}' if parallel: From 990797080aeb76c062272da91df11558ed0f0dde Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 10 Nov 2021 12:42:34 +0530 Subject: [PATCH 17/23] test: minor fixes --- cypress/integration/list_view.js | 2 +- cypress/integration/report_view.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/integration/list_view.js b/cypress/integration/list_view.js index ce9e87274b..7b5ac3d27b 100644 --- a/cypress/integration/list_view.js +++ b/cypress/integration/list_view.js @@ -14,7 +14,7 @@ context('List View', () => { cy.get('.dropdown-menu li:visible .dropdown-item .menu-item-label[data-label="Edit"]').click(); cy.get('.modal-body .form-control[data-fieldname="field"]').first().select('Due Date').wait(200); - cy.fill_field('value', '09-28-21', 'Date'); + cy.get('.modal-body').fill_field('value', '09-28-21', 'Date'); cy.get('.modal-footer .standard-actions .btn-primary').click(); cy.wait(500); diff --git a/cypress/integration/report_view.js b/cypress/integration/report_view.js index b999461433..01ea4c73b2 100644 --- a/cypress/integration/report_view.js +++ b/cypress/integration/report_view.js @@ -23,7 +23,7 @@ context('Report View', () => { let cell = cy.get('.dt-row-0 > .dt-cell--col-4'); // select the cell cell.dblclick(); - cell.findByRole('checkbox').check({ force: true }).blur(); + cell.get('.dt-cell__content').findByRole('checkbox').check({ force: true }).blur(); cy.wait('@value-update'); cy.get('@doc').then(doc => { cy.call('frappe.client.get_value', { From 8f1e7b9704665bbd3ff7c261b67f0429bf5921d7 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 10 Nov 2021 22:16:37 +0530 Subject: [PATCH 18/23] test: failing test fixes --- cypress/integration/list_view.js | 3 +-- cypress/integration/report_view.js | 2 +- cypress/integration/timeline.js | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cypress/integration/list_view.js b/cypress/integration/list_view.js index 7b5ac3d27b..7791bef8f5 100644 --- a/cypress/integration/list_view.js +++ b/cypress/integration/list_view.js @@ -13,8 +13,7 @@ context('List View', () => { cy.get('.actions-btn-group button').contains('Actions').should('be.visible').click(); cy.get('.dropdown-menu li:visible .dropdown-item .menu-item-label[data-label="Edit"]').click(); - cy.get('.modal-body .form-control[data-fieldname="field"]').first().select('Due Date').wait(200); - cy.get('.modal-body').fill_field('value', '09-28-21', 'Date'); + cy.get('.modal-body .form-control[data-fieldname="field"]').first().select('Priority').wait(200); cy.get('.modal-footer .standard-actions .btn-primary').click(); cy.wait(500); diff --git a/cypress/integration/report_view.js b/cypress/integration/report_view.js index 01ea4c73b2..b999461433 100644 --- a/cypress/integration/report_view.js +++ b/cypress/integration/report_view.js @@ -23,7 +23,7 @@ context('Report View', () => { let cell = cy.get('.dt-row-0 > .dt-cell--col-4'); // select the cell cell.dblclick(); - cell.get('.dt-cell__content').findByRole('checkbox').check({ force: true }).blur(); + cell.findByRole('checkbox').check({ force: true }).blur(); cy.wait('@value-update'); cy.get('@doc').then(doc => { cy.call('frappe.client.get_value', { diff --git a/cypress/integration/timeline.js b/cypress/integration/timeline.js index d39c413703..a621a451e2 100644 --- a/cypress/integration/timeline.js +++ b/cypress/integration/timeline.js @@ -43,10 +43,10 @@ context('Timeline', () => { cy.get('.timeline-message-box .more-actions > .action-btn').click(); //Menu button in timeline item cy.get('.timeline-message-box .more-actions .dropdown-item').contains('Delete').click(); cy.get_open_dialog().findByRole('button', {name: 'Yes'}).click(); - cy.click_modal_primary_button('Yes'); + cy.click_modal_primary_button('Yes').blur(); //Deleting the added ToDo - cy.get('[id="page-ToDo"] .page-actions .menu-btn-group [data-original-title="Menu"]').click(); + cy.get('[id="page-ToDo"] .page-actions .menu-btn-group [data-original-title="Menu"]').click({ force: true }); cy.get('[id="page-ToDo"] .page-actions .menu-btn-group .dropdown-item').contains('Delete').click(); cy.get_open_dialog().findByRole('button', {name: 'Yes'}).click(); }); From 15daadf5a623aa248b8252580b4afac776e4a7ec Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Thu, 11 Nov 2021 11:20:50 +0530 Subject: [PATCH 19/23] test: failing test fixes --- cypress/integration/form.js | 2 +- cypress/integration/report_view.js | 2 +- cypress/integration/timeline.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress/integration/form.js b/cypress/integration/form.js index 1f4a5136c3..71cc6f4f0d 100644 --- a/cypress/integration/form.js +++ b/cypress/integration/form.js @@ -8,7 +8,7 @@ context('Form', () => { }); it('create a new form', () => { cy.visit('/app/todo/new'); - cy.get_field('description', 'Text Editor').type('this is a test todo').wait(200); + cy.get_field('description', 'Text Editor').type('this is a test todo', {force: true}).wait(200); cy.get('.page-title').should('contain', 'Not Saved'); cy.intercept({ method: 'POST', diff --git a/cypress/integration/report_view.js b/cypress/integration/report_view.js index b999461433..a6b49c2b53 100644 --- a/cypress/integration/report_view.js +++ b/cypress/integration/report_view.js @@ -23,7 +23,7 @@ context('Report View', () => { let cell = cy.get('.dt-row-0 > .dt-cell--col-4'); // select the cell cell.dblclick(); - cell.findByRole('checkbox').check({ force: true }).blur(); + cell.findByRole('checkbox').check({ force: true }) cy.wait('@value-update'); cy.get('@doc').then(doc => { cy.call('frappe.client.get_value', { diff --git a/cypress/integration/timeline.js b/cypress/integration/timeline.js index a621a451e2..5cb5b6ee18 100644 --- a/cypress/integration/timeline.js +++ b/cypress/integration/timeline.js @@ -47,8 +47,8 @@ context('Timeline', () => { //Deleting the added ToDo cy.get('[id="page-ToDo"] .page-actions .menu-btn-group [data-original-title="Menu"]').click({ force: true }); - cy.get('[id="page-ToDo"] .page-actions .menu-btn-group .dropdown-item').contains('Delete').click(); - cy.get_open_dialog().findByRole('button', {name: 'Yes'}).click(); + cy.get('[id="page-ToDo"] .page-actions .menu-btn-group .dropdown-item').contains('Delete').click({ force: true }); + cy.get_open_dialog().findByRole('button', {name: 'Yes'}).click({ force: true }); }); it('Timeline should have submit and cancel activity information', () => { From b70251baba7d3e6d76b6d781de8af7266b8869ad Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Thu, 11 Nov 2021 12:25:03 +0530 Subject: [PATCH 20/23] ci: user hotfix branches for patch test --- .github/workflows/patch-mariadb-tests.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/patch-mariadb-tests.yml b/.github/workflows/patch-mariadb-tests.yml index 8758c4e273..d9a6ca6f59 100644 --- a/.github/workflows/patch-mariadb-tests.yml +++ b/.github/workflows/patch-mariadb-tests.yml @@ -106,16 +106,14 @@ jobs: source env/bin/activate cd apps/frappe/ git remote set-url upstream https://github.com/frappe/frappe.git - git fetch --all --tags - taglist=$(git tag --sort version:refname | grep -v "beta") - last_release=$(echo "$taglist" | tail -1 | cut -d . -f 1 | cut -c 2-) - - for version in $(seq 12 "$last_release") + for version in $(seq 12 13) do - last_tag=$(echo "$taglist" | grep "v$version" | tail -1) - echo "Updating to $last_tag" - git checkout -q -f "$last_tag" + echo "Updating to v$version" + branch_name="version-$version-hotfix" + git fetch --depth 1 upstream $branch_name:$branch_name + + git checkout -q -f $branch_name pip install -q -r requirements.txt bench --site test_site migrate done From 520336e6eee311a0a53ca93abdcd26541686f376 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Thu, 11 Nov 2021 12:40:06 +0530 Subject: [PATCH 21/23] test: Updated control_duration.js --- cypress/integration/control_duration.js | 3 ++- cypress/integration/report_view.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cypress/integration/control_duration.js b/cypress/integration/control_duration.js index 266d421e70..09629a344f 100644 --- a/cypress/integration/control_duration.js +++ b/cypress/integration/control_duration.js @@ -33,12 +33,13 @@ context('Control Duration', () => { cy.get('@dialog').then(dialog => { let value = dialog.get_value('duration'); expect(value).to.equal(3889800); + cy.hide_dialog(); }); }); it('should hide days or seconds according to duration options', () => { get_dialog_with_duration(1, 1).as('dialog'); - cy.get('.frappe-control[data-fieldname=duration] input').first().click(); + cy.get('.frappe-control[data-fieldname=duration] input').first(); cy.get('.duration-input[data-duration=days]').should('not.be.visible'); cy.get('.duration-input[data-duration=seconds]').should('not.be.visible'); }); diff --git a/cypress/integration/report_view.js b/cypress/integration/report_view.js index a6b49c2b53..deb1245ed8 100644 --- a/cypress/integration/report_view.js +++ b/cypress/integration/report_view.js @@ -23,7 +23,7 @@ context('Report View', () => { let cell = cy.get('.dt-row-0 > .dt-cell--col-4'); // select the cell cell.dblclick(); - cell.findByRole('checkbox').check({ force: true }) + cell.findByRole('checkbox').check({ force: true }); cy.wait('@value-update'); cy.get('@doc').then(doc => { cy.call('frappe.client.get_value', { From 67aab24bd004ba6e74a8d99c490eb9cbc6ff8d3e Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Thu, 11 Nov 2021 14:52:31 +0530 Subject: [PATCH 22/23] test: fixed failing tests --- cypress/integration/report_view.js | 2 +- cypress/integration/timeline.js | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cypress/integration/report_view.js b/cypress/integration/report_view.js index deb1245ed8..0253e8fd43 100644 --- a/cypress/integration/report_view.js +++ b/cypress/integration/report_view.js @@ -23,7 +23,7 @@ context('Report View', () => { let cell = cy.get('.dt-row-0 > .dt-cell--col-4'); // select the cell cell.dblclick(); - cell.findByRole('checkbox').check({ force: true }); + cell.get('.dt-cell__edit--col-4').findByRole('checkbox').check({ force: true }); cy.wait('@value-update'); cy.get('@doc').then(doc => { cy.call('frappe.client.get_value', { diff --git a/cypress/integration/timeline.js b/cypress/integration/timeline.js index 5cb5b6ee18..6c4733400d 100644 --- a/cypress/integration/timeline.js +++ b/cypress/integration/timeline.js @@ -41,14 +41,10 @@ context('Timeline', () => { //Deleting the added comment cy.get('.timeline-message-box .more-actions > .action-btn').click(); //Menu button in timeline item - cy.get('.timeline-message-box .more-actions .dropdown-item').contains('Delete').click(); - cy.get_open_dialog().findByRole('button', {name: 'Yes'}).click(); - cy.click_modal_primary_button('Yes').blur(); - - //Deleting the added ToDo - cy.get('[id="page-ToDo"] .page-actions .menu-btn-group [data-original-title="Menu"]').click({ force: true }); - cy.get('[id="page-ToDo"] .page-actions .menu-btn-group .dropdown-item').contains('Delete').click({ force: true }); + cy.get('.timeline-message-box .more-actions .dropdown-item').contains('Delete').click({ force: true }); cy.get_open_dialog().findByRole('button', {name: 'Yes'}).click({ force: true }); + + cy.get('.timeline-content').should('not.contain', 'Testing Timeline 123'); }); it('Timeline should have submit and cancel activity information', () => { From 9e8e80d41be772cdd30b5ebd9bbae5aae791accb Mon Sep 17 00:00:00 2001 From: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> Date: Fri, 12 Nov 2021 08:51:38 +0530 Subject: [PATCH 23/23] fix: Reload user doctype to avoid patch failure --- .../doctype/role/patches/v13_set_default_desk_properties.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frappe/core/doctype/role/patches/v13_set_default_desk_properties.py b/frappe/core/doctype/role/patches/v13_set_default_desk_properties.py index 375ea02e0e..dc17526047 100644 --- a/frappe/core/doctype/role/patches/v13_set_default_desk_properties.py +++ b/frappe/core/doctype/role/patches/v13_set_default_desk_properties.py @@ -2,9 +2,10 @@ import frappe from ..role import desk_properties def execute(): + frappe.reload_doctype('user') frappe.reload_doctype('role') for role in frappe.get_all('Role', ['name', 'desk_access']): role_doc = frappe.get_doc('Role', role.name) for key in desk_properties: role_doc.set(key, role_doc.desk_access) - role_doc.save() \ No newline at end of file + role_doc.save()