[ui-test] completed tests for manufacturing (#10218)

* modified test_item to include child table assertions

* minor travis fixes

* removed css selectors and used cur_frm
This commit is contained in:
Ameya Shenoy 2017-08-04 10:50:32 +05:30 committed by Rushabh Mehta
parent 329aae2458
commit 4331067e57
4 changed files with 106 additions and 9 deletions

View File

@ -117,4 +117,4 @@ QUnit.test("test: item", function (assert) {
),
() => done()
]);
});
});

View File

@ -1,8 +1,17 @@
QUnit.test("test: production order", function (assert) {
assert.expect(2);
assert.expect(25);
let done = assert.async();
let laptop_quantity = 5;
let single_laptop_cost = 1340; // Calculated in workstation (time * per_hour_cost) for every item
let items = ["Screen", "CPU", "Keyboard"];
let operation_items = ["CPU", "Keyboard", "Screen"];
let click_make = () => {
let element = $(`.btn-primary:contains("Make"):visible`);
if(!element.length) {
throw `did not find any button containing 'Make'`;
}
element.click();
return frappe.timeout(1);
};
frappe.run_serially([
// test production order
@ -24,18 +33,106 @@ QUnit.test("test: production order", function (assert) {
() => frappe.timeout(1),
() => cur_frm.set_value("fg_warehouse", "Finished Goods - RB"),
() => cur_frm.save(),
() => frappe.timeout(1),
() => frappe.timeout(2),
() => {
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);
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, cur_frm.doc.total_operating_cost,
"Total and Planned Cost is equal");
items.forEach(function(item, index) {
assert.equal(item, cur_frm.doc.required_items[index].item_code, `Required item ${item} added`);
assert.equal("Stores - RB", cur_frm.doc.required_items[index].source_warehouse, `Item ${item} warhouse verified`);
assert.equal("5", cur_frm.doc.required_items[index].required_qty, `Item ${item} quantity verified`);
});
operation_items.forEach(function(operation_item, index) {
assert.equal(`Assemble ${operation_item}`, cur_frm.doc.operations[index].operation,
`Operation ${operation_item} added`);
assert.equal(`${operation_item} assembly workstation`, cur_frm.doc.operations[index].workstation,
`Workstation ${operation_item} linked`);
});
},
// Submit the production order
() => cur_frm.savesubmit(),
() => frappe.timeout(1),
() => frappe.click_button('Yes'),
() => frappe.timeout(1),
// Confirm the production order timesheet, save and submit it
() => frappe.click_link("TS-00"),
() => frappe.timeout(1),
() => frappe.click_button("Save"),
() => frappe.timeout(1),
() => frappe.click_button("Submit"),
() => frappe.timeout(1),
() => frappe.click_button("Yes"),
() => frappe.timeout(2),
// Start the production order process
() => frappe.set_route("List", "Production Order"),
() => frappe.timeout(2),
() => frappe.set_route("List", "Production Order"),
() => frappe.timeout(2),
() => frappe.click_link("Laptop"),
() => frappe.timeout(1),
() => frappe.click_button("Start"),
() => frappe.timeout(0.5),
() => click_make(),
() => frappe.click_button("Save"),
() => frappe.timeout(0.5),
() => {
assert.equal(cur_frm.doc.total_outgoing_value, cur_frm.doc.total_incoming_value,
"Total incoming and outgoing cost is equal");
assert.equal(cur_frm.doc.total_outgoing_value, "99000",
"Outgoing cost is correct"); // Price of each item x5
},
// Submit for production
() => frappe.click_button("Submit"),
() => frappe.timeout(0.5),
() => frappe.click_button("Yes"),
() => frappe.timeout(0.5),
// Finish the production order by sending for manufacturing
() => frappe.set_route("List", "Production Order"),
() => frappe.timeout(1),
() => frappe.click_link("Laptop"),
() => frappe.timeout(1),
() => {
assert.ok(frappe.tests.is_visible("5 items in progress", 'p'), "Production order initiated");
assert.ok(frappe.tests.is_visible("Finish"), "Finish button visible");
},
() => frappe.click_button("Finish"),
() => frappe.timeout(0.5),
() => click_make(),
() => {
assert.equal(cur_frm.doc.total_incoming_value, "105700",
"Incoming cost is correct"); // Price of each item x5, values are in USD
assert.equal(cur_frm.doc.total_outgoing_value, "99000",
"Outgoing cost is correct"); // Price of each item x5, values are in USD
assert.equal(cur_frm.doc.total_incoming_value - cur_frm.doc.total_outgoing_value, cur_frm.doc.value_difference,
"Value difference is correct"); // Price of each item x5, values are in USD
},
() => frappe.click_button("Save"),
() => frappe.timeout(1),
() => frappe.click_button("Submit"),
() => frappe.timeout(1),
() => frappe.click_button("Yes"),
() => frappe.timeout(1),
// Manufacturing finished
() => frappe.set_route("List", "Production Order"),
() => frappe.timeout(1),
() => frappe.click_link("Laptop"),
() => frappe.timeout(1),
() => assert.ok(frappe.tests.is_visible("5 items produced", 'p'), "Production order completed"),
() => done()
]);
});
});

View File

@ -16,4 +16,4 @@ QUnit.test("test: warehouse", function (assert) {
() => done()
]);
});
});

View File

@ -41,7 +41,7 @@ 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/manufacturing/doctype/production_order/test_production_order.js #long
erpnext/accounts/page/pos/test_pos.js
erpnext/selling/doctype/product_bundle/test_product_bundle.js
erpnext/schools/doctype/grading_scale/test_grading_scale.js