From 4e91f28ce529a6ba8384ec9daff96c7b117dcc2c Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Mon, 31 Jul 2017 11:02:28 +0530 Subject: [PATCH] [ui-testing] added test for production order (#10138) * temporary commit for switching branches * [ui-tests] added bill_of_materials test * added warehouses required for production order * [ui-test] added production order test * debugging travis failure --- erpnext/crm/doctype/item/test_item.js | 15 ++++--- erpnext/manufacturing/doctype/bom/test_bom.js | 1 + .../production_order/test_production_order.js | 41 +++++++++++++++++++ .../company/{ => tests}/test_company.js | 0 .../company/tests/test_company_production.js | 19 +++++++++ .../stock/doctype/warehouse/test_warehouse.js | 19 +++++++++ erpnext/tests/ui/tests.txt | 5 ++- 7 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 erpnext/manufacturing/doctype/production_order/test_production_order.js rename erpnext/setup/doctype/company/{ => tests}/test_company.js (100%) create mode 100644 erpnext/setup/doctype/company/tests/test_company_production.js create mode 100644 erpnext/stock/doctype/warehouse/test_warehouse.js diff --git a/erpnext/crm/doctype/item/test_item.js b/erpnext/crm/doctype/item/test_item.js index 704e762b1c..baaa21f90e 100644 --- a/erpnext/crm/doctype/item/test_item.js +++ b/erpnext/crm/doctype/item/test_item.js @@ -18,7 +18,8 @@ QUnit.test("test: item", function (assert) { {item_group: "Products"}, {is_stock_item: is_stock_item}, {standard_rate: keyboard_cost}, - {opening_stock: no_of_items_to_stock} + {opening_stock: no_of_items_to_stock}, + {default_warehouse: "Stores - RB"} ] ), () => { @@ -43,7 +44,8 @@ QUnit.test("test: item", function (assert) { {item_group: "Products"}, {is_stock_item: is_stock_item}, {standard_rate: screen_cost}, - {opening_stock: no_of_items_to_stock} + {opening_stock: no_of_items_to_stock}, + {default_warehouse: "Stores - RB"} ] ), @@ -54,7 +56,8 @@ QUnit.test("test: item", function (assert) { {item_group: "Products"}, {is_stock_item: is_stock_item}, {standard_rate: CPU_cost}, - {opening_stock: no_of_items_to_stock} + {opening_stock: no_of_items_to_stock}, + {default_warehouse: "Stores - RB"} ] ), @@ -62,7 +65,8 @@ QUnit.test("test: item", function (assert) { () => frappe.tests.make( "Item", [ {item_code: "Laptop"}, - {item_group: "Products"} + {item_group: "Products"}, + {default_warehouse: "Stores - RB"} ] ), () => frappe.tests.make( @@ -80,7 +84,8 @@ QUnit.test("test: item", function (assert) { {item_group: "Products"}, {is_stock_item: is_stock_item}, {standard_rate: scrap_cost}, - {opening_stock: no_of_items_to_stock} + {opening_stock: no_of_items_to_stock}, + {default_warehouse: "Stores - RB"} ] ), diff --git a/erpnext/manufacturing/doctype/bom/test_bom.js b/erpnext/manufacturing/doctype/bom/test_bom.js index 8187ef3617..80a4edee8e 100644 --- a/erpnext/manufacturing/doctype/bom/test_bom.js +++ b/erpnext/manufacturing/doctype/bom/test_bom.js @@ -12,6 +12,7 @@ QUnit.test("test: item", function (assert) { {item: "Laptop"}, {quantity: 1}, {with_operations: 1}, + {company: "Razer Blade"}, {operations: [ [ {operation: "Assemble CPU"}, diff --git a/erpnext/manufacturing/doctype/production_order/test_production_order.js b/erpnext/manufacturing/doctype/production_order/test_production_order.js new file mode 100644 index 0000000000..57299db039 --- /dev/null +++ b/erpnext/manufacturing/doctype/production_order/test_production_order.js @@ -0,0 +1,41 @@ +QUnit.test("test: production order", function (assert) { + assert.expect(2); + let done = assert.async(); + let laptop_quantity = 5; + let single_laptop_cost = 1340; // Calculated in workstation (time * per_hour_cost) for every item + + frappe.run_serially([ + // test production order + () => frappe.set_route("List", "Production Order"), + () => frappe.timeout(0.5), + + // Create a laptop production order + () => frappe.new_doc("Production Order"), + () => frappe.timeout(1), + () => cur_frm.set_value("production_item", "Laptop"), + () => frappe.timeout(2), + () => cur_frm.set_value("company", "Razer Blade"), + () => frappe.timeout(2), + () => cur_frm.set_value("qty", laptop_quantity), + () => frappe.timeout(2), + () => cur_frm.set_value("scrap_warehouse", "Laptop Scrap Warehouse - RB"), + () => frappe.timeout(1), + () => cur_frm.set_value("wip_warehouse", "Work In Progress - RB"), + () => frappe.timeout(1), + () => cur_frm.set_value("fg_warehouse", "Finished Goods - RB"), + () => cur_frm.save(), + () => frappe.timeout(1), + + () => { + assert.equal(cur_frm.doc.planned_operating_cost, cur_frm.doc.total_operating_cost, "Total and Planned Cost is equal"); + assert.equal(cur_frm.doc.planned_operating_cost, laptop_quantity*single_laptop_cost, "Total cost is calculated correctly "+cur_frm.doc.planned_operating_cost); + }, + + () => cur_frm.savesubmit(), + () => frappe.timeout(1), + () => frappe.click_button('Yes'), + () => frappe.timeout(1), + + () => done() + ]); +}); diff --git a/erpnext/setup/doctype/company/test_company.js b/erpnext/setup/doctype/company/tests/test_company.js similarity index 100% rename from erpnext/setup/doctype/company/test_company.js rename to erpnext/setup/doctype/company/tests/test_company.js diff --git a/erpnext/setup/doctype/company/tests/test_company_production.js b/erpnext/setup/doctype/company/tests/test_company_production.js new file mode 100644 index 0000000000..73bd710e23 --- /dev/null +++ b/erpnext/setup/doctype/company/tests/test_company_production.js @@ -0,0 +1,19 @@ +QUnit.test("Test: Company", function (assert) { + assert.expect(0); + + let done = assert.async(); + + frappe.run_serially([ + // Added company for Production Order testing + () => frappe.set_route("List", "Company"), + () => frappe.new_doc("Company"), + () => frappe.timeout(1), + () => cur_frm.set_value("company_name", "Razer Blade"), + () => cur_frm.set_value("abbr", "RB"), + () => cur_frm.set_value("default_currency", "USD"), + () => cur_frm.save(), + () => frappe.timeout(1), + + () => done() + ]); +}); \ No newline at end of file diff --git a/erpnext/stock/doctype/warehouse/test_warehouse.js b/erpnext/stock/doctype/warehouse/test_warehouse.js new file mode 100644 index 0000000000..3763613042 --- /dev/null +++ b/erpnext/stock/doctype/warehouse/test_warehouse.js @@ -0,0 +1,19 @@ +QUnit.test("test: warehouse", function (assert) { + assert.expect(0); + let done = assert.async(); + + frappe.run_serially([ + // test warehouse creation + () => frappe.set_route("List", "Warehouse"), + + // Create a Laptop Scrap Warehouse + () => frappe.tests.make( + "Warehouse", [ + {warehouse_name: "Laptop Scrap Warehouse"}, + {company: "Razer Blade"} + ] + ), + + () => done() + ]); +}); diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt index b87ff034c2..3943144e2e 100644 --- a/erpnext/tests/ui/tests.txt +++ b/erpnext/tests/ui/tests.txt @@ -1,11 +1,12 @@ erpnext/tests/ui/make_fixtures.js #long -erpnext/setup/doctype/company/test_company.js +erpnext/setup/doctype/company/tests/test_company.js erpnext/accounts/doctype/account/test_account.js erpnext/accounts/doctype/account/test_make_tax_account.js erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.js erpnext/crm/doctype/lead/test_lead.js erpnext/crm/doctype/opportunity/test_opportunity.js erpnext/selling/doctype/quotation/test_quotation.js +erpnext/setup/doctype/company/tests/test_company_production.js erpnext/crm/doctype/item/test_item.js erpnext/manufacturing/doctype/workstation/test_workstation.js erpnext/manufacturing/doctype/operation/test_operation.js @@ -31,5 +32,7 @@ erpnext/schools/doctype/student_batch_name/test_student_batch_name.js erpnext/schools/doctype/student_category/test_student_category.js erpnext/schools/doctype/room/test_room.js erpnext/schools/doctype/instructor/test_instructor.js +erpnext/stock/doctype/warehouse/test_warehouse.js +erpnext/manufacturing/doctype/production_order/test_production_order.js erpnext/accounts/page/pos/test_pos.js erpnext/selling/doctype/product_bundle/test_product_bundle.js