From 73f969fd7ffc1f75145a68c1bfddca0a0205df56 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Fri, 21 Jul 2017 14:22:08 +0530 Subject: [PATCH] [ui-test] manufacturing item creation testing (#10009) --- erpnext/crm/doctype/item/test_item.js | 85 +++++++++++++++++++++++++++ erpnext/tests/ui/tests.txt | 3 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 erpnext/crm/doctype/item/test_item.js diff --git a/erpnext/crm/doctype/item/test_item.js b/erpnext/crm/doctype/item/test_item.js new file mode 100644 index 0000000000..a490b94b54 --- /dev/null +++ b/erpnext/crm/doctype/item/test_item.js @@ -0,0 +1,85 @@ +QUnit.test("test: item", function (assert) { + assert.expect(18); + let done = assert.async(); + frappe.run_serially([ + // test item creation + () => frappe.set_route("List", "Item"), + + // Create a keyboard item + () => frappe.tests.make( + "Item", [ + {item_code: "Keyboard"}, + {item_group: "Products"}, + {is_stock_item: 1}, + {standard_rate: 1000}, + {opening_stock: 100} + ] + ), + () => { + assert.ok(cur_frm.doc.item_name.includes('Keyboard'), + 'Item Keyboard created correctly'); + assert.ok(cur_frm.doc.item_code.includes('Keyboard'), + 'item_code for Keyboard set correctly'); + assert.ok(cur_frm.doc.item_group.includes('Products'), + 'item_group for Keyboard set correctly'); + assert.equal(cur_frm.doc.is_stock_item, 1, + 'is_stock_item for Keyboard set correctly'); + assert.equal(cur_frm.doc.standard_rate, 1000, + 'standard_rate for Keyboard set correctly'); + assert.equal(cur_frm.doc.opening_stock, 100, + 'opening_stock for Keyboard set correctly'); + }, + + // Create a Screen item + () => frappe.tests.make( + "Item", [ + {item_code: "Screen"}, + {item_group: "Products"}, + {is_stock_item: 1}, + {standard_rate: 1000}, + {opening_stock: 100} + ] + ), + () => { + assert.ok(cur_frm.doc.item_name.includes('Screen'), + 'Item Screen created correctly'); + assert.ok(cur_frm.doc.item_code.includes('Screen'), + 'item_code for Screen set correctly'); + assert.ok(cur_frm.doc.item_group.includes('Products'), + 'item_group for Screen set correctly'); + assert.equal(cur_frm.doc.is_stock_item, 1, + 'is_stock_item for Screen set correctly'); + assert.equal(cur_frm.doc.standard_rate, 1000, + 'standard_rate for Screen set correctly'); + assert.equal(cur_frm.doc.opening_stock, 100, + 'opening_stock for Screen set correctly'); + }, + + // Create a CPU item + () => frappe.tests.make( + "Item", [ + {item_code: "CPU"}, + {item_group: "Products"}, + {is_stock_item: 1}, + {standard_rate: 1000}, + {opening_stock: 100} + ] + ), + () => { + assert.ok(cur_frm.doc.item_name.includes('CPU'), + 'Item CPU created correctly'); + assert.ok(cur_frm.doc.item_code.includes('CPU'), + 'item_code for CPU set correctly'); + assert.ok(cur_frm.doc.item_group.includes('Products'), + 'item_group for CPU set correctly'); + assert.equal(cur_frm.doc.is_stock_item, 1, + 'is_stock_item for CPU set correctly'); + assert.equal(cur_frm.doc.standard_rate, 1000, + 'standard_rate for CPU set correctly'); + assert.equal(cur_frm.doc.opening_stock, 100, + 'opening_stock for CPU set correctly'); + }, + + () => done() + ]); +}); diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt index 42233dc800..98f83999c9 100644 --- a/erpnext/tests/ui/tests.txt +++ b/erpnext/tests/ui/tests.txt @@ -2,4 +2,5 @@ erpnext/tests/ui/make_fixtures.js #long erpnext/accounts/doctype/account/test_account.js erpnext/crm/doctype/lead/test_lead.js erpnext/crm/doctype/opportunity/test_opportunity.js -erpnext/selling/doctype/quotation/test_quotation.js \ No newline at end of file +erpnext/selling/doctype/quotation/test_quotation.js +erpnext/crm/doctype/item/test_item.js \ No newline at end of file