Skip to content

Commit

Permalink
fix: Notification test in Postgres (frappe#7044)
Browse files Browse the repository at this point in the history
  • Loading branch information
netchampfaris authored and adityahase committed Mar 8, 2019
1 parent 94ea028 commit b61a37a
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ matrix:
exclude:
- python: 2.7
env: DB=postgres
- python: 3.6
- python: 2.7
env: TEST_TYPE=ui

install:
Expand Down
10 changes: 7 additions & 3 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ sudo pip install -e ~/bench

rm $TRAVIS_BUILD_DIR/.git/shallow
cd ~/ && bench init frappe-bench --python $(which python) --frappe-path $TRAVIS_BUILD_DIR
cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/
cp -r $TRAVIS_BUILD_DIR/test_sites/test_site_postgres ~/frappe-bench/sites/
cp -r $TRAVIS_BUILD_DIR/test_sites/test_site_ui ~/frappe-bench/sites/
if [[ $DB == 'mariadb' ]]; then
cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/
elif [[ $TEST_TYPE == 'ui' ]]; then
cp -r $TRAVIS_BUILD_DIR/test_sites/test_site_ui ~/frappe-bench/sites/
elif [[ $DB == 'postgres' ]]; then
cp -r $TRAVIS_BUILD_DIR/test_sites/test_site_postgres ~/frappe-bench/sites/
fi
4 changes: 2 additions & 2 deletions .travis/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ if [[ $DB == 'mariadb' ]]; then

elif [[ $TEST_TYPE == 'ui' ]]; then
setup_mariadb_env 'test_site_ui'
bench --site test_site_ui --force restore ./apps/frappe/test_sites/test_site_ui/test_site_ui-database.sql.gz
bench --site test_site_ui migrate
bench --site test_site_ui reinstall --yes
bench --site test_site_ui execute frappe.utils.install.complete_setup_wizard
bench --site test_site_ui scheduler disable
cd apps/frappe && yarn && yarn cypress:run

Expand Down
1 change: 1 addition & 0 deletions cypress/integration/awesome_bar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
context('Awesome Bar', () => {
before(() => {
cy.visit('/login');
cy.login('Administrator', 'qwe');
cy.visit('/desk');
});
Expand Down
36 changes: 19 additions & 17 deletions cypress/integration/table_multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,49 @@ context('Table MultiSelect', () => {
cy.login('Administrator', 'qwe');
});

let todo_description = 'table multiselect' + Math.random().toString().slice(2, 8);
let name = 'table multiselect' + Math.random().toString().slice(2, 8);

it('select value from multiselect dropdown', () => {
cy.visit('/desk#Form/ToDo/New ToDo 1');
cy.fill_field('description', todo_description, 'Text Editor').blur();
cy.get('input[data-fieldname="assign_to"]').focus().as('input');
cy.get('input[data-fieldname="assign_to"] + ul').should('be.visible');
cy.get('@input').type('faris{enter}', { delay: 100 });
cy.get('.frappe-control[data-fieldname="assign_to"] .form-control .tb-selected-value')
cy.new_form('Assignment Rule');
cy.fill_field('__newname', name);
cy.fill_field('document_type', 'ToDo');
cy.fill_field('assign_condition', 'status=="Open"');
cy.get('input[data-fieldname="users"]').focus().as('input');
cy.get('input[data-fieldname="users"] + ul').should('be.visible');
cy.get('@input').type('test{enter}', { delay: 100 });
cy.get('.frappe-control[data-fieldname="users"] .form-control .tb-selected-value')
.first().as('selected-value');
cy.get('@selected-value').should('contain', 'faris@erpnext.com');
cy.get('@selected-value').should('contain', 'test@erpnext.com');

cy.server();
cy.route('POST', '/api/method/frappe.desk.form.save.savedocs').as('save_form');
// trigger save
cy.get('.primary-action').click();
cy.wait('@save_form').its('status').should('eq', 200);
cy.get('@selected-value').should('contain', 'faris@erpnext.com');
cy.get('@selected-value').should('contain', 'test@erpnext.com');
});

it('delete value using backspace', () => {
cy.visit('/desk#List/ToDo/List');
cy.go_to_list('Assignment Rule');
cy.get(`.list-subject:contains("table multiselect")`).last().find('a').click();
cy.get('input[data-fieldname="assign_to"]').focus().type('{backspace}');
cy.get('.frappe-control[data-fieldname="assign_to"] .form-control .tb-selected-value')
cy.get('input[data-fieldname="users"]').focus().type('{backspace}');
cy.get('.frappe-control[data-fieldname="users"] .form-control .tb-selected-value')
.should('not.exist');
});

it('delete value using x', () => {
cy.visit('/desk#List/ToDo/List');
cy.go_to_list('Assignment Rule');
cy.get(`.list-subject:contains("table multiselect")`).last().find('a').click();
cy.get('.frappe-control[data-fieldname="assign_to"] .form-control .tb-selected-value').as('existing_value');
cy.get('.frappe-control[data-fieldname="users"] .form-control .tb-selected-value').as('existing_value');
cy.get('@existing_value').find('.btn-remove').click();
cy.get('@existing_value').should('not.exist');
});

it('navigate to selected value', () => {
cy.visit('/desk#List/ToDo/List');
cy.go_to_list('Assignment Rule');
cy.get(`.list-subject:contains("table multiselect")`).last().find('a').click();
cy.get('.frappe-control[data-fieldname="assign_to"] .form-control .tb-selected-value').as('existing_value');
cy.get('.frappe-control[data-fieldname="users"] .form-control .tb-selected-value').as('existing_value');
cy.get('@existing_value').find('.btn-link-to-form').click();
cy.location('hash').should('contain', 'Form/User/faris@erpnext.com');
cy.location('hash').should('contain', 'Form/User/test@erpnext.com');
});
});
11 changes: 9 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... });
Cypress.Commands.add('login', (email, password) => {
cy.request({
url: '/',
url: '/api/method/login',
method: 'POST',
body: {
cmd: 'login',
usr: email,
pwd: password
}
Expand All @@ -54,3 +53,11 @@ Cypress.Commands.add('fill_field', (fieldname, value, fieldtype='Data') => {
Cypress.Commands.add('awesomebar', (text) => {
cy.get('#navbar-search').type(`${text}{downarrow}{enter}`, { delay: 100 });
});

Cypress.Commands.add('new_form', (doctype) => {
cy.visit(`/desk#Form/${doctype}/New ${doctype} 1`);
});

Cypress.Commands.add('go_to_list', (doctype) => {
cy.visit(`/desk#List/${doctype}/List`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
"collapsible": 0,
"columns": 0,
"fieldname": "users",
"fieldtype": "Table",
"fieldtype": "Table MultiSelect",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
Expand Down Expand Up @@ -449,7 +449,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2019-02-28 17:12:44.413782",
"modified": "2019-03-08 15:13:01.379471",
"modified_by": "Administrator",
"module": "Automation",
"name": "Assignment Rule",
Expand All @@ -476,7 +476,7 @@
"write": 1
}
],
"quick_entry": 1,
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
Expand Down
1 change: 1 addition & 0 deletions frappe/email/doctype/notification/test_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def test_alert_disabled_on_wrong_field(self):
{ "email_by_document_field": "owner" }
]
}).insert()
frappe.db.commit()

event = frappe.new_doc("Event")
event.subject = "test-2",
Expand Down
1 change: 1 addition & 0 deletions frappe/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import frappe
import sqlparse

from frappe import _

RECORDER_INTERCEPT_FLAG = "recorder-intercept"
RECORDER_REQUEST_SPARSE_HASH = "recorder-requests-sparse"
Expand Down
6 changes: 6 additions & 0 deletions frappe/tests/test_website.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def set_request(**kwargs):
builder = EnvironBuilder(**kwargs)
frappe.local.request = Request(builder.get_environ())

def get_html_for_route(route):
set_request(method='GET', path=route)
response = render.render()
html = frappe.safe_decode(response.get_data())
return html

class TestWebsite(unittest.TestCase):

def test_page_load(self):
Expand Down
23 changes: 13 additions & 10 deletions frappe/utils/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,24 @@ def before_tests():
frappe.clear_cache()

# complete setup if missing
from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
if not int(frappe.db.get_single_value('System Settings', 'setup_complete') or 0):
setup_complete({
"language" :"English",
"email" :"[email protected]",
"full_name" :"Test User",
"password" :"test",
"country" :"United States",
"timezone" :"America/New_York",
"currency" :"USD"
})
complete_setup_wizard()

frappe.db.commit()
frappe.clear_cache()

def complete_setup_wizard():
from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
setup_complete({
"language" :"English",
"email" :"[email protected]",
"full_name" :"Test User",
"password" :"test",
"country" :"United States",
"timezone" :"America/New_York",
"currency" :"USD"
})

def import_country_and_currency():
from frappe.geo.country_info import get_all
from frappe.utils import update_progress_bar
Expand Down
Binary file not shown.

0 comments on commit b61a37a

Please sign in to comment.