From d89f9080d3a3c668dabd340e179379852a6ed968 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Tue, 16 Apr 2019 17:52:16 +0530 Subject: [PATCH 1/2] fix: Change fieldtype of assign_condition from "Small Text" to "Code" - Small text fields gets sanitized unless ignore_xss_filter is explicitly enabled. - Code fieldtype seems to be right fieldtype for such use case --- .../assignment_rule/assignment_rule.json | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/frappe/automation/doctype/assignment_rule/assignment_rule.json b/frappe/automation/doctype/assignment_rule/assignment_rule.json index 1996281acf..984ca9928a 100644 --- a/frappe/automation/doctype/assignment_rule/assignment_rule.json +++ b/frappe/automation/doctype/assignment_rule/assignment_rule.json @@ -22,6 +22,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "document_type", "fieldtype": "Link", "hidden": 0, @@ -56,6 +57,7 @@ "collapsible": 0, "columns": 0, "description": "Higher priority rule will be applied first", + "fetch_if_empty": 0, "fieldname": "priority", "fieldtype": "Int", "hidden": 0, @@ -88,6 +90,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "disabled", "fieldtype": "Check", "hidden": 0, @@ -120,6 +123,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break_4", "fieldtype": "Column Break", "hidden": 0, @@ -153,6 +157,7 @@ "columns": 0, "default": "Automatic Assignment", "description": "Example: {{ subject }}", + "fetch_if_empty": 0, "fieldname": "description", "fieldtype": "Small Text", "hidden": 0, @@ -185,6 +190,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "assignment_rules_section", "fieldtype": "Section Break", "hidden": 0, @@ -218,8 +224,9 @@ "collapsible": 0, "columns": 0, "description": "Simple Python Expression, Example: status == 'Open' and type == 'Bug'", + "fetch_if_empty": 0, "fieldname": "assign_condition", - "fieldtype": "Small Text", + "fieldtype": "Code", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -250,6 +257,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break_6", "fieldtype": "Column Break", "hidden": 0, @@ -282,8 +290,9 @@ "collapsible": 0, "columns": 0, "description": "Simple Python Expression, Example: Status in (\"Closed\", \"Cancelled\")", + "fetch_if_empty": 0, "fieldname": "unassign_condition", - "fieldtype": "Small Text", + "fieldtype": "Code", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -314,6 +323,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "assign_to_users_section", "fieldtype": "Section Break", "hidden": 0, @@ -346,6 +356,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "rule", "fieldtype": "Select", "hidden": 0, @@ -379,6 +390,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "users", "fieldtype": "Table MultiSelect", "hidden": 0, @@ -412,6 +424,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "last_user", "fieldtype": "Link", "hidden": 0, @@ -440,16 +453,14 @@ } ], "has_web_view": 0, - "hide_heading": 0, "hide_toolbar": 0, "idx": 0, - "image_view": 0, "in_create": 0, "is_submittable": 0, "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2019-03-08 15:13:01.379471", + "modified": "2019-04-16 17:46:04.890120", "modified_by": "Administrator", "module": "Automation", "name": "Assignment Rule", @@ -478,7 +489,6 @@ ], "quick_entry": 0, "read_only": 0, - "read_only_onload": 0, "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", From 3d21bba74d6c593a7a3881b192f2e950ec088456 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 20 Apr 2019 14:01:19 +0530 Subject: [PATCH 2/2] test: fix fill_field command for code fieldtype --- cypress/integration/table_multiselect.js | 2 +- cypress/support/commands.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cypress/integration/table_multiselect.js b/cypress/integration/table_multiselect.js index e53584640b..cca9a6eb46 100644 --- a/cypress/integration/table_multiselect.js +++ b/cypress/integration/table_multiselect.js @@ -9,7 +9,7 @@ context('Table MultiSelect', () => { cy.new_form('Assignment Rule'); cy.fill_field('__newname', name); cy.fill_field('document_type', 'ToDo'); - cy.fill_field('assign_condition', 'status=="Open"'); + cy.fill_field('assign_condition', 'status=="Open"', 'Code'); cy.get('input[data-fieldname="users"]').focus().as('input'); cy.get('input[data-fieldname="users"] + ul').should('be.visible'); cy.get('@input').type('test{enter}', { delay: 100 }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 010c0242f5..282481888e 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -41,13 +41,16 @@ Cypress.Commands.add('fill_field', (fieldname, value, fieldtype='Data') => { if (fieldtype === 'Text Editor') { selector = `[data-fieldname="${fieldname}"] .ql-editor`; } + if (fieldtype === 'Code') { + selector = `[data-fieldname="${fieldname}"] .ace_text-input`; + } cy.get(selector).as('input'); if (fieldtype === 'Select') { return cy.get('@input').select(value); } else { - return cy.get('@input').type(value); + return cy.get('@input').type(value, {waitForAnimations: false}); } });