[UI Tests] All sales order test in tests folders (#10211)
* [new] Sales order with_discount, multi_uom, delivery_date added
* [fix] All sales order test in tests folder
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.js b/erpnext/selling/doctype/sales_order/tests/test_sales_order.js
similarity index 100%
rename from erpnext/selling/doctype/sales_order/test_sales_order.js
rename to erpnext/selling/doctype/sales_order/tests/test_sales_order.js
diff --git a/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_item_wise_discount.js b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_item_wise_discount.js
new file mode 100644
index 0000000..c745374
--- /dev/null
+++ b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_item_wise_discount.js
@@ -0,0 +1,37 @@
+QUnit.module('Sales Order');
+
+QUnit.test("test sales order", function(assert) {
+ assert.expect(2);
+ let done = assert.async();
+ frappe.run_serially([
+ () => {
+ return frappe.tests.make('Sales Order', [
+ {customer: 'Test Customer 1'},
+ {items: [
+ [
+ {'delivery_date': frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)},
+ {'qty': 5},
+ {'item_code': 'Test Product 4'},
+ {'discount_percentage': 10},
+ {'margin_type': 'Percentage'}
+ ]
+ ]},
+ {customer_address: 'Test1-Billing'},
+ {shipping_address_name: 'Test1-Shipping'},
+ {contact_person: 'Contact 1-Test Customer 1'}
+ ]);
+ },
+ () => cur_frm.save(),
+ () => {
+ // get_item_details
+ assert.ok(cur_frm.doc.items[0].item_name=='Test Product 4', "Item name correct");
+ // get grand_total details
+ assert.ok(cur_frm.doc.grand_total== 450, "Grand total correct ");
+
+ },
+ () => frappe.tests.click_button('Submit'),
+ () => frappe.tests.click_button('Yes'),
+ () => frappe.timeout(0.3),
+ () => done()
+ ]);
+});
diff --git a/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multi_uom.js b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multi_uom.js
new file mode 100644
index 0000000..74f51ca
--- /dev/null
+++ b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multi_uom.js
@@ -0,0 +1,38 @@
+QUnit.module('Sales Order');
+
+QUnit.test("test sales order", function(assert) {
+ assert.expect(3);
+ let done = assert.async();
+ frappe.run_serially([
+ () => {
+ return frappe.tests.make('Sales Order', [
+ {customer: 'Test Customer 1'},
+ {items: [
+ [
+ {'delivery_date': frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)},
+ {'qty': 5},
+ {'item_code': 'Test Product 4'},
+ {'uom': 'unit'},
+ ]
+ ]},
+ {customer_address: 'Test1-Billing'},
+ {shipping_address_name: 'Test1-Shipping'},
+ {contact_person: 'Contact 1-Test Customer 1'}
+ ]);
+ },
+ () => cur_frm.save(),
+ () => {
+ // get_item_details
+ assert.ok(cur_frm.doc.items[0].item_name=='Test Product 4', "Item name correct");
+ // get uom details
+ assert.ok(cur_frm.doc.items[0].uom=='Unit', "Multi Uom correct");
+ // get grand_total details
+ assert.ok(cur_frm.doc.grand_total== 5000, "Grand total correct ");
+
+ },
+ () => frappe.tests.click_button('Submit'),
+ () => frappe.tests.click_button('Yes'),
+ () => frappe.timeout(0.3),
+ () => done()
+ ]);
+});
diff --git a/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multiple_delivery_date.js b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multiple_delivery_date.js
new file mode 100644
index 0000000..8e05385
--- /dev/null
+++ b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multiple_delivery_date.js
@@ -0,0 +1,59 @@
+/* eslint-disable */
+// rename this file from _test_[name] to test_[name] to activate
+// and remove above this line
+
+QUnit.test("test: Sales Order", function (assert) {
+ assert.expect(2);
+ let done = assert.async();
+ let delivery_date = frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1);
+
+ frappe.run_serially([
+ // insert a new Sales Order
+ () => {
+ return frappe.tests.make('Sales Order', [
+ {customer: "Test Customer 1"},
+ {delivery_date: delivery_date},
+ {order_type: 'Sales'},
+ {items: [
+ [
+ {"item_code": "Test Product 1"},
+ {"qty": 5},
+ {'rate': 100},
+ ]]
+ }
+ ])
+ },
+ () => {
+ assert.ok(cur_frm.doc.items[0].delivery_date == delivery_date);
+ },
+ () => frappe.timeout(1),
+ // make SO without delivery date in parent,
+ // parent delivery date should be set based on final delivery date entered in item
+ () => {
+ return frappe.tests.make('Sales Order', [
+ {customer: "Test Customer 1"},
+ {order_type: 'Sales'},
+ {items: [
+ [
+ {"item_code": "Test Product 1"},
+ {"qty": 5},
+ {'rate': 100},
+ {'delivery_date': delivery_date}
+ ],
+ [
+ {"item_code": "Test Product 2"},
+ {"qty": 5},
+ {'rate': 100},
+ {'delivery_date': frappe.datetime.add_days(delivery_date, 5)}
+ ]]
+ }
+ ])
+ },
+ () => cur_frm.save(),
+ () => frappe.timeout(1),
+ () => {
+ assert.ok(cur_frm.doc.delivery_date == frappe.datetime.add_days(delivery_date, 5));
+ },
+ () => done()
+ ]);
+});
\ No newline at end of file
diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt
index 2abadec..a61c8ec 100644
--- a/erpnext/tests/ui/tests.txt
+++ b/erpnext/tests/ui/tests.txt
@@ -8,7 +8,10 @@
erpnext/selling/doctype/quotation/test_quotation.js
erpnext/setup/doctype/company/tests/test_company_production.js
erpnext/crm/doctype/item/test_item.js
-erpnext/selling/doctype/sales_order/test_sales_order.js
+erpnext/selling/doctype/sales_order/tests/test_sales_order.js
+erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multiple_delivery_date.js
+erpnext/selling/doctype/sales_order/tests/test_sales_order_with_item_wise_discount.js
+erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multi_uom.js
erpnext/manufacturing/doctype/workstation/test_workstation.js
erpnext/manufacturing/doctype/operation/test_operation.js
erpnext/manufacturing/doctype/bom/test_bom.js