Added first UI tests (#9532)

* [wip]

* [tests] wip

* [ui-tests] first-cut

* [minor] remove old tests
This commit is contained in:
Rushabh Mehta
2017-07-03 11:53:07 +05:30
committed by GitHub
parent 65f6f2a05e
commit 43ef4e9047
14 changed files with 104 additions and 150 deletions

View File

@@ -1,106 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
"""
Run Selenium Tests
Requires a clean install. After reinstalling fresh db, call
frappe --execute erpnext.tests.sel_tests.start
"""
from __future__ import unicode_literals
import frappe
from frappe.utils import sel
import time
def start():
try:
run()
finally:
sel.close()
def run():
def next_slide(idx, selector="next-btn"):
sel.find('[data-slide-id="{0}"] .{1}'.format(idx, selector))[0].click()
sel.wait_for_ajax()
sel.start(verbose=True, driver="Firefox")
sel.input_wait = 0.2
sel.login("#page-setup-wizard")
# slide 1
next_slide("0")
sel.set_field("first_name", "Test")
sel.set_field("last_name", "User")
sel.set_field("email", "test@erpnext.com")
sel.set_field("password", "test")
next_slide("1")
sel.set_select("country", "India")
next_slide("2")
sel.set_field("company_name", "Wind Power LLC")
sel.set_field("fy_start_date", "01-04-2014")
sel.set_field("company_tagline", "Wind Power For Everyone")
next_slide("3")
next_slide("4")
sel.set_field("tax_1", "VAT")
sel.set_field("tax_rate_1", "12.5")
sel.set_field("tax_2", "Service Tax")
sel.set_field("tax_rate_2", "10.36")
next_slide("5")
sel.set_field("customer_1", "Asian Junction")
sel.set_field("customer_contact_1", "January Vaclavik")
sel.set_field("customer_2", "Life Plan Counselling")
sel.set_field("customer_contact_2", "Jana Tobeolisa")
sel.set_field("customer_3", "Two Pesos")
sel.set_field("customer_contact_3", "Satomi Shigeki")
sel.set_field("customer_4", "Intelacard")
sel.set_field("customer_contact_4", "Hans Rasmussen")
next_slide("6")
sel.set_field("item_1", "Wind Turbine A")
sel.set_field("item_2", "Wind Turbine B")
sel.set_field("item_3", "Wind Turbine C")
next_slide("7")
sel.set_field("supplier_1", "Helios Air")
sel.set_field("supplier_contact_1", "Quimey Osorio")
sel.set_field("supplier_2", "Ks Merchandise")
sel.set_field("supplier_contact_2", "Edgarda Salcedo")
sel.set_field("supplier_3", "Eagle Hardware")
sel.set_field("supplier_contact_3", "Hafsteinn Bjarnarsonar")
next_slide("8")
sel.set_field("item_buy_1", "Bearing Pipe")
sel.set_field("item_buy_2", "Bearing Assembly")
sel.set_field("item_buy_3", "Base Plate")
sel.set_field("item_buy_4", "Coil")
next_slide("9", "complete-btn")
sel.wait('[data-state="setup-complete"]')
w = raw_input("quit?")
# complete setup
# new customer
# new supplier
# new item
# sales cycle
# purchase cycle

View File

@@ -1,25 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import unittest, frappe
from frappe.utils import sel
from frappe.utils import formatdate
#selenium_tests = True
# class TestLogin(unittest.TestCase):
# def setUp(self):
# sel.login()
#
# def test_material_request(self):
# sel.new_doc("Stock", "Material Request")
# sel.set_field("company", "_Test Company")
# sel.add_child("items")
# sel.set_field("item_code", "_Test Item")
# sel.set_field("qty", "1")
# sel.set_field("warehouse", "_Test Warehouse - _TC")
# sel.set_field("schedule_date", formatdate())
# sel.done_add_child("items")
# sel.primary_action()
# sel.wait_for_state("clean")

View File

@@ -6,7 +6,6 @@ from six.moves import range
test_records = frappe.get_test_records('Company')
class TestInit(unittest.TestCase):
def test_encode_company_abbr(self):
company = frappe.new_doc("Company")

View File

@@ -0,0 +1,48 @@
$.extend(frappe.test_data, {
'Customer': {
'Test Customer 1': [
{customer_name: 'Test Customer 1'}
],
'Test Customer 2': [
{customer_name: 'Test Customer 2'}
],
'Test Customer 3': [
{customer_name: 'Test Customer 3'}
],
},
'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'},
{is_stock_item: 1},
{standard_rate: 150},
{opening_stock: 200},
],
'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'},
{is_stock_item: 0},
{standard_rate: 200}
],
'Test Service 2': [
{item_code: 'Test Service 2'},
{item_group: 'Services'},
{is_stock_item: 0},
{standard_rate: 300}
]
}
});

View File

@@ -0,0 +1,29 @@
QUnit.module('sales');
QUnit.test("test quotation", function(assert) {
assert.expect(2);
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}
]
]}
]);
},
() => {
// get_item_details
assert.ok(cur_frm.doc.items[0].item_name=='Test Product 1');
// calculate_taxes_and_totals
assert.ok(cur_frm.doc.grand_total==500);
},
() => done()
]);
});