From 805633860f309a7fa7f2bb6df2b7da189e11a6fb Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 3 Aug 2017 22:22:03 +0530 Subject: [PATCH] [test] test_customize_form.js --- .../customize_form/test_customize_form.js | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/frappe/custom/doctype/customize_form/test_customize_form.js b/frappe/custom/doctype/customize_form/test_customize_form.js index 94f62ab1fb..d37afa5580 100644 --- a/frappe/custom/doctype/customize_form/test_customize_form.js +++ b/frappe/custom/doctype/customize_form/test_customize_form.js @@ -9,15 +9,24 @@ QUnit.test("test customize form", function(assert) { () => frappe.set_route('Form', 'Customize Form'), () => frappe.timeout(1), () => cur_frm.set_value('doc_type', 'ToDo'), - () => frappe.timeout(1), - () => frappe.click_button('Reset to defaults'), - () => frappe.click_button('Submit'), - () => frappe.timeout(1), - () => assert.equal(cur_frm.doc.fields[1].fieldname, 'status', - 'check if second field is "status"'), - + () => frappe.timeout(2), + () => { + // find the status column as there may be other custom fields like + // kanban etc. + frappe.row_idx = 0; + cur_frm.doc.fields.every((d, i) => { + if(d.fieldname==='status') { + frappe.row_idx = i; + return false; + } else { + return true; + } + }); + assert.equal(cur_frm.doc.fields[frappe.row_idx].fieldname, 'status', + 'check if selected field is "status"'); + }, // open "status" row - () => cur_frm.fields_dict.fields.grid.grid_rows[1].toggle_view(), + () => cur_frm.fields_dict.fields.grid.grid_rows[frappe.row_idx].toggle_view(), () => frappe.timeout(0.5), // try deleting it @@ -28,8 +37,8 @@ QUnit.test("test customize form", function(assert) { () => frappe.timeout(0.5), // status still exists - () => assert.equal(cur_frm.doc.fields[1].fieldname, 'status', - 'check if second field is still "status"'), + () => assert.equal(cur_frm.doc.fields[frappe.row_idx].fieldname, 'status', + 'check if selected field is still "status"'), () => done() ]); });