From 2890fa74a2361fc14d9bd6e106820f705eeca2d5 Mon Sep 17 00:00:00 2001 From: Vishal Dhayagude Date: Fri, 18 Aug 2017 11:55:14 +0530 Subject: [PATCH] [UI Test] UI Test for Purchase Receipt Added (#10434) --- .../purchase_receipt/test_purchase_receipt.js | 51 +++++++++++++------ erpnext/tests/ui/tests.txt | 3 +- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.js index 2bc73358b8..0b3fcc9898 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.js @@ -1,23 +1,42 @@ -/* eslint-disable */ -// rename this file from _test_[name] to test_[name] to activate -// and remove above this line +QUnit.module('Stock'); -QUnit.test("test: Purchase Receipt", function (assert) { +QUnit.test("test Purchase Receipt", function(assert) { + assert.expect(4); let done = assert.async(); - - // number of asserts - assert.expect(1); - - frappe.run_serially('Purchase Receipt', [ - // insert a new Purchase Receipt - () => frappe.tests.make([ - // values to be set - {key: 'value'} - ]), + frappe.run_serially([ () => { - assert.equal(cur_frm.doc.key, 'value'); + return frappe.tests.make('Purchase Receipt', [ + {supplier: 'Test Supplier'}, + {items: [ + [ + {'received_qty': 5}, + {'qty': 4}, + {'item_code': 'Test Product 1'}, + {'uom': 'Nos'}, + {'warehouse':'Stores - '+frappe.get_abbr(frappe.defaults.get_default('Company'))}, + {'rejected_warehouse':'Work In Progress - '+frappe.get_abbr(frappe.defaults.get_default('Company'))}, + ] + ]}, + {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==472, "Grad Total correct"); + + }, + () => frappe.tests.click_button('Submit'), + () => frappe.tests.click_button('Yes'), + () => frappe.timeout(0.3), () => done() ]); - }); diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt index dc9d5347da..dffbbafe2b 100644 --- a/erpnext/tests/ui/tests.txt +++ b/erpnext/tests/ui/tests.txt @@ -95,4 +95,5 @@ 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 -erpnext/buying/doctype/purchase_order/tests/test_purchase_order_receipt.js \ No newline at end of file +erpnext/buying/doctype/purchase_order/tests/test_purchase_order_receipt.js +erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.js