From a1637d83434f0e1f2c1e3321eb35351c22d1f7f0 Mon Sep 17 00:00:00 2001 From: Vishal Dhayagude Date: Tue, 22 Aug 2017 18:33:17 +0530 Subject: [PATCH] [UI Test] UI test for Sales Invoice with Payment Entry (#10483) * [UI Test] UI test for Sales Invoice with Payment Entry * Update test_purchase_order_receipt.js --- .../sales_invoice/tests/test_sales_invoice.js | 43 ++++++++++++++ .../tests/test_sales_invoice_with_payment.js | 56 +++++++++++++++++++ .../tests/test_purchase_order_receipt.js | 1 - erpnext/tests/ui/tests.txt | 3 +- 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice.js create mode 100644 erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_payment.js diff --git a/erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice.js new file mode 100644 index 00000000000..35b255875ea --- /dev/null +++ b/erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice.js @@ -0,0 +1,43 @@ +QUnit.module('Sales Invoice'); + +QUnit.test("test sales Invoice", function(assert) { + assert.expect(4); + let done = assert.async(); + frappe.run_serially([ + () => { + return frappe.tests.make('Sales Invoice', [ + {customer: 'Test Customer 1'}, + {items: [ + [ + {'qty': 5}, + {'item_code': 'Test Product 1'}, + ] + ]}, + {update_stock:1}, + {customer_address: 'Test1-Billing'}, + {shipping_address_name: 'Test1-Shipping'}, + {contact_person: 'Contact 1-Test Customer 1'}, + {taxes_and_charges: 'TEST In State GST'}, + {tc_name: 'Test Term 1'}, + {terms: 'This is Test'} + ]); + }, + () => cur_frm.save(), + () => { + // get_item_details + assert.ok(cur_frm.doc.items[0].item_name=='Test Product 1', "Item name correct"); + // get tax details + assert.ok(cur_frm.doc.taxes_and_charges=='TEST In State GST', "Tax details correct"); + // get tax account head details + assert.ok(cur_frm.doc.taxes[0].account_head=='CGST - '+frappe.get_abbr(frappe.defaults.get_default('Company')), " Account Head abbr correct"); + // grand_total Calculated + assert.ok(cur_frm.doc.grand_total==590, "Grad Total correct"); + + }, + () => frappe.tests.click_button('Submit'), + () => frappe.tests.click_button('Yes'), + () => frappe.timeout(0.3), + () => done() + ]); +}); + diff --git a/erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_payment.js b/erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_payment.js new file mode 100644 index 00000000000..736443e2609 --- /dev/null +++ b/erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_payment.js @@ -0,0 +1,56 @@ +QUnit.module('Sales Invoice'); + +QUnit.test("test sales Invoice with payment", function(assert) { + assert.expect(4); + let done = assert.async(); + frappe.run_serially([ + () => { + return frappe.tests.make('Sales Invoice', [ + {customer: 'Test Customer 1'}, + {items: [ + [ + {'qty': 5}, + {'item_code': 'Test Product 1'}, + ] + ]}, + {update_stock:1}, + {customer_address: 'Test1-Billing'}, + {shipping_address_name: 'Test1-Shipping'}, + {contact_person: 'Contact 1-Test Customer 1'}, + {taxes_and_charges: 'TEST In State GST'}, + {tc_name: 'Test Term 1'}, + {terms: 'This is Test'} + ]); + }, + () => cur_frm.save(), + () => { + // get_item_details + assert.ok(cur_frm.doc.items[0].item_name=='Test Product 1', "Item name correct"); + // get tax details + assert.ok(cur_frm.doc.taxes_and_charges=='TEST In State GST', "Tax details correct"); + // grand_total Calculated + assert.ok(cur_frm.doc.grand_total==590, "Grad Total correct"); + + }, + () => frappe.tests.click_button('Submit'), + () => frappe.tests.click_button('Yes'), + () => frappe.timeout(2), + () => frappe.tests.click_button('Close'), + () => frappe.tests.click_button('Make'), + () => frappe.tests.click_link('Payment'), + () => frappe.timeout(0.2), + () => { cur_frm.set_value('mode_of_payment','Cash');}, + () => { cur_frm.set_value('paid_to','Cash - '+frappe.get_abbr(frappe.defaults.get_default('Company')));}, + () => {cur_frm.set_value('reference_no','TEST1234');}, + () => {cur_frm.set_value('reference_date',frappe.datetime.add_days(frappe.datetime.nowdate(), 0));}, + () => cur_frm.save(), + () => { + // get payment details + assert.ok(cur_frm.doc.paid_amount==590, "Paid Amount Correct"); + }, + () => frappe.tests.click_button('Submit'), + () => frappe.tests.click_button('Yes'), + () => done() + ]); +}); + diff --git a/erpnext/buying/doctype/purchase_order/tests/test_purchase_order_receipt.js b/erpnext/buying/doctype/purchase_order/tests/test_purchase_order_receipt.js index e77814d0f9f..daf8d6c259c 100644 --- a/erpnext/buying/doctype/purchase_order/tests/test_purchase_order_receipt.js +++ b/erpnext/buying/doctype/purchase_order/tests/test_purchase_order_receipt.js @@ -69,7 +69,6 @@ QUnit.test("test: purchase order receipt", function(assert) { assert.ok($('div.slick-cell.l2.r2 > a').text().includes('Test Product 1') && $('div.slick-cell.l9.r9 > div').text().includes(5), "Stock ledger entry correct"); }, - () => done() ]); }); diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt index ffdccfd0066..cb33c90c1ff 100644 --- a/erpnext/tests/ui/tests.txt +++ b/erpnext/tests/ui/tests.txt @@ -70,7 +70,8 @@ erpnext/buying/doctype/supplier/test_supplier.js erpnext/buying/doctype/request_for_quotation/tests/test_request_for_quotation.js erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation.js erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_taxes_and_charges.js -erpnext/accounts/doctype/sales_invoice/test_sales_invoice.js +erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice.js +erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_payment.js erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.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