From 5c3b448c09d0b19bb5f2256d6827ccf7656ca6c4 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 22 Apr 2022 16:59:03 +0530 Subject: [PATCH 1/5] refactor: used list comprehension --- frappe/tests/ui_test_helpers.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frappe/tests/ui_test_helpers.py b/frappe/tests/ui_test_helpers.py index 4cb3e95a6d..494ba8872d 100644 --- a/frappe/tests/ui_test_helpers.py +++ b/frappe/tests/ui_test_helpers.py @@ -137,12 +137,10 @@ def create_contact_records(): @frappe.whitelist() def create_multiple_todo_records(): - values = [] if frappe.db.get_all("ToDo", {"description": "Multiple ToDo 1"}): return - for index in range(1, 1002): - values.append(("100{}".format(index), "Multiple ToDo {}".format(index))) + values = [("100{}".format(i), "Multiple ToDo {}".format(i)) for i in range(1, 1002)] frappe.db.bulk_insert("ToDo", fields=["name", "description"], values=set(values)) From 7f83178556e6e81690b5d7d94345794035daa399 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 22 Apr 2022 16:59:22 +0530 Subject: [PATCH 2/5] test: flaky markdown editor fix --- cypress/integration/control_markdown_editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/control_markdown_editor.js b/cypress/integration/control_markdown_editor.js index b527d854d4..128add5397 100644 --- a/cypress/integration/control_markdown_editor.js +++ b/cypress/integration/control_markdown_editor.js @@ -16,7 +16,7 @@ context("Control Markdown Editor", () => { cy.click_modal_primary_button("Upload"); cy.get_field("main_section_md", "Markdown Editor").should( "contain", - "![](/files/sample_image.jpg)" + "![](/files/sample_image" ); }); }); From 8c953b4f74070ec534a42e957b8b075acd852a82 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 22 Apr 2022 16:59:42 +0530 Subject: [PATCH 3/5] test: removing drag drop test(flaky) --- cypress/integration/kanban.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cypress/integration/kanban.js b/cypress/integration/kanban.js index c7f3f08336..070af10b0d 100644 --- a/cypress/integration/kanban.js +++ b/cypress/integration/kanban.js @@ -72,14 +72,16 @@ context('Kanban Board', () => { }); - it('Drag todo', () => { - cy.intercept({ - method: 'POST', - url: 'api/method/frappe.desk.doctype.kanban_board.kanban_board.update_order_for_single_card' - }).as('drag-completed'); + // it('Drag todo', () => { + // cy.intercept({ + // method: 'POST', + // url: 'api/method/frappe.desk.doctype.kanban_board.kanban_board.update_order_for_single_card' + // }).as('drag-completed'); - cy.get('.kanban-card-body:first').drag('[data-column-value="Closed"] .kanban-cards', {force: true}); + // cy.get('.kanban-card-body') + // .contains('Test Kanban ToDo').first() + // .drag('[data-column-value="Closed"] .kanban-cards', { force: true }); - cy.wait('@drag-completed'); - }); + // cy.wait('@drag-completed'); + // }); }); \ No newline at end of file From 09a00770795e1296beedb253e7941db3a1fda167 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 22 Apr 2022 17:13:46 +0530 Subject: [PATCH 4/5] style: fixed indentation --- cypress/integration/kanban.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/kanban.js b/cypress/integration/kanban.js index 070af10b0d..50fc41afe3 100644 --- a/cypress/integration/kanban.js +++ b/cypress/integration/kanban.js @@ -82,6 +82,6 @@ context('Kanban Board', () => { // .contains('Test Kanban ToDo').first() // .drag('[data-column-value="Closed"] .kanban-cards', { force: true }); - // cy.wait('@drag-completed'); + // cy.wait('@drag-completed'); // }); }); \ No newline at end of file From d558f16e714f598502e2897bd873202a2d7ea0cd Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 22 Apr 2022 17:43:20 +0530 Subject: [PATCH 5/5] test: fixed flaky test for form, timeline_email --- cypress/integration/form.js | 2 +- cypress/integration/timeline_email.js | 4 ++-- cypress/support/commands.js | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cypress/integration/form.js b/cypress/integration/form.js index acaff9a191..99a4336bcb 100644 --- a/cypress/integration/form.js +++ b/cypress/integration/form.js @@ -27,7 +27,7 @@ context('Form', () => { 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.click_listview_row_item_with_text('Test Form Contact 3'); cy.get('#page-Contact .page-head').findByTitle('Test Form Contact 3').should('exist'); cy.get('.prev-doc').should('be.visible').click(); diff --git a/cypress/integration/timeline_email.js b/cypress/integration/timeline_email.js index 5808bd52ef..f2a239401d 100644 --- a/cypress/integration/timeline_email.js +++ b/cypress/integration/timeline_email.js @@ -16,7 +16,7 @@ context('Timeline Email', () => { it('Adding email and verifying timeline content for email attachment', () => { cy.visit('/app/todo'); - cy.get('.list-row > .level-left > .list-subject').eq(0).click(); + cy.click_listview_row_item_with_text('Test ToDo'); //Creating a new email cy.get('.timeline-actions > .timeline-item > .action-buttons > .action-btn').click(); @@ -47,7 +47,7 @@ context('Timeline Email', () => { it('Deleting attachment and ToDo', () => { cy.visit('/app/todo'); - cy.get('.list-row > .level-left > .list-subject > .level-item.ellipsis > .ellipsis').eq(0).click(); + cy.click_listview_row_item_with_text('Test ToDo'); //Removing the added attachment cy.get('.attachment-row > .data-pill > .remove-btn > .icon').click(); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 026c622e78..7e2f3116ae 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -352,6 +352,13 @@ Cypress.Commands.add('click_listview_row_item', (row_no) => { cy.get('.list-row > .level-left > .list-subject > .level-item > .ellipsis').eq(row_no).click({force: true}); }); +Cypress.Commands.add('click_listview_row_item_with_text', (text) => { + cy.get('.list-row > .level-left > .list-subject > .level-item > .ellipsis') + .contains(text) + .first() + .click({force: true}); +}); + Cypress.Commands.add('click_filter_button', () => { cy.get('.filter-selector > .btn').click(); });