comparison js/black-box.js @ 109:8335b1abc295

added verifications to system tests
author Atul Varma <avarma@mozilla.com>
date Fri, 30 Apr 2010 05:10:10 -0700
parents 3ad618d3370f
children 4567dc69cb3e
comparison
equal deleted inserted replaced
108:3ad618d3370f 109:8335b1abc295
20 else 20 else
21 this.onDone(); 21 this.onDone();
22 }, 22 },
23 _$: function _$(sel) { 23 _$: function _$(sel) {
24 var query = this.jQuery(sel); 24 var query = this.jQuery(sel);
25
25 if (query.length == 0) 26 if (query.length == 0)
26 throw new Error("selector yields no results: " + sel); 27 throw new Error("selector yields no results: " + sel);
27 if (query.length > 1) 28 if (query.length > 1)
28 throw new Error("selector yields " + query.length + 29 throw new Error("selector yields " + query.length +
29 " results instead of 1: " + sel); 30 " results instead of 1: " + sel);
31
30 return query; 32 return query;
33 },
34 verifyVisible: function verifyVisible(field) {
35 this.queue.push(
36 function() {
37 var query = this.jQuery(field + ":visible");
38
39 if (query.length == 0)
40 throw new Error("selector not visible: " + field);
41 });
31 }, 42 },
32 type: function type(field, value) { 43 type: function type(field, value) {
33 this.queue.push(function() { this._$(field).val(value); }); 44 this.queue.push(function() { this._$(field).val(value); });
34 }, 45 },
35 submit: function submit(form) { 46 submit: function submit(form) {
39 50
40 function testLoginWithCorrectPassword(auto) { 51 function testLoginWithCorrectPassword(auto) {
41 auto.type("#login .username", "john@doe.com"); 52 auto.type("#login .username", "john@doe.com");
42 auto.type("#login .password", "test"); 53 auto.type("#login .password", "test");
43 auto.submit("#login form"); 54 auto.submit("#login form");
55 auto.verifyVisible("#header .requires-login");
56 auto.verifyVisible("#header .requires-auth-login");
44 } 57 }
45 58
46 function testLoginWithNoPassword(auto) { 59 function testLoginWithNoPassword(auto) {
47 auto.type("#login .username", "john@doe.com"); 60 auto.type("#login .username", "john@doe.com");
48 auto.type("#login .password", ""); 61 auto.type("#login .password", "");
49 auto.submit("#login form"); 62 auto.submit("#login form");
63 auto.verifyVisible("#header .requires-login");
50 } 64 }
51 65
52 function testLoginWithIncorrectPassword(auto) { 66 function testLoginWithIncorrectPassword(auto) {
53 auto.type("#login .username", "john@doe.com"); 67 auto.type("#login .username", "john@doe.com");
54 auto.type("#login .password", "u"); 68 auto.type("#login .password", "u");
55 auto.submit("#login form"); 69 auto.submit("#login form");
70 auto.verifyVisible("#errors .bugzilla-api-error");
56 } 71 }
57 72
58 function setDashboardLoaded(delegate, window) { 73 function setDashboardLoaded(delegate, window) {
59 window.onDashboardLoaded = function onDashboardLoaded(dashboard, options) { 74 window.onDashboardLoaded = function onDashboardLoaded(dashboard, options) {
60 $(dashboard).error( 75 $(dashboard).error(