[ui-tests] added workstation and operation  (#10044)

* [ui-test] workstation and operation testing added

* [ui-tests] removed unnecessary assertions and used logical names for operations and workstations
diff --git a/erpnext/crm/doctype/item/test_item.js b/erpnext/crm/doctype/item/test_item.js
index a490b94..2f50ebe 100644
--- a/erpnext/crm/doctype/item/test_item.js
+++ b/erpnext/crm/doctype/item/test_item.js
@@ -1,6 +1,12 @@
 QUnit.test("test: item", function (assert) {
-	assert.expect(18);
+	assert.expect(6);
 	let done = assert.async();
+	let keyboard_cost  = 800;
+	let screen_cost  = 4000;
+	let CPU_cost  = 15000;
+	let scrap_cost = 100;
+	let no_of_items_to_stock = 100;
+	let is_stock_item = 1;
 	frappe.run_serially([
 		// test item creation
 		() => frappe.set_route("List", "Item"),
@@ -10,9 +16,9 @@
 			"Item", [
 				{item_code: "Keyboard"},
 				{item_group: "Products"},
-				{is_stock_item: 1},
-				{standard_rate: 1000},
-				{opening_stock: 100}
+				{is_stock_item: is_stock_item},
+				{standard_rate: keyboard_cost},
+				{opening_stock: no_of_items_to_stock}
 			]
 		),
 		() => {
@@ -22,11 +28,11 @@
 				'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,
+			assert.equal(cur_frm.doc.is_stock_item, is_stock_item,
 				'is_stock_item for Keyboard set correctly');
-			assert.equal(cur_frm.doc.standard_rate, 1000,
+			assert.equal(cur_frm.doc.standard_rate, keyboard_cost,
 				'standard_rate for Keyboard set correctly');
-			assert.equal(cur_frm.doc.opening_stock, 100,
+			assert.equal(cur_frm.doc.opening_stock, no_of_items_to_stock,
 				'opening_stock for Keyboard set correctly');
 		},
 
@@ -35,50 +41,41 @@
 			"Item", [
 				{item_code: "Screen"},
 				{item_group: "Products"},
-				{is_stock_item: 1},
-				{standard_rate: 1000},
-				{opening_stock: 100}
+				{is_stock_item: is_stock_item},
+				{standard_rate: screen_cost},
+				{opening_stock: no_of_items_to_stock}
 			]
 		),
-		() => {
-			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}
+				{is_stock_item: is_stock_item},
+				{standard_rate: CPU_cost},
+				{opening_stock: no_of_items_to_stock}
 			]
 		),
-		() => {
-			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');
-		},
+
+		// Create a laptop item
+		() => frappe.tests.make(
+			"Item", [
+				{item_code: "Laptop"},
+				{item_group: "Products"}
+			]
+		),
+
+		// Create a scrap item
+		() => frappe.tests.make(
+			"Item", [
+				{item_code: "Scrap item"},
+				{item_group: "Products"},
+				{is_stock_item: is_stock_item},
+				{standard_rate: scrap_cost},
+				{opening_stock: no_of_items_to_stock}
+			]
+		),
 
 		() => done()
 	]);
diff --git a/erpnext/manufacturing/doctype/operation/test_operation.js b/erpnext/manufacturing/doctype/operation/test_operation.js
new file mode 100644
index 0000000..9fedaac
--- /dev/null
+++ b/erpnext/manufacturing/doctype/operation/test_operation.js
@@ -0,0 +1,65 @@
+QUnit.test("test: operation", function (assert) {
+	assert.expect(2);
+	let done = assert.async();
+	let set_op_name = (text) => {
+		$(`input.input-with-feedback.form-control.bold:visible`).val(`${text}`);
+	};
+	let click_create = () => {
+		$(`.btn-primary:contains("Create"):visible`).click();
+	};
+
+	frappe.run_serially([
+		// test operation creation
+		() => frappe.set_route("List", "Operation"),
+
+		// Create a Keyboard operation
+		() => {
+			frappe.tests.make(
+				"Operation", [
+					{workstation: "Keyboard assembly workstation"}
+				]
+			);
+		},
+		() => frappe.timeout(4),
+		() => set_op_name("Assemble Keyboard"),
+		() => frappe.timeout(0.5),
+		() => click_create(),
+		() => frappe.timeout(1),
+		() => {
+			assert.ok(cur_frm.docname.includes('Assemble Keyboard'),
+				'Assemble Keyboard created successfully');
+			assert.ok(cur_frm.doc.workstation.includes('Keyboard assembly workstation'),
+				'Keyboard assembly workstation was linked successfully');
+		},
+
+		// Create a Screen operation
+		() => {
+			frappe.tests.make(
+				"Operation", [
+					{workstation: "Screen assembly workstation"}
+				]
+			);
+		},
+		() => frappe.timeout(4),
+		() => set_op_name("Assemble Screen"),
+		() => frappe.timeout(0.5),
+		() => click_create(),
+		() => frappe.timeout(1),
+
+		// Create a CPU operation
+		() => {
+			frappe.tests.make(
+				"Operation", [
+					{workstation: "CPU assembly workstation"}
+				]
+			);
+		},
+		() => frappe.timeout(4),
+		() => set_op_name("Assemble CPU"),
+		() => frappe.timeout(0.5),
+		() => click_create(),
+		() => frappe.timeout(1),
+
+		() => done()
+	]);
+});
diff --git a/erpnext/manufacturing/doctype/workstation/test_workstation.js b/erpnext/manufacturing/doctype/workstation/test_workstation.js
new file mode 100644
index 0000000..1df53d0
--- /dev/null
+++ b/erpnext/manufacturing/doctype/workstation/test_workstation.js
@@ -0,0 +1,89 @@
+QUnit.test("test: workstation", function (assert) {
+	assert.expect(9);
+	let done = assert.async();
+	let elec_rate = 50;
+	let rent = 100;
+	let consumable_rate = 20;
+	let labour_rate = 500;
+	frappe.run_serially([
+		// test workstation creation
+		() => frappe.set_route("List", "Workstation"),
+
+		// Create a keyboard workstation
+		() => frappe.tests.make(
+			"Workstation", [
+				{workstation_name: "Keyboard assembly workstation"},
+				{hour_rate_electricity: elec_rate},
+				{hour_rate_rent: rent},
+				{hour_rate_consumable: consumable_rate},
+				{hour_rate_labour: labour_rate},
+				{working_hours: [
+					[
+						{enabled: 1},
+						{start_time: '11:00:00'},
+						{end_time: '18:00:00'}
+					]
+				]}
+			]
+		),
+		() => {
+			assert.ok(cur_frm.doc.workstation_name.includes('Keyboard assembly workstation'),
+				'Keyboard assembly workstation created successfully');
+			assert.equal(cur_frm.doc.hour_rate_electricity, elec_rate,
+				'electricity rate set correctly');
+			assert.equal(cur_frm.doc.hour_rate_rent, rent,
+				'rent set correctly');
+			assert.equal(cur_frm.doc.hour_rate_consumable, consumable_rate,
+				'consumable rate set correctly');
+			assert.equal(cur_frm.doc.hour_rate_labour, labour_rate,
+				'labour rate set correctly');
+			assert.equal(cur_frm.doc.working_hours[0].enabled, 1,
+				'working hours enabled');
+			assert.ok(cur_frm.doc.working_hours[0].start_time.includes('11:00:0'),
+				'start time set correctly');
+			assert.ok(cur_frm.doc.working_hours[0].end_time.includes('18:00:0'),
+				'end time set correctly');
+			assert.ok(cur_frm.doc.hour_rate_electricity+cur_frm.doc.hour_rate_rent+
+				cur_frm.doc.hour_rate_consumable+cur_frm.doc.hour_rate_labour==
+				cur_frm.doc.hour_rate, 'Net hour rate set correctly');
+		},
+
+		// Create a Screen workstation
+		() => frappe.tests.make(
+			"Workstation", [
+				{workstation_name: "Screen assembly workstation"},
+				{hour_rate_electricity: elec_rate},
+				{hour_rate_rent: rent},
+				{hour_rate_consumable: consumable_rate},
+				{hour_rate_labour: labour_rate},
+				{working_hours: [
+					[
+						{enabled: 1},
+						{start_time: '11:00:00'},
+						{end_time: '18:00:00'}
+					]
+				]}
+			]
+		),
+
+		// Create a CPU workstation
+		() => frappe.tests.make(
+			"Workstation", [
+				{workstation_name: "CPU assembly workstation"},
+				{hour_rate_electricity: elec_rate},
+				{hour_rate_rent: rent},
+				{hour_rate_consumable: consumable_rate},
+				{hour_rate_labour: labour_rate},
+				{working_hours: [
+					[
+						{enabled: 1},
+						{start_time: '11:00:00'},
+						{end_time: '18:00:00'}
+					]
+				]}
+			]
+		),
+
+		() => done()
+	]);
+});
diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt
index c149226..f7e4956 100644
--- a/erpnext/tests/ui/tests.txt
+++ b/erpnext/tests/ui/tests.txt
@@ -4,5 +4,7 @@
 erpnext/crm/doctype/opportunity/test_opportunity.js
 erpnext/selling/doctype/quotation/test_quotation.js
 erpnext/crm/doctype/item/test_item.js
+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
\ No newline at end of file
+erpnext/hr/doctype/branch/test_branch.js