From 243f091b30b99bef08a42fc9cebec795c4d331dc Mon Sep 17 00:00:00 2001 From: Shreya Shah Date: Thu, 10 Aug 2017 10:51:47 +0530 Subject: [PATCH] Get supplier details (#10352) --- .../buying/doctype/supplier/test_supplier.js | 78 +++++++++++++++++++ erpnext/tests/ui/tests.txt | 3 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 erpnext/buying/doctype/supplier/test_supplier.js diff --git a/erpnext/buying/doctype/supplier/test_supplier.js b/erpnext/buying/doctype/supplier/test_supplier.js new file mode 100644 index 0000000000..6be40a52bf --- /dev/null +++ b/erpnext/buying/doctype/supplier/test_supplier.js @@ -0,0 +1,78 @@ +QUnit.module('Buying'); + +QUnit.test("test: supplier", function(assert) { + assert.expect(6); + let done = assert.async(); + frappe.run_serially([ + () => { + return frappe.tests.make('Supplier', [ + {supplier_name: 'Test Supplier'}, + {supplier_type: 'Hardware'}, + {country: 'United States'}, + {default_currency: 'USD'}, + {default_price_list: 'Test-Buying-USD'}, + {credit_days_based_on: 'Fixed Days'}, + {accounts: [ + [ + {'company': "Test Company"}, + {'account': "Creditors - TC"} + ]] + } + ]); + }, + () => frappe.timeout(1), + () => frappe.click_button('New Address'), + () => { + return frappe.tests.set_form_values(cur_frm, [ + {address_title:"Test3"}, + {address_type: "Billing"}, + {address_line1: "Billing Street 3"}, + {city: "Billing City 3"}, + ]); + }, + () => cur_frm.save(), + () => frappe.timeout(2), + () => frappe.click_button('New Address'), + () => { + return frappe.tests.set_form_values(cur_frm, [ + {address_title:"Test3"}, + {address_type: "Shipping"}, + {address_line1: "Shipping Street 3"}, + {city: "Shipping City 3"}, + ]); + }, + () => cur_frm.save(), + () => frappe.timeout(2), + () => frappe.click_button('New Address'), + () => { + return frappe.tests.set_form_values(cur_frm, [ + {address_title:"Test3"}, + {address_type: "Warehouse"}, + {address_line1: "Warehouse Street 3"}, + {city: "Warehouse City 3"}, + ]); + }, + () => cur_frm.save(), + () => frappe.timeout(2), + () => frappe.click_button('New Contact'), + () => { + return frappe.tests.set_form_values(cur_frm, [ + {first_name: "Contact 3"} + ]); + }, + () => cur_frm.save(), + () => frappe.timeout(1), + () => frappe.set_route('Form', 'Supplier', 'Test Supplier'), + () => frappe.timeout(0.3), + + () => { + assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Name correct"); + assert.ok(cur_frm.doc.supplier_type == 'Hardware', "Type correct"); + assert.ok(cur_frm.doc.default_currency == 'USD', "Currency correct"); + assert.ok(cur_frm.doc.accounts[0].account == 'Creditors - '+frappe.get_abbr('Test Company'), " Account Head abbr correct"); + assert.ok($('.address-box:nth-child(3) p').text().includes('Shipping City 3'), "Address correct"); + assert.ok($('.col-sm-6+ .col-sm-6 .h6').text().includes('Contact 3'), "Contact correct"); + }, + () => done() + ]); +}); \ No newline at end of file diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt index 3f867f4b9c..fff54c6b95 100644 --- a/erpnext/tests/ui/tests.txt +++ b/erpnext/tests/ui/tests.txt @@ -71,4 +71,5 @@ erpnext/schools/doctype/student_group_creation_tool/test_student_group_creation_ erpnext/schools/doctype/student_leave_application/test_student_leave_application.js erpnext/schools/doctype/student_attendance_tool/test_student_attendance_tool.js erpnext/schools/doctype/student_attendance/test_student_attendance.js -erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_material_issue.js \ No newline at end of file +erpnext/stock/doctype/stock_entry/tests/test_stock_entry_for_material_issue.js +erpnext/buying/doctype/supplier/test_supplier.js \ No newline at end of file