Merge "Tests pass in languages other than English"
This commit is contained in:
commit
efe64e0e8e
|
@ -27,25 +27,33 @@ test("Footer count update", function () {
|
|||
var table_count = table.find("span.table_count");
|
||||
var rows = tbody.find('tr');
|
||||
|
||||
// The following function returns the first set of consecutive numbers.
|
||||
// This is allows you to match an inner numeric value regardless of
|
||||
// the language and regardless of placement within the phrase.
|
||||
// If you want to match '4' for your numeric value, the following are ok:
|
||||
// "there are 4 lights", "4 lights there are", "lights there are 4" but
|
||||
// not "there are 14 lights".
|
||||
var get_consec_nums = function(str) { return (str.match(/\d+/) || [""])[0]; };
|
||||
|
||||
horizon.datatables.update_footer_count(table);
|
||||
notEqual(table_count.text().indexOf('4 items'), -1, "Initial count is correct");
|
||||
equal(get_consec_nums(table_count.text()), '4', "Initial count is correct");
|
||||
|
||||
// hide rows
|
||||
rows.first().hide();
|
||||
rows.first().next().hide();
|
||||
horizon.datatables.update_footer_count(table);
|
||||
notEqual(table_count.text().indexOf('2 items'), -1, "Count correct after hiding two rows");
|
||||
equal(get_consec_nums(table_count.text()), '2', "Count correct after hiding two rows");
|
||||
|
||||
// show a row
|
||||
rows.first().next().show();
|
||||
horizon.datatables.update_footer_count(table);
|
||||
notEqual(table_count.text().indexOf('3 items'), -1, "Count correct after showing one row");
|
||||
equal(get_consec_nums(table_count.text()), '3', "Count correct after showing one row");
|
||||
|
||||
// add rows
|
||||
$('<tr><td>cat3</td></tr>"').appendTo(tbody);
|
||||
$('<tr><td>cat4</td></tr>"').appendTo(tbody);
|
||||
horizon.datatables.update_footer_count(table);
|
||||
notEqual(table_count.text().indexOf('5 items'), -1, "Count correct after adding two rows");
|
||||
equal(get_consec_nums(table_count.text()), '5', "Count correct after adding two rows");
|
||||
});
|
||||
|
||||
test("Formset reenumerate rows", function () {
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block modal-footer %}
|
||||
<button type="submit" class="btn btn-primary pull-right">{% trans "Sign In" %}</button>
|
||||
<button id="loginBtn" type="submit" class="btn btn-primary pull-right">{% trans "Sign In" %}</button>
|
||||
{% endblock %}
|
||||
|
|
|
@ -611,16 +611,14 @@ class SeleniumTests(test.SeleniumAdminTestCase):
|
|||
ignored_exceptions=[socket_timeout])
|
||||
wait.until(lambda x: self.selenium.find_element_by_id("id_name"))
|
||||
|
||||
body = self.selenium.find_element_by_tag_name("body")
|
||||
self.assertFalse("Passwords do not match" in body.text,
|
||||
"Error message should not be visible at loading time")
|
||||
self.assertFalse(self._is_element_present("id_confirm_password_error"),
|
||||
"Password error element shouldn't yet exist.")
|
||||
self.selenium.find_element_by_id("id_name").send_keys("Test User")
|
||||
self.selenium.find_element_by_id("id_password").send_keys("test")
|
||||
self.selenium.find_element_by_id("id_confirm_password").send_keys("te")
|
||||
self.selenium.find_element_by_id("id_email").send_keys("a@b.com")
|
||||
body = self.selenium.find_element_by_tag_name("body")
|
||||
self.assertTrue("Passwords do not match" in body.text,
|
||||
"Error message not found in body")
|
||||
self.assertTrue(self._is_element_present("id_confirm_password_error"),
|
||||
"Couldn't find password error element.")
|
||||
|
||||
@test.create_stubs({api.keystone: ('tenant_list',
|
||||
'user_get',
|
||||
|
@ -638,12 +636,17 @@ class SeleniumTests(test.SeleniumAdminTestCase):
|
|||
|
||||
self.selenium.get("%s%s" % (self.live_server_url, USER_UPDATE_URL))
|
||||
|
||||
body = self.selenium.find_element_by_tag_name("body")
|
||||
self.assertFalse("Passwords do not match" in body.text,
|
||||
"Error message should not be visible at loading time")
|
||||
self.assertFalse(self._is_element_present("id_confirm_password_error"),
|
||||
"Password error element shouldn't yet exist.")
|
||||
self.selenium.find_element_by_id("id_password").send_keys("test")
|
||||
self.selenium.find_element_by_id("id_confirm_password").send_keys("te")
|
||||
self.selenium.find_element_by_id("id_email").clear()
|
||||
body = self.selenium.find_element_by_tag_name("body")
|
||||
self.assertTrue("Passwords do not match" in body.text,
|
||||
"Error message not found in body")
|
||||
self.assertTrue(self._is_element_present("id_confirm_password_error"),
|
||||
"Couldn't find password error element.")
|
||||
|
||||
def _is_element_present(self, element_id):
|
||||
try:
|
||||
self.selenium.find_element_by_id(element_id)
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
|
|
@ -18,5 +18,6 @@ from horizon.test import helpers as test
|
|||
class BrowserTests(test.SeleniumTestCase):
|
||||
def test_splash(self):
|
||||
self.selenium.get(self.live_server_url)
|
||||
button = self.selenium.find_element_by_tag_name("button")
|
||||
self.assertEqual("Sign In", button.text)
|
||||
button = self.selenium.find_element_by_id("loginBtn")
|
||||
# Ensure button has something; must be language independent.
|
||||
self.assertTrue(len(button.text) > 0)
|
||||
|
|
Loading…
Reference in New Issue