fix(test): Disable SMS sending tests on production environments. (#5185) r=@jbuck, @philbooth

Production environments send SMS. We can't have that happening.
This commit is contained in:
Shane Tomlinson 2017-06-30 00:20:42 +01:00 коммит произвёл GitHub
Родитель a0e0164257
Коммит e55dc57275
3 изменённых файлов: 35 добавлений и 14 удалений

Просмотреть файл

@ -42,6 +42,7 @@ define([
const clearBrowserState = FunctionalHelpers.clearBrowserState;
const createUser = FunctionalHelpers.createUser;
const deleteAllSms = FunctionalHelpers.deleteAllSms;
const disableInProd = FunctionalHelpers.disableInProd;
const fillOutSignIn = FunctionalHelpers.fillOutSignIn;
const getSmsSigninCode = FunctionalHelpers.getSmsSigninCode;
const openPage = FunctionalHelpers.openPage;
@ -140,7 +141,7 @@ define([
.then(testElementValueEquals(selectors.SIGNIN.EMAIL, browserSignedInEmail));
},
'Sync signin page w/ signin code - user signed into browser': function () {
'Sync signin page w/ signin code - user signed into browser': disableInProd(function () {
const testPhoneNumber = TestHelpers.createPhoneNumber();
let signinUrlWithSigninCode;
@ -180,7 +181,7 @@ define([
// defined so that we are ready when Fennec or iOS adds fxa_status support.
.then(testElementTextEquals(selectors.SIGNIN.EMAIL_NOT_EDITABLE, browserSignedInEmail));
});
},
}),
'Non-Sync signin page - user signed into browser, no user signed in locally': function () {
return this.remote

Просмотреть файл

@ -534,6 +534,23 @@ define([
.then(() => restmail.deleteAllEmails(user));
});
/**
* Tests that send an SMS should be wrapped by `disableInProd`. This will
* prevent the tests from running in stage/prod where we should not
* send SMSs to random people.
*
* @param {Function} test
* @returns {Function}
*/
function disableInProd(test) {
if (intern.config.fxaProduction) {
return function () {
};
}
return test;
}
/**
* Get SMS message `index` for `phoneNumber`.
*
@ -1868,6 +1885,7 @@ define([
deleteAllEmails,
deleteAllSms,
denormalizeStoredEmail: denormalizeStoredEmail,
disableInProd,
fetchAllMetrics: fetchAllMetrics,
fillOutChangePassword: fillOutChangePassword,
fillOutCompleteResetPassword: fillOutCompleteResetPassword,

Просмотреть файл

@ -30,6 +30,7 @@
const SEND_SMS_SIGNIN_CODE_URL = `${SEND_SMS_URL}&signinCodes=true`;
const SEND_SMS_NO_QUERY_URL = `${config.fxaContentRoot}sms`;
let email;
const PASSWORD = 'password';
@ -39,6 +40,7 @@
const click = FunctionalHelpers.click;
const closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
const deleteAllSms = FunctionalHelpers.deleteAllSms;
const disableInProd = FunctionalHelpers.disableInProd;
const fillOutSignUp = FunctionalHelpers.fillOutSignUp;
const getSms = FunctionalHelpers.getSms;
const getSmsSigninCode = FunctionalHelpers.getSmsSigninCode;
@ -213,7 +215,7 @@
.then(testElementTextInclude(selectors.SMS_SEND.PHONE_NUMBER_TOOLTIP, 'invalid'));
},
'valid phone number, back': function () {
'valid phone number, back': disableInProd(function () {
return this.remote
.then(openPage(SEND_SMS_URL, selectors.SMS_SEND.HEADER))
.then(type(selectors.SMS_SEND.PHONE_NUMBER, testPhoneNumber))
@ -229,9 +231,9 @@
// original phone number should still be in place
.then(testElementValueEquals(selectors.SMS_SEND.PHONE_NUMBER, testPhoneNumber));
},
}),
'valid phone number, resend': function () {
'valid phone number, resend': disableInProd(function () {
return this.remote
.then(openPage(SEND_SMS_URL, selectors.SMS_SEND.HEADER))
.then(type(selectors.SMS_SEND.PHONE_NUMBER, testPhoneNumber))
@ -242,18 +244,18 @@
.then(click(selectors.SMS_SENT.LINK_RESEND))
.then(testElementTextInclude(selectors.SMS_SENT.PHONE_NUMBER_SENT_TO, formattedPhoneNumber))
.then(getSms(testPhoneNumber, 1));
},
}),
'valid phone number, enable signinCode': function () {
'valid phone number, enable signinCode': disableInProd(function () {
return this.remote
.then(openPage(SEND_SMS_SIGNIN_CODE_URL, selectors.SMS_SEND.HEADER))
.then(type(selectors.SMS_SEND.PHONE_NUMBER, testPhoneNumber))
.then(click(selectors.SMS_SEND.SUBMIT))
.then(testElementExists(selectors.SMS_SENT.HEADER))
.then(getSmsSigninCode(testPhoneNumber, 0));
},
}),
'valid phone number w/ country code of 1': function () {
'valid phone number w/ country code of 1': disableInProd(function () {
return this.remote
.then(openPage(SEND_SMS_URL, selectors.SMS_SEND.HEADER))
.then(type(selectors.SMS_SEND.PHONE_NUMBER, `1${testPhoneNumber}`))
@ -262,9 +264,9 @@
.then(testElementTextInclude(selectors.SMS_SENT.PHONE_NUMBER_SENT_TO, formattedPhoneNumber))
.then(testElementExists(selectors.SMS_SEND.LINK_MARKETING))
.then(getSms(testPhoneNumber, 0));
},
}),
'valid phone number w/ country code of +1': function () {
'valid phone number w/ country code of +1': disableInProd(function () {
return this.remote
.then(openPage(SEND_SMS_URL, selectors.SMS_SEND.HEADER))
.then(type(selectors.SMS_SEND.PHONE_NUMBER, `+1${testPhoneNumber}`))
@ -273,9 +275,9 @@
.then(testElementTextInclude(selectors.SMS_SENT.PHONE_NUMBER_SENT_TO, formattedPhoneNumber))
.then(testElementExists(selectors.SMS_SEND.LINK_MARKETING))
.then(getSms(testPhoneNumber, 0));
},
}),
'valid phone number (contains spaces and punctuation)': function () {
'valid phone number (contains spaces and punctuation)': disableInProd(function () {
const unformattedPhoneNumber = ` ${testPhoneNumber.slice(0,3)} .,- ${testPhoneNumber.slice(3)} `;
return this.remote
.then(openPage(SEND_SMS_URL, selectors.SMS_SEND.HEADER))
@ -291,7 +293,7 @@
// original phone number should still be in place
.then(testElementValueEquals(selectors.SMS_SEND.PHONE_NUMBER, unformattedPhoneNumber));
}
})
};
registerSuite(suite);