Permalink
Browse files

Make sure the testSetup.setup fixtures exist before dereferencing them.

  • Loading branch information...
1 parent 734f181 commit 61f61ceaf0428df9914a908c871aa4d2dd5820a2 @shane-tomlinson shane-tomlinson committed Nov 19, 2012
@@ -25,15 +25,17 @@ var browser,
runner.run(module, {
"setup all the things": function(done) {
testSetup.setup({ b:1, e:2 }, function(err, fix) {
- browser = fix.b[0];
- primaryEmail = {
- email: fix.e[0],
- pass: fix.e[0].split('@')[0],
- };
- secondPrimaryEmail = {
- email: fix.e[1],
- pass: fix.e[1].split('@')[0],
- };
+ if (fix) {
+ browser = fix.b[0];
+ primaryEmail = {
+ email: fix.e[0],
+ pass: fix.e[0].split('@')[0],
+ };
+ secondPrimaryEmail = {
+ email: fix.e[1],
+ pass: fix.e[1].split('@')[0],
+ };
+ }
done(err);
});
},
@@ -25,12 +25,14 @@ var browser,
runner.run(module, {
"setup all the things": function(done) {
testSetup.setup({ b:1, p:1, e:1 }, function(err, fix) {
- browser = fix.b[0];
- secondaryEmail = fix.p[0];
- primaryEmail = {
- email: fix.e[0],
- pass: fix.e[0].split('@')[0],
- };
+ if (fix) {
+ browser = fix.b[0];
+ secondaryEmail = fix.p[0];
+ primaryEmail = {
+ email: fix.e[0],
+ pass: fix.e[0].split('@')[0],
+ };
+ }
done(err);
});
},
@@ -25,9 +25,11 @@ var browser,
function setup(done) {
emails = [];
user.getVerifiedUser(function(err, info) {
- browser = info.browser;
- secondaryEmail = saveEmail(info.email);
- secondaryPassword = info.password;
+ if (info) {
+ browser = info.browser;
+ secondaryEmail = saveEmail(info.email);
+ secondaryPassword = info.password;
+ }
done(err);
});
}
@@ -29,10 +29,12 @@ var browser, secondBrowser, testUser;
runner.run(module, {
"setup tests": function(done) {
testSetup.setup({browsers: 2, personatestusers: 1}, function(err, fixtures) {
- browser = fixtures.browsers[0];
- secondBrowser = fixtures.browsers[1];
- testUser = fixtures.personatestusers[0];
- done();
+ if (fixtures) {
+ browser = fixtures.browsers[0];
+ secondBrowser = fixtures.browsers[1];
+ testUser = fixtures.personatestusers[0];
+ }
+ done(err);
});
},
"create a new selenium session": function(done) {
@@ -52,10 +52,16 @@ var browser;
runner.run(module, {
"create a new selenium session": function(done) {
testSetup.setup({b:1}, function(err, fix) {
- browser = fix.b[0];
- testSetup.newBrowserSession(browser, done);
+ if (fix) {
+ browser = fix.b[0];
+ }
+
+ done(err);
});
},
+ "start the session": function(done) {
+ testSetup.newBrowserSession(browser, done);
+ },
"open the frontend test url": function(done) {
browser.get(frontendTestUrl, done);
},
@@ -78,7 +84,7 @@ runner.run(module, {
//XXX should have a better way to save off the elapsed time, test
// counts, pass/fail, etc., somewhere better than just dumping it in the
// console. Maybe set custom-data for Sauce after the job completes?
- // - Should have a mode here where we just return the `res` back to
+ // - Should have a mode here where we just return the `res` back to
// a parallel test runner, which can then make assertions about
// all the results.
//console.dir(res); // commented out because stray JSON makes SAX parser, hence Jenkins, cry
@@ -94,7 +100,7 @@ runner.run(module, {
"shut down": function(done) {
browser.quit(done);
}
-},
+},
{
suiteName: path.basename(__filename),
cleanup: function(done) { testSetup.teardown(done) }
@@ -32,10 +32,12 @@ var startup = function(b, email, cb) {
var setup = {
"setup stuff": function(done) {
testSetup.setup({browsers: 2, eyedeemails: 1, restmails: 1}, function(err, fixtures) {
- browser = fixtures.browsers[0];
- secondBrowser = fixtures.browsers[1];
- eyedeemail = fixtures.eyedeemails[0];
- theEmail = fixtures.restmails[0];
+ if (fixtures) {
+ browser = fixtures.browsers[0];
+ secondBrowser = fixtures.browsers[1];
+ eyedeemail = fixtures.eyedeemails[0];
+ theEmail = fixtures.restmails[0];
+ }
done(err)
});
}
@@ -31,11 +31,13 @@ function dialogEyedeemeFlow(b, email, cb) {
var primary_123done = {
"setup": function(done) {
testSetup.setup({browsers: 1, eyedeemails: 3, restmails: 1}, function(err, fixtures) {
- browser = fixtures.browsers[0];
- eyedeemail = fixtures.eyedeemails[0];
- eyedeemail_mfb = fixtures.eyedeemails[1];
- porg_eyedeemail = fixtures.eyedeemails[2];
- theEmail = fixtures.restmails[0];
+ if (fixtures) {
+ browser = fixtures.browsers[0];
+ eyedeemail = fixtures.eyedeemails[0];
+ eyedeemail_mfb = fixtures.eyedeemails[1];
+ porg_eyedeemail = fixtures.eyedeemails[2];
+ theEmail = fixtures.restmails[0];
+ }
done(err);
});
},
@@ -21,11 +21,13 @@ var new_secondary_123done_two_browsers = {
"setup": function(done) {
// this is the more compact setup syntax
testSetup.setup({b:2, r:3}, function(err, fix) {
- browser = fix.b[0];
- secondBrowser = fix.b[1];
- theEmail = fix.r[0];
- mfbEmail = fix.r[1];
- nspEmail = fix.r[2];
+ if (fix) {
+ browser = fix.b[0];
+ secondBrowser = fix.b[1];
+ theEmail = fix.r[0];
+ mfbEmail = fix.r[1];
+ nspEmail = fix.r[2];
+ }
done(err);
});
},
@@ -148,7 +150,7 @@ var new_secondary_personaorg = {
},
"get verification link": function(done) {
restmail.getVerificationLink({email: nspEmail}, done);
- },
+ },
"open link, verify you are redirected to acct mgr and see your email": function(done, link) {
browser.chain({onError: done})
.get(link)
@@ -33,8 +33,10 @@ var browser, secondary;
runner.run(module, {
'pull in test environment': function(done) {
testSetup.setup({browsers: 1, restmails: 1}, function(err, fixtures) {
- browser = fixtures.browsers[0];
- secondary = fixtures.restmails[0];
+ if (fixtures) {
+ browser = fixtures.browsers[0];
+ secondary = fixtures.restmails[0];
+ }
done(err);
});
},
@@ -46,7 +48,7 @@ runner.run(module, {
.get(persona_urls['myfavoritebeer'])
.wclick(CSS['myfavoritebeer.org'].signinButton)
.wwin(CSS['persona.org'].windowName, function(err) {
- if (err) return done(err);
+ if (err) return done(err);
dialog.signInAsNewUser({
browser: browser,
email: secondary,
@@ -64,7 +66,7 @@ runner.run(module, {
.wfind(CSS['persona.org'].congratsMessage, done);
},
'hack localStorage to simulate 60 seconds of inactivity': function(done) {
- // JSON.parse to get user id, JSON.parse usersCOmputer, rewind time,
+ // JSON.parse to get user id, JSON.parse usersCOmputer, rewind time,
// stringify and finally set as local storage.
var rewindOneMinute = '(function() { ' +
'var usersComputer = JSON.parse(localStorage.getItem("usersComputer")); ' +
@@ -101,7 +103,7 @@ runner.run(module, {
"until we decide what to do, at least end the session properly": function(done) {
browser.quit(done)
}
-},
+},
{
suiteName: path.basename(__filename),
cleanup: function(done) { testSetup.teardown(done) }
@@ -70,13 +70,15 @@ runner.run(module, {
"setup all the things": function(done) {
// this is the more compact setup syntax
testSetup.setup({b:2, r:1, e:2}, function(err, fix) {
- browser = fix.b[0];
- firstPrimaryEmail = saveEmail(fix.e[0]);
- secondPrimaryEmail = saveEmail(fix.e[1]);
- secondaryEmail = saveEmail(fix.r[0]);
- firstPrimaryPassword = firstPrimaryEmail.split('@')[0];
- secondPrimaryPassword = secondPrimaryEmail.split('@')[0];
- secondaryPassword = secondaryEmail.split('@')[0];
+ if (fix) {
+ browser = fix.b[0];
+ firstPrimaryEmail = saveEmail(fix.e[0]);
+ secondPrimaryEmail = saveEmail(fix.e[1]);
+ secondaryEmail = saveEmail(fix.r[0]);
+ firstPrimaryPassword = firstPrimaryEmail.split('@')[0];
+ secondPrimaryPassword = secondPrimaryEmail.split('@')[0];
+ secondaryPassword = secondaryEmail.split('@')[0];
+ }
done(err);
});
},
@@ -26,8 +26,10 @@ runner.run(module, {
"setup": function(done) {
// this is the more compact setup syntax
testSetup.setup({b:2}, function(err, fix) {
- browser = fix.b[0];
- verificationBrowser = fix.b[1];
+ if (fix) {
+ browser = fix.b[0];
+ verificationBrowser = fix.b[1];
+ }
done(err);
});
},
@@ -94,7 +96,7 @@ runner.run(module, {
"shut down remaining browsers": function(done) {
browser.quit(done);
}
-},
+},
{
suiteName: path.basename(__filename),
cleanup: function(done) { testSetup.teardown(done); }
@@ -28,9 +28,11 @@ var browser, primary, secondary;
runner.run(module, {
"setup": function(done) {
testSetup.setup({browsers: 1, restmails: 1, eyedeemails:1}, function(err, fix) {
- browser = fix.browsers[0];
- primary = fix.eyedeemails[0];
- secondary = fix.restmails[0];
+ if (fix) {
+ browser = fix.browsers[0];
+ primary = fix.eyedeemails[0];
+ secondary = fix.restmails[0];
+ }
done(err);
});
},
@@ -20,9 +20,11 @@ var browser, testUser, mfbUser;
runner.run(module, {
"setup": function(done) {
testSetup.setup({browsers: 1, personatestusers: 2}, function(err, fixtures) {
- browser = fixtures.browsers[0];
- testUser = fixtures.personatestusers[0];
- mfbUser = fixtures.personatestusers[1];
+ if (fixtures) {
+ browser = fixtures.browsers[0];
+ testUser = fixtures.personatestusers[0];
+ mfbUser = fixtures.personatestusers[1];
+ }
done(err);
});
},
@@ -82,7 +84,7 @@ runner.run(module, {
done(err || assert.equal(text, mfbUser.email));
});
}
-},
+},
{
suiteName: path.basename(__filename),
cleanup: function(done) { testSetup.teardown(done) }

0 comments on commit 61f61ce

Please sign in to comment.