fixes to style, app boilerplate and selenium testing
This commit is contained in:
parent
902954ad24
commit
7cf586dcd4
6 changed files with 87 additions and 49 deletions
BIN
frappe/public/images/grid-pattern.png
Normal file
BIN
frappe/public/images/grid-pattern.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 179 B |
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// MIT License. See license.txt
|
||||
// MIT License. See license.txt
|
||||
|
||||
/*
|
||||
opts:
|
||||
|
|
@ -14,13 +14,12 @@ frappe.provide('frappe.ui.toolbar');
|
|||
frappe.ui.toolbar.SelectorDialog = Class.extend({
|
||||
init: function(opts) {
|
||||
this.opts = opts;
|
||||
this.make_dialog();
|
||||
this.make_dialog();
|
||||
this.bind_events();
|
||||
},
|
||||
make_dialog: function() {
|
||||
this.dialog = new frappe.ui.Dialog({
|
||||
title: this.opts.title,
|
||||
width: 300,
|
||||
fields: [
|
||||
{fieldtype:'Select', fieldname:'doctype', options:'Select...', label:__('Select Type')},
|
||||
{fieldtype:'Button', label:'Go', fieldname:'go'}
|
||||
|
|
@ -32,24 +31,24 @@ frappe.ui.toolbar.SelectorDialog = Class.extend({
|
|||
},
|
||||
bind_events: function() {
|
||||
var me = this;
|
||||
|
||||
|
||||
// on go
|
||||
$(this.dialog.fields_dict.go.input).click(function() {
|
||||
if(!me.dialog.display) return;
|
||||
me.dialog.hide();
|
||||
me.opts.execute(me.dialog.fields_dict.doctype.get_value());
|
||||
});
|
||||
|
||||
|
||||
// on change
|
||||
$(this.dialog.fields_dict.doctype.input).change(function() {
|
||||
me.dialog.fields_dict.go.input.click();
|
||||
}).keypress(function(ev) {
|
||||
if(ev.which==13) {
|
||||
me.dialog.fields_dict.go.input.click();
|
||||
me.dialog.fields_dict.go.input.click();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
show: function() {
|
||||
this.dialog.show();
|
||||
|
|
@ -58,12 +57,12 @@ frappe.ui.toolbar.SelectorDialog = Class.extend({
|
|||
},
|
||||
set_values: function(lst) {
|
||||
// convert to labels
|
||||
for(var i=0;i<lst.length;i++)
|
||||
for(var i=0;i<lst.length;i++)
|
||||
lst[i]={label:__(lst[i]), value:lst[i]};
|
||||
|
||||
|
||||
// set values
|
||||
var sel = this.dialog.fields_dict.doctype.input;
|
||||
$(sel).empty().add_options(lst.sort(function(a, b) {
|
||||
$(sel).empty().add_options(lst.sort(function(a, b) {
|
||||
return (a.label > b.label ? 1 : -1) }));
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
{% if doc.apply_style %}
|
||||
{% if doc.at_import %}
|
||||
{{ doc.at_import }}
|
||||
{% endif %}
|
||||
|
|
@ -235,3 +236,4 @@ hr {
|
|||
/* User CSS */
|
||||
{{ doc.add_css }}
|
||||
{%- endif %}
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -108,12 +108,12 @@ app_version = "0.0.1"
|
|||
# ------------------
|
||||
|
||||
# include js, css files in header of desk.html
|
||||
# app_include_css = "/assets/{app_name}/{app_name}.css"
|
||||
# app_include_js = "/assets/{app_name}/{app_name}.js"
|
||||
# app_include_css = "/assets/{app_name}/css/{app_name}.css"
|
||||
# app_include_js = "/assets/{app_name}/js/{app_name}.js"
|
||||
|
||||
# include js, css files in header of web template
|
||||
# web_include_css = "/assets/{app_name}/{app_name}.css"
|
||||
# web_include_js = "/assets/{app_name}/{app_name}.js"
|
||||
# web_include_css = "/assets/{app_name}/css/{app_name}.css"
|
||||
# web_include_js = "/assets/{app_name}/js/{app_name}.js"
|
||||
|
||||
# Installation
|
||||
# ------------
|
||||
|
|
@ -131,30 +131,30 @@ app_version = "0.0.1"
|
|||
# -----------
|
||||
# Permissions evaluated in scripted ways
|
||||
|
||||
# permission_query_conditions = {
|
||||
# permission_query_conditions = {{
|
||||
# "Event": "frappe.core.doctype.event.event.get_permission_query_conditions",
|
||||
# }
|
||||
# }}
|
||||
#
|
||||
# has_permission = {
|
||||
# has_permission = {{
|
||||
# "Event": "frappe.core.doctype.event.event.has_permission",
|
||||
# }
|
||||
# }}
|
||||
|
||||
# Document Events
|
||||
# ---------------
|
||||
# Hook on document methods and events
|
||||
|
||||
# doc_events = {
|
||||
# "*": {
|
||||
# doc_events = {{
|
||||
# "*": {{
|
||||
# "on_update": "method",
|
||||
# "on_cancel": "method",
|
||||
# "on_trash": "method"
|
||||
# }
|
||||
# }
|
||||
# }}
|
||||
# }}
|
||||
|
||||
# Scheduled Tasks
|
||||
# ---------------
|
||||
|
||||
# scheduler_events = {
|
||||
# scheduler_events = {{
|
||||
# "all": [
|
||||
# "{app_name}.tasks.all"
|
||||
# ],
|
||||
|
|
@ -170,7 +170,7 @@ app_version = "0.0.1"
|
|||
# "monthly": [
|
||||
# "{app_name}.tasks.monthly"
|
||||
# ]
|
||||
# }
|
||||
# }}
|
||||
|
||||
# Testing
|
||||
# -------
|
||||
|
|
|
|||
|
|
@ -7,42 +7,52 @@ from selenium.webdriver.common.keys import Keys
|
|||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support.select import Select
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.common.exceptions import TimeoutException
|
||||
from urllib import unquote
|
||||
import time, frappe, subprocess
|
||||
import time, subprocess
|
||||
import signal
|
||||
import sys
|
||||
|
||||
host = "http://localhost:8888"
|
||||
host = "http://localhost"
|
||||
pipe = None
|
||||
driver = None
|
||||
verbose = None
|
||||
host = None
|
||||
port = "8888"
|
||||
_driver = None
|
||||
_verbose = None
|
||||
logged_in = False
|
||||
cur_route = False
|
||||
input_wait = 0
|
||||
|
||||
def start(_verbose=None):
|
||||
global driver, verbose
|
||||
verbose = _verbose
|
||||
def start(verbose=None, driver="PhantomJS"):
|
||||
global _driver, _verbose
|
||||
_verbose = verbose
|
||||
|
||||
start_test_server(verbose)
|
||||
driver = webdriver.PhantomJS()
|
||||
_driver = getattr(webdriver, driver)()
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
||||
def signal_handler(signal, frame):
|
||||
close()
|
||||
sys.exit(0)
|
||||
|
||||
def start_test_server(verbose):
|
||||
global pipe
|
||||
pipe = subprocess.Popen(["frappe", "--serve", "--port", "8888"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
pipe = subprocess.Popen(["frappe", "--serve", "--port", port], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
#time.sleep(5)
|
||||
while not pipe.stderr.readline():
|
||||
time.sleep(0.5)
|
||||
if verbose:
|
||||
print "Test server started"
|
||||
|
||||
def get(url):
|
||||
driver.get(url)
|
||||
_driver.get(url)
|
||||
|
||||
def login(wait_for_id="#page-desktop"):
|
||||
global logged_in
|
||||
if logged_in:
|
||||
return
|
||||
get(host + "/login")
|
||||
get(host + ":" + port + "/login")
|
||||
wait("#login_email")
|
||||
set_input("#login_email", "Administrator")
|
||||
set_input("#login_password", "admin" + Keys.RETURN)
|
||||
|
|
@ -87,12 +97,16 @@ def add_child(fieldname):
|
|||
def find(selector, everywhere=False):
|
||||
if cur_route and not everywhere:
|
||||
selector = cur_route + " " + selector
|
||||
return driver.find_elements_by_css_selector(selector)
|
||||
return _driver.find_elements_by_css_selector(selector)
|
||||
|
||||
def set_field(fieldname, value):
|
||||
set_input('input[data-fieldname="{0}"]'.format(fieldname), value + Keys.TAB)
|
||||
wait_for_ajax()
|
||||
time.sleep(0.5)
|
||||
|
||||
def set_select(fieldname, value):
|
||||
select = Select(find('select[data-fieldname="{0}"]'.format(fieldname))[0])
|
||||
select.select_by_value(value)
|
||||
wait_for_ajax()
|
||||
|
||||
def primary_action():
|
||||
find(".appframe-titlebar .btn-primary")[0].click()
|
||||
|
|
@ -117,9 +131,9 @@ def wait(selector, everywhere=False):
|
|||
if cur_route and not everywhere:
|
||||
selector = cur_route + " " + selector
|
||||
try:
|
||||
elem = WebDriverWait(driver, 10).until(
|
||||
elem = WebDriverWait(_driver, 20).until(
|
||||
EC.presence_of_element_located((By.CSS_SELECTOR, selector)))
|
||||
if verbose:
|
||||
if _verbose:
|
||||
print "found " + selector
|
||||
except TimeoutException:
|
||||
print "not found " + selector
|
||||
|
|
@ -130,9 +144,14 @@ def set_input(selector, text):
|
|||
elem = find(selector)[0]
|
||||
elem.clear()
|
||||
elem.send_keys(text)
|
||||
if input_wait:
|
||||
time.sleep(input_wait)
|
||||
|
||||
def close():
|
||||
global driver, pipe
|
||||
driver.quit()
|
||||
pipe.kill()
|
||||
driver = pipe = None
|
||||
global _driver, pipe
|
||||
print "closing selenium"
|
||||
if _driver:
|
||||
_driver.quit()
|
||||
if pipe:
|
||||
pipe.kill()
|
||||
_driver = pipe = None
|
||||
|
|
|
|||
|
|
@ -1,13 +1,29 @@
|
|||
{
|
||||
"allow_attach": 1,
|
||||
"creation": "2013-03-25 16:01:33.000000",
|
||||
"creation": "2013-03-25 16:01:33",
|
||||
"description": "Set your background color, font and image (tiled)",
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "enable",
|
||||
"fieldtype": "Section Break",
|
||||
"in_list_view": 1,
|
||||
"label": "Enable",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "This must be checked if Style Settings are applicable",
|
||||
"fieldname": "apply_style",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Apply Style",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "color",
|
||||
"fieldtype": "Section Break",
|
||||
"in_list_view": 1,
|
||||
"label": "Color",
|
||||
"permlevel": 0
|
||||
},
|
||||
|
|
@ -15,6 +31,7 @@
|
|||
"description": "If image is selected, color will be ignored (attach first)",
|
||||
"fieldname": "background_image",
|
||||
"fieldtype": "Select",
|
||||
"in_list_view": 1,
|
||||
"label": "Background Image",
|
||||
"options": "attach_files:",
|
||||
"permlevel": 0
|
||||
|
|
@ -23,6 +40,7 @@
|
|||
"description": "Solid background color (default light gray)",
|
||||
"fieldname": "background_color",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Background Color",
|
||||
"permlevel": 0
|
||||
},
|
||||
|
|
@ -156,7 +174,7 @@
|
|||
"idx": 1,
|
||||
"issingle": 1,
|
||||
"max_attachments": 1,
|
||||
"modified": "2013-12-20 19:22:48.000000",
|
||||
"modified": "2014-05-03 14:57:55.879426",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "Style Settings",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue