# HG changeset patch # User Atul Varma # Date 1272629410 25200 # Node ID 8335b1abc2959dc1a80b173dd801ae29ba418dab # Parent 3ad618d3370f11dd7ce5abb90a1ce77038ad9601 added verifications to system tests diff -r 3ad618d3370f -r 8335b1abc295 js/black-box.js --- a/js/black-box.js Fri Apr 30 04:52:17 2010 -0700 +++ b/js/black-box.js Fri Apr 30 05:10:10 2010 -0700 @@ -22,13 +22,24 @@ }, _$: function _$(sel) { var query = this.jQuery(sel); + if (query.length == 0) throw new Error("selector yields no results: " + sel); if (query.length > 1) throw new Error("selector yields " + query.length + " results instead of 1: " + sel); + return query; }, + verifyVisible: function verifyVisible(field) { + this.queue.push( + function() { + var query = this.jQuery(field + ":visible"); + + if (query.length == 0) + throw new Error("selector not visible: " + field); + }); + }, type: function type(field, value) { this.queue.push(function() { this._$(field).val(value); }); }, @@ -41,18 +52,22 @@ auto.type("#login .username", "john@doe.com"); auto.type("#login .password", "test"); auto.submit("#login form"); + auto.verifyVisible("#header .requires-login"); + auto.verifyVisible("#header .requires-auth-login"); } function testLoginWithNoPassword(auto) { auto.type("#login .username", "john@doe.com"); auto.type("#login .password", ""); - auto.submit("#login form"); + auto.submit("#login form"); + auto.verifyVisible("#header .requires-login"); } function testLoginWithIncorrectPassword(auto) { auto.type("#login .username", "john@doe.com"); auto.type("#login .password", "u"); auto.submit("#login form"); + auto.verifyVisible("#errors .bugzilla-api-error"); } function setDashboardLoaded(delegate, window) {