[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
This commit is contained in:
Ameya Shenoy 2017-07-24 14:34:30 +05:30 committed by Rushabh Mehta
parent 20a862a6b9
commit 91b2833708
4 changed files with 195 additions and 42 deletions

View File

@ -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 @@ QUnit.test("test: item", function (assert) {
"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 @@ QUnit.test("test: item", function (assert) {
'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 @@ QUnit.test("test: item", function (assert) {
"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}
]
),
// 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}
]
),
() => {
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()
]);

View File

@ -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()
]);
});

View File

@ -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()
]);
});

View File

@ -4,5 +4,7 @@ erpnext/crm/doctype/lead/test_lead.js
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
erpnext/hr/doctype/branch/test_branch.js