Fixed multiple ui test cases

This commit is contained in:
Nabin Hait 2017-09-07 19:16:38 +05:30
parent 07b713121b
commit d4e57a38a4
6 changed files with 38 additions and 67 deletions

View File

@ -1,16 +1,15 @@
QUnit.test("test:POS Profile", function(assert) {
assert.expect(1);
QUnit.test("test:Sales Invoice", function(assert) {
assert.expect(3);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make("POS Profile", [
{naming_series: "SINV"},
{company: "Test Company"},
{country: "India"},
{currency: "INR"},
{write_off_account: "Write Off - TC"},
{write_off_cost_center: "Main - TC"},
{write_off_account: "Write Off - FT"},
{write_off_cost_center: "Main - FT"},
{payments: [
[
{"default": 1},
@ -24,19 +23,10 @@ QUnit.test("test:POS Profile", function(assert) {
() => {
assert.equal(cur_frm.doc.payments[0].default, 1, "Default mode of payment tested");
},
() => done()
]);
});
QUnit.test("test:Sales Invoice", function(assert) {
assert.expect(2);
let done = assert.async();
frappe.run_serially([
() => frappe.timeout(1),
() => {
return frappe.tests.make("Sales Invoice", [
{customer: "Test Customer 2"},
{company: "Test Company"},
{is_pos: 1},
{posting_date: frappe.datetime.get_today()},
{due_date: frappe.datetime.get_today()},
@ -44,7 +34,7 @@ QUnit.test("test:Sales Invoice", function(assert) {
[
{"item_code": "Test Product 1"},
{"qty": 5},
{"warehouse":'Stores - TC'}
{"warehouse":'Stores - FT'}
]]
}
]);

View File

@ -1,23 +0,0 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Sales Order", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially('Sales Order', [
// insert a new Sales Order
() => frappe.tests.make([
// values to be set
{key: 'value'}
]),
() => {
assert.equal(cur_frm.doc.key, 'value');
},
() => done()
]);
});

View File

@ -1,7 +1,7 @@
QUnit.module('Sales Order');
QUnit.test("test sales order", function(assert) {
assert.expect(8);
assert.expect(10);
let done = assert.async();
frappe.run_serially([
() => {
@ -12,7 +12,7 @@ QUnit.test("test sales order", function(assert) {
{'delivery_date': frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)},
{'qty': 5},
{'item_code': 'Test Product 4'},
{'uom': 'unit'},
{'uom': 'Nos'},
{'margin_type': 'Percentage'},
{'discount_percentage': 10},
]
@ -33,7 +33,7 @@ QUnit.test("test sales order", function(assert) {
{additional_discount_percentage:10}
]);
},
() => cur_frm.save(),
() => frappe.timeout(1),
() => {
// get_item_details
assert.ok(cur_frm.doc.items[0].item_name=='Test Product 4', "Item name correct");
@ -42,15 +42,19 @@ QUnit.test("test sales order", function(assert) {
// 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");
// calculate totals
assert.ok(cur_frm.doc.items[0].price_list_rate==1000, "Item 1 price_list_rate");
assert.ok(cur_frm.doc.total== 4500, "total correct ");
assert.ok(cur_frm.doc.rounded_total== 4414.5, "rounded total correct ");
assert.ok(cur_frm.doc.items[0].price_list_rate==90, "Item 1 price_list_rate");
assert.ok(cur_frm.doc.total== 405, "total correct ");
assert.ok(cur_frm.doc.net_total== 364.5, "net total correct ");
assert.ok(cur_frm.doc.grand_total== 397.30, "grand total correct ");
assert.ok(cur_frm.doc.rounded_total== 397.30, "rounded total correct ");
},
() => cur_frm.save(),
() => frappe.timeout(1),
() => cur_frm.print_doc(),
() => frappe.timeout(1),
() => {
assert.ok($('.btn-print-print').is(':visible'), "Print Format Available");
frappe.timeout(1);
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");
},
() => cur_frm.print_doc(),

View File

@ -1,21 +1,3 @@
QUnit.test("test:POS Settings", function(assert) {
assert.expect(1);
let done = assert.async();
frappe.run_serially([
() => frappe.set_route('Form', 'POS Settings'),
() => cur_frm.set_value('is_online', 1),
() => frappe.timeout(0.2),
() => cur_frm.save(),
() => frappe.timeout(1),
() => frappe.ui.toolbar.clear_cache(),
() => frappe.timeout(2),
() => assert.ok(cur_frm.doc.is_online==1, "Enabled online"),
() => frappe.timeout(2),
() => done()
]);
});
QUnit.test("test:Point of Sales", function(assert) {
assert.expect(1);
let done = assert.async();
@ -29,7 +11,7 @@ QUnit.test("test:Point of Sales", function(assert) {
() => frappe.timeout(2),
() => frappe.click_link('Test Product 2'),
() => frappe.timeout(0.2),
() => frappe.click_element(`.cart-items [title="Test Product 2"]`),
() => frappe.click_element(`.cart-items [data-item-code="Test Product 2"]`),
() => frappe.timeout(0.2),
() => frappe.click_element(`.number-pad [data-value="Rate"]`),
() => frappe.timeout(0.2),
@ -49,7 +31,7 @@ QUnit.test("test:Point of Sales", function(assert) {
() => frappe.timeout(0.2),
() => frappe.click_button('Submit'),
() => frappe.click_button('Yes'),
() => frappe.timeout(5),
() => frappe.timeout(3),
() => assert.ok(cur_frm.doc.docstatus==1, "Sales invoice created successfully"),
() => done()
]);

View File

@ -0,0 +1,17 @@
QUnit.test("test:POS Settings", function(assert) {
assert.expect(1);
let done = assert.async();
frappe.run_serially([
() => frappe.set_route('Form', 'POS Settings'),
() => cur_frm.set_value('is_online', 1),
() => frappe.timeout(0.2),
() => cur_frm.save(),
() => frappe.timeout(1),
() => frappe.ui.toolbar.clear_cache(),
() => frappe.timeout(10),
() => assert.ok(cur_frm.doc.is_online==1, "Enabled online"),
() => frappe.timeout(2),
() => done()
]);
});

View File

@ -50,7 +50,8 @@ erpnext/schools/doctype/room/test_room.js
erpnext/schools/doctype/instructor/test_instructor.js
erpnext/stock/doctype/warehouse/test_warehouse.js
erpnext/manufacturing/doctype/production_order/test_production_order.js #long
erpnext/selling/page/point_of_sale/test_point_of_sale.js
erpnext/selling/page/point_of_sale/tests/test_pos_settings.js
erpnext/selling/page/point_of_sale/tests/test_point_of_sale.js
erpnext/accounts/page/pos/test_pos.js
erpnext/selling/doctype/product_bundle/test_product_bundle.js
erpnext/stock/doctype/delivery_note/test_delivery_note.js