Added Lead fixture, Added test for Lead, Opportunity (#9607)

* Added fixtures for Address and Contact

* Fixed formatting errors

* Added Test for terms, Added Tax and Terms fixture

* Add tests for tax

* Added Test for Print Format
diff --git a/erpnext/tests/ui/test_fixtures.js b/erpnext/tests/ui/test_fixtures.js
index e4ee664..2ba5db5 100644
--- a/erpnext/tests/ui/test_fixtures.js
+++ b/erpnext/tests/ui/test_fixtures.js
@@ -1,48 +1,216 @@
 $.extend(frappe.test_data, {
-	'Customer': {
-		'Test Customer 1': [
-			{customer_name: 'Test Customer 1'}
+	"Customer": {
+		"Test Customer 1": [
+			{customer_name: "Test Customer 1"}
 		],
-		'Test Customer 2': [
-			{customer_name: 'Test Customer 2'}
+		"Test Customer 2": [
+			{customer_name: "Test Customer 2"}
 		],
-		'Test Customer 3': [
-			{customer_name: 'Test Customer 3'}
+		"Test Customer 3": [
+			{customer_name: "Test Customer 3"}
 		],
 	},
-	'Item': {
-		'Test Product 1': [
-			{item_code: 'Test Product 1'},
-			{item_group: 'Products'},
+	"Item": {
+		"Test Product 1": [
+			{item_code: "Test Product 1"},
+			{item_group: "Products"},
 			{is_stock_item: 1},
 			{standard_rate: 100},
 			{opening_stock: 100},
 		],
-		'Test Product 2': [
-			{item_code: 'Test Product 2'},
-			{item_group: 'Products'},
+		"Test Product 2": [
+			{item_code: "Test Product 2"},
+			{item_group: "Products"},
 			{is_stock_item: 1},
 			{standard_rate: 150},
 			{opening_stock: 200},
 		],
-		'Test Product 3': [
-			{item_code: 'Test Product 3'},
-			{item_group: 'Products'},
+		"Test Product 3": [
+			{item_code: "Test Product 3"},
+			{item_group: "Products"},
 			{is_stock_item: 1},
 			{standard_rate: 250},
 			{opening_stock: 100},
 		],
-		'Test Service 1': [
-			{item_code: 'Test Service 1'},
-			{item_group: 'Services'},
+		"Test Service 1": [
+			{item_code: "Test Service 1"},
+			{item_group: "Services"},
 			{is_stock_item: 0},
 			{standard_rate: 200}
 		],
-		'Test Service 2': [
-			{item_code: 'Test Service 2'},
-			{item_group: 'Services'},
+		"Test Service 2": [
+			{item_code: "Test Service 2"},
+			{item_group: "Services"},
 			{is_stock_item: 0},
 			{standard_rate: 300}
 		]
+	},
+	"Lead": {
+		"LEAD-00001": [
+			{lead_name: "Test Lead 1"}
+		],
+		"LEAD-00002": [
+			{lead_name: "Test Lead 2"}
+		],
+		"LEAD-00003": [
+			{lead_name: "Test Lead 3"}
+		]
+	},
+	"Address": {
+		"Test1-Billing": [
+			{address_title:"Test1"},
+			{address_type: "Billing"},
+			{address_line1: "Billing Street 1"},
+			{city: "Billing City 1"},
+			{links: [
+				[
+					{link_doctype: "Customer"},
+					{link_name: "Test Customer 1"}
+				]
+			]}
+		],
+		"Test1-Shipping": [
+			{address_title:"Test1"},
+			{address_type: "Shipping"},
+			{address_line1: "Shipping Street 1"},
+			{city: "Shipping City 1"},
+			{links: [
+				[
+					{link_doctype: "Customer"},
+					{link_name: "Test Customer 1"}
+				]
+			]}
+		],
+		"Test1-Warehouse": [
+			{address_title:"Test1"},
+			{address_type: "Warehouse"},
+			{address_line1: "Warehouse Street 1"},
+			{city: "Warehouse City 1"},
+			{links: [
+				[
+					{link_doctype: "Customer"},
+					{link_name: "Test Customer 1"}
+				]
+			]}
+		],
+		"Test2-Billing": [
+			{address_title:"Test2"},
+			{address_type: "Billing"},
+			{address_line1: "Billing Street 2"},
+			{city: "Billing City 2"},
+			{links: [
+				[
+					{link_doctype: "Customer"},
+					{link_name: "Test Customer 2"}
+				]
+			]}
+		],
+		"Test2-Shipping": [
+			{address_title:"Test2"},
+			{address_type: "Shipping"},
+			{address_line1: "Shipping Street 2"},
+			{city: "Shipping City 2"},
+			{links: [
+				[
+					{link_doctype: "Customer"},
+					{link_name: "Test Customer 2"}
+				]
+			]}
+		],
+		"Test2-Warehouse": [
+			{address_title:"Test2"},
+			{address_type: "Warehouse"},
+			{address_line1: "Warehouse Street 2"},
+			{city: "Warehouse City 2"},
+			{links: [
+				[
+					{link_doctype: "Customer"},
+					{link_name: "Test Customer 2"}
+				]
+			]}
+		]
+	},
+	"Contact": {
+		"Contact 1-Test Customer 1": [
+			{first_name: "Contact 1"},
+			{links: [
+				[
+					{link_doctype: "Customer"},
+					{link_name: "Test Customer 1"}
+				]
+			]}
+		],
+		"Contact 2-Test Customer 1": [
+			{first_name: "Contact 2"},
+			{links: [
+				[
+					{link_doctype: "Customer"},
+					{link_name: "Test Customer 1"}
+				]
+			]}
+		],
+		"Contact 1-Test Customer 2": [
+			{first_name: "Contact 1"},
+			{links: [
+				[
+					{link_doctype: "Customer"},
+					{link_name: "Test Customer 2"}
+				]
+			]}
+		],
+		"Contact 2-Test Customer 2": [
+			{first_name: "Contact 2"},
+			{links: [
+				[
+					{link_doctype: "Customer"},
+					{link_name: "Test Customer 2"}
+				]
+			]}
+		],
+	},
+	"Price List": {
+		"Test-Buying-USD": [
+			{price_list_name: "Test-Buying-USD"},
+			{currency: "USD"},
+			{buying: "1"}
+		],
+		"Test-Buying-EUR": [
+			{price_list_name: "Test-Buying-EUR"},
+			{currency: "EUR"},
+			{buying: "1"}
+		],
+		"Test-Selling-USD": [
+			{price_list_name: "Test-Selling-USD"},
+			{currency: "USD"},
+			{selling: "1"}
+		],
+		"Test-Selling-EUR": [
+			{price_list_name: "Test-Selling-EUR"},
+			{currency: "EUR"},
+			{selling: "1"}
+		],
+	},
+	"Terms and Conditions": {
+		"Test Term 1": [
+			{title: "Test Term 1"}
+		],
+		"Test Term 2": [
+			{title: "Test Term 2"}
+		]
+	},
+	"Sales Taxes and Charges Template": {
+		"TEST In State GST": [
+			{title: "TEST In State GST"},
+			{taxes:[
+				[
+					{charge_type:"On Net Total"},
+					{account_head:"CGST - "+frappe.get_abbr(frappe.defaults.get_default("Company")) }
+				],
+				[
+					{charge_type:"On Net Total"},
+					{account_head:"SGST - "+frappe.get_abbr(frappe.defaults.get_default("Company")) }
+				]
+			]}
+		]
 	}
-});
\ No newline at end of file
+});
diff --git a/erpnext/tests/ui/test_sellling.js b/erpnext/tests/ui/test_sellling.js
index 5543a67..f676152 100644
--- a/erpnext/tests/ui/test_sellling.js
+++ b/erpnext/tests/ui/test_sellling.js
@@ -1,29 +1,120 @@
-QUnit.module('sales');
+QUnit.module("sales");
 
-QUnit.test("test quotation", function(assert) {
-	assert.expect(2);
+QUnit.test("test: lead", function (assert) {
+	assert.expect(1);
+	let done = assert.async();
+	let random = frappe.utils.get_random(10);
+	frappe.run_serially([
+		() => frappe.tests.setup_doctype("Lead"),
+		() => frappe.set_route("List", "Lead"),
+		() => frappe.new_doc("Lead"),
+		() => cur_frm.set_value("lead_name", random),
+		() => cur_frm.save(),
+		() => {
+			assert.ok(cur_frm.doc.lead_name.includes(random));
+			return done();
+		}
+	]);
+});
+
+QUnit.test("test: opportunity", function (assert) {
+	assert.expect(1);
 	let done = assert.async();
 	frappe.run_serially([
-		() => frappe.tests.setup_doctype('Customer'),
-		() => frappe.tests.setup_doctype('Item'),
 		() => {
-			return frappe.tests.make('Quotation', [
-				{customer: 'Test Customer 1'},
-				{items: [
-					[
-						{'item_code': 'Test Product 1'},
-						{'qty': 5}
+			return frappe.tests.make("Opportunity", [{
+				enquiry_from: "Lead"
+			},
+			{
+				lead: "LEAD-00002"
+			}
+			]);
+		},
+		() => {
+			assert.ok(cur_frm.doc.lead === "LEAD-00002");
+			return done();
+		}
+	]);
+});
+
+QUnit.test("test: quotation", function (assert) {
+	assert.expect(18);
+	let done = assert.async();
+	frappe.run_serially([
+		() => frappe.tests.setup_doctype("Customer"),
+		() => frappe.tests.setup_doctype("Item"),
+		() => frappe.tests.setup_doctype("Address"),
+		() => frappe.tests.setup_doctype("Contact"),
+		() => frappe.tests.setup_doctype("Price List"),
+		() => frappe.tests.setup_doctype("Terms and Conditions"),
+		() => frappe.tests.setup_doctype("Sales Taxes and Charges Template"),
+		() => {
+			return frappe.tests.make("Quotation", [{
+				customer: "Test Customer 1"
+			},
+			{
+				items: [
+					[{
+						"item_code": "Test Product 1"
+					},
+					{
+						"qty": 5
+					}
 					]
-				]}
+				]
+			}
 			]);
 		},
 		() => {
 			// get_item_details
-			assert.ok(cur_frm.doc.items[0].item_name=='Test Product 1');
+			assert.ok(cur_frm.doc.items[0].item_name == "Test Product 1", "Added Test Product 1");
 
 			// calculate_taxes_and_totals
-			assert.ok(cur_frm.doc.grand_total==500);
+			assert.ok(cur_frm.doc.grand_total === 500, "Total Amount is correct");
 		},
+		() => cur_frm.set_value("customer_address", "Test1-Billing"),
+		() => cur_frm.set_value("shipping_address_name", "Test1-Warehouse"),
+		() => cur_frm.set_value("contact_person", "Contact 1-Test Customer 1"),
+		() => cur_frm.set_value("currency", "USD"),
+		() => frappe.timeout(0.3),
+		() => cur_frm.set_value("selling_price_list", "Test-Selling-USD"),
+		() => frappe.timeout(0.5),
+		() => cur_frm.doc.items[0].rate = 200,
+		() => frappe.timeout(0.3),
+		() => cur_frm.set_value("tc_name", "Test Term 1"),
+		() => cur_frm.set_value("taxes_and_charges", "TEST In State GST"),
+		() => frappe.timeout(0.3),
+		() => cur_frm.save(),
+		() => {
+			// Check Address and Contact Info
+			assert.ok(cur_frm.doc.address_display.includes("Billing Street 1"), "Address Changed");
+			assert.ok(cur_frm.doc.shipping_address.includes("Warehouse Street 1"), "Address Changed");
+			assert.ok(cur_frm.doc.contact_display == "Contact 1", "Contact info changed");
+
+			// Check Currency
+			assert.ok(cur_frm.doc_currency == "USD", "Currency Changed");
+			assert.ok(cur_frm.doc.selling_price_list == "Test-Selling-USD", "Price List Changed");
+			assert.ok(cur_frm.doc.items[0].rate == 200, "Price Changed Manually");
+			assert.ok(cur_frm.doc.total == 1000, "New Total Calculated");
+
+			// Check Terms and Condtions
+			assert.ok(cur_frm.doc.tc_name == "Test Term 1", "Terms and Conditions Checked");
+
+			// Check Taxes
+			assert.ok(cur_frm.doc.taxes[0].account_head.includes("CGST"));
+			assert.ok(cur_frm.doc.taxes[1].account_head.includes("SGST"));
+			assert.ok(cur_frm.doc.grand_total == 1180, "Tax Amount Added to Total");
+			assert.ok(cur_frm.doc.taxes_and_charges == "TEST In State GST", "Tax Template Selected");
+		},
+		() => frappe.timeout(0.3),
+		() => cur_frm.print_doc(),
+		() => frappe.timeout(1),
+		() => assert.ok($('.btn-print-print').is(':visible'), "Print Format Available"),
+		() => assert.ok(RegExp(/QTN-\d\d\d\d\d/g).test($("#header-html small").text())),
+		() => assert.ok($(".important .text-right.value").text().includes("$ 1,180.00")),
+		() => assert.ok($(".section-break+ .section-break .column-break:nth-child(1) .data-field:nth-child(1) .value").text().includes("Billing Street 1"), "Print Preview Works As Expected"),
+		() => frappe.timeout(0.3),
+		() => cur_frm.print_doc(),
 		() => done()
 	]);
-});
+});
\ No newline at end of file