diff --git a/tests/functional/fx_desktop_handshake.js b/tests/functional/fx_desktop_handshake.js index 8b40c21fa..3ed8809d3 100644 --- a/tests/functional/fx_desktop_handshake.js +++ b/tests/functional/fx_desktop_handshake.js @@ -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 diff --git a/tests/functional/lib/helpers.js b/tests/functional/lib/helpers.js index be64a6d91..cee05edf6 100644 --- a/tests/functional/lib/helpers.js +++ b/tests/functional/lib/helpers.js @@ -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, diff --git a/tests/functional/send_sms.js b/tests/functional/send_sms.js index bc4076a2a..f0409b1d2 100644 --- a/tests/functional/send_sms.js +++ b/tests/functional/send_sms.js @@ -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);