mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 19:29:10 +00:00
[UI Test] Buying module - Multiple tests for Purchase orders (#10414)
* Extended timeout to avoid rare failures * Get purchase orders with discount on grand total * Get purchase orders with discount on individual items * Get purchase orders and calculate taxes * Added paths
This commit is contained in:
committed by
Makarand Bauskar
parent
f6544e95d4
commit
289400d944
@@ -45,7 +45,7 @@ QUnit.test("test: purchase order", function(assert) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
() => cur_frm.print_doc(),
|
() => cur_frm.print_doc(),
|
||||||
() => frappe.timeout(1),
|
() => frappe.timeout(2),
|
||||||
() => {
|
() => {
|
||||||
assert.ok($('.btn-print-print').is(':visible'), "Print Format Available");
|
assert.ok($('.btn-print-print').is(':visible'), "Print Format Available");
|
||||||
assert.ok($('div > div:nth-child(5) > div > div > table > tbody > tr > td:nth-child(4) > div').text().includes('Test Product 4'), "Print Preview Works");
|
assert.ok($('div > div:nth-child(5) > div > div > table > tbody > tr > td:nth-child(4) > div').text().includes('Test Product 4'), "Print Preview Works");
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
QUnit.module('Buying');
|
||||||
|
|
||||||
|
QUnit.test("test: purchase order with discount on grand total", function(assert) {
|
||||||
|
assert.expect(4);
|
||||||
|
let done = assert.async();
|
||||||
|
|
||||||
|
frappe.run_serially([
|
||||||
|
() => {
|
||||||
|
return frappe.tests.make('Purchase Order', [
|
||||||
|
{supplier: 'Test Supplier'},
|
||||||
|
{company: 'Wind Power LLC'},
|
||||||
|
{is_subcontracted: 'No'},
|
||||||
|
{buying_price_list: 'Test-Buying-EUR'},
|
||||||
|
{currency: 'EUR'},
|
||||||
|
{items: [
|
||||||
|
[
|
||||||
|
{"item_code": 'Test Product 4'},
|
||||||
|
{"qty": 5},
|
||||||
|
{"uom": 'Unit'},
|
||||||
|
{"rate": 500 },
|
||||||
|
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
|
||||||
|
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
|
||||||
|
{"warehouse": 'Stores - WP'}
|
||||||
|
]
|
||||||
|
]},
|
||||||
|
{apply_discount_on: 'Grand Total'},
|
||||||
|
{additional_discount_percentage: 10}
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
|
() => frappe.timeout(1),
|
||||||
|
|
||||||
|
() => {
|
||||||
|
assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Supplier name correct");
|
||||||
|
assert.ok(cur_frm.doc.items[0].rate == 500, "Rate correct");
|
||||||
|
// Calculate total
|
||||||
|
assert.ok(cur_frm.doc.total == 2500, "Total correct");
|
||||||
|
// Calculate grand total after discount
|
||||||
|
assert.ok(cur_frm.doc.grand_total == 2250, "Grand total correct");
|
||||||
|
},
|
||||||
|
|
||||||
|
() => frappe.tests.click_button('Submit'),
|
||||||
|
() => frappe.tests.click_button('Yes'),
|
||||||
|
() => frappe.timeout(0.3),
|
||||||
|
|
||||||
|
() => done()
|
||||||
|
]);
|
||||||
|
});
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
QUnit.module('Buying');
|
||||||
|
|
||||||
|
QUnit.test("test: purchase order with item wise discount", function(assert) {
|
||||||
|
assert.expect(4);
|
||||||
|
let done = assert.async();
|
||||||
|
|
||||||
|
frappe.run_serially([
|
||||||
|
() => {
|
||||||
|
return frappe.tests.make('Purchase Order', [
|
||||||
|
{supplier: 'Test Supplier'},
|
||||||
|
{company: 'Wind Power LLC'},
|
||||||
|
{is_subcontracted: 'No'},
|
||||||
|
{buying_price_list: 'Test-Buying-EUR'},
|
||||||
|
{currency: 'EUR'},
|
||||||
|
{items: [
|
||||||
|
[
|
||||||
|
{"item_code": 'Test Product 4'},
|
||||||
|
{"qty": 5},
|
||||||
|
{"uom": 'Unit'},
|
||||||
|
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
|
||||||
|
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
|
||||||
|
{"warehouse": 'Stores - WP'},
|
||||||
|
{"discount_percentage": 20}
|
||||||
|
]
|
||||||
|
]}
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
|
() => frappe.timeout(1),
|
||||||
|
|
||||||
|
() => {
|
||||||
|
assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Supplier name correct");
|
||||||
|
assert.ok(cur_frm.doc.items[0].discount_percentage == 20, "Discount correct");
|
||||||
|
// Calculate totals after discount
|
||||||
|
assert.ok(cur_frm.doc.total == 2000, "Total correct");
|
||||||
|
assert.ok(cur_frm.doc.grand_total == 2000, "Grand total correct");
|
||||||
|
},
|
||||||
|
|
||||||
|
() => frappe.tests.click_button('Submit'),
|
||||||
|
() => frappe.tests.click_button('Yes'),
|
||||||
|
() => frappe.timeout(0.3),
|
||||||
|
|
||||||
|
() => done()
|
||||||
|
]);
|
||||||
|
});
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
QUnit.module('Buying');
|
||||||
|
|
||||||
|
QUnit.test("test: purchase order with taxes and charges", function(assert) {
|
||||||
|
assert.expect(3);
|
||||||
|
let done = assert.async();
|
||||||
|
|
||||||
|
frappe.run_serially([
|
||||||
|
() => {
|
||||||
|
return frappe.tests.make('Purchase Order', [
|
||||||
|
{supplier: 'Test Supplier'},
|
||||||
|
{company: 'Wind Power LLC'},
|
||||||
|
{is_subcontracted: 'No'},
|
||||||
|
{buying_price_list: 'Test-Buying-USD'},
|
||||||
|
{currency: 'USD'},
|
||||||
|
{items: [
|
||||||
|
[
|
||||||
|
{"item_code": 'Test Product 4'},
|
||||||
|
{"qty": 5},
|
||||||
|
{"uom": 'Unit'},
|
||||||
|
{"rate": 500 },
|
||||||
|
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
|
||||||
|
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
|
||||||
|
{"warehouse": 'Stores - WP'}
|
||||||
|
]
|
||||||
|
]},
|
||||||
|
|
||||||
|
{taxes_and_charges: 'TEST In State GST'}
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
|
() => {
|
||||||
|
// Check taxes and calculate grand total
|
||||||
|
assert.ok(cur_frm.doc.taxes[1].account_head=='SGST - '+frappe.get_abbr(frappe.defaults.get_default('Company')), "Account Head abbr correct");
|
||||||
|
assert.ok(cur_frm.doc.total_taxes_and_charges == 225, "Taxes and charges correct");
|
||||||
|
assert.ok(cur_frm.doc.grand_total == 2725, "Grand total correct");
|
||||||
|
},
|
||||||
|
|
||||||
|
() => frappe.timeout(0.3),
|
||||||
|
() => frappe.tests.click_button('Submit'),
|
||||||
|
() => frappe.tests.click_button('Yes'),
|
||||||
|
() => frappe.timeout(0.3),
|
||||||
|
() => done()
|
||||||
|
]);
|
||||||
|
});
|
||||||
@@ -46,7 +46,7 @@ QUnit.test("test: supplier quotation", function(assert) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
() => cur_frm.print_doc(),
|
() => cur_frm.print_doc(),
|
||||||
() => frappe.timeout(1),
|
() => frappe.timeout(2),
|
||||||
() => {
|
() => {
|
||||||
assert.ok($('.btn-print-print').is(':visible'), "Print Format Available");
|
assert.ok($('.btn-print-print').is(':visible'), "Print Format Available");
|
||||||
assert.ok($("table > tbody > tr > td:nth-child(3) > div").text().includes("Test Product 4"), "Print Preview Works As Expected");
|
assert.ok($("table > tbody > tr > td:nth-child(3) > div").text().includes("Test Product 4"), "Print Preview Works As Expected");
|
||||||
|
|||||||
@@ -87,4 +87,7 @@ erpnext/accounts/doctype/sales_invoice/test_sales_invoice.js
|
|||||||
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_item_wise_discount.js
|
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_item_wise_discount.js
|
||||||
erpnext/buying/doctype/purchase_order/tests/test_purchase_order.js
|
erpnext/buying/doctype/purchase_order/tests/test_purchase_order.js
|
||||||
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_multi_uom.js
|
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_multi_uom.js
|
||||||
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_get_items.js
|
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_get_items.js
|
||||||
|
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_discount_on_grand_total.js
|
||||||
|
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_item_wise_discount.js
|
||||||
|
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_taxes_and_charges.js
|
||||||
Reference in New Issue
Block a user