diff --git a/erpnext/manufacturing/doctype/bom/test_bom.js b/erpnext/manufacturing/doctype/bom/test_bom.js new file mode 100644 index 00000000000..8187ef36171 --- /dev/null +++ b/erpnext/manufacturing/doctype/bom/test_bom.js @@ -0,0 +1,62 @@ +QUnit.test("test: item", function (assert) { + assert.expect(1); + let done = assert.async(); + + frappe.run_serially([ + // test item creation + () => frappe.set_route("List", "Item"), + + // Create a BOM for a laptop + () => frappe.tests.make( + "BOM", [ + {item: "Laptop"}, + {quantity: 1}, + {with_operations: 1}, + {operations: [ + [ + {operation: "Assemble CPU"}, + {time_in_mins: 60}, + ], + [ + {operation: "Assemble Keyboard"}, + {time_in_mins: 30}, + ], + [ + {operation: "Assemble Screen"}, + {time_in_mins: 30}, + ] + ]}, + {scrap_items: [ + [ + {item_code: "Scrap item"} + ] + ]}, + {items: [ + [ + {item_code: "CPU"}, + {qty: 1} + ], + [ + {item_code: "Keyboard"}, + {qty: 1} + ], + [ + {item_code: "Screen"}, + {qty: 1} + ] + ]}, + ] + ), + () => cur_frm.savesubmit(), + () => frappe.timeout(1), + () => frappe.click_button('Yes'), + () => frappe.timeout(1), + + () => { + assert.ok(cur_frm.doc.operating_cost + cur_frm.doc.raw_material_cost - + cur_frm.doc.scrap_material_cost == cur_frm.doc.total_cost, 'Total_Cost calculated correctly'); + }, + + () => done() + ]); +}); \ No newline at end of file diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt index f7e495625f9..047ee9cb922 100644 --- a/erpnext/tests/ui/tests.txt +++ b/erpnext/tests/ui/tests.txt @@ -8,3 +8,4 @@ erpnext/manufacturing/doctype/workstation/test_workstation.js erpnext/manufacturing/doctype/operation/test_operation.js erpnext/hr/doctype/holiday_list/test_holiday_list.js erpnext/hr/doctype/branch/test_branch.js +erpnext/manufacturing/doctype/bom/test_bom.js \ No newline at end of file