diff --git a/src/test/js/mfa_e2e_test.js b/src/test/js/mfa_e2e_test.js index 1132360ee..70ef1e907 100644 --- a/src/test/js/mfa_e2e_test.js +++ b/src/test/js/mfa_e2e_test.js @@ -1,5 +1,7 @@ const randomData = require('./shared/random_data'); const TestData = require('./config/test_data'); +const Welsh = require('./shared/welsh_constants'); +const assert = require('assert'); Feature('I am able to login with MFA'); @@ -84,6 +86,30 @@ Scenario('@functional @mfaLogin I am able to login with MFA', async (I) => { I.resetRequestInterception(); }).retry(TestData.SCENARIO_RETRY_LIMIT); +Scenario('@functional @mfaLogin @welshLanguage I am able to login with MFA in Welsh', async (I) => { + const loginUrl = `${TestData.WEB_PUBLIC_URL}/login?redirect_uri=${TestData.SERVICE_REDIRECT_URI}&client_id=${serviceName}${Welsh.urlForceCy}`; + + I.amOnPage(loginUrl); + I.waitForText(Welsh.signInOrCreateAccount, 20, 'h1'); + I.fillField('#username', mfaUserEmail); + I.fillField('#password', TestData.PASSWORD); + I.click(Welsh.signIn); + I.seeInCurrentUrl("/verification"); + I.waitForText(Welsh.verificationRequired, 10, 'h1'); + I.wait(5); + const otpEmailBody = await I.getEmail(mfaUserEmail); + assert.equal(otpEmailBody.body.startsWith('Ysgrifennwyd'), true); + const otpCode = await I.extractOtpFromEmailBody(otpEmailBody); + + I.fillField('code', otpCode); + I.interceptRequestsAfterSignin(); + I.click(Welsh.submitBtn); + I.waitForText(TestData.SERVICE_REDIRECT_URI); + I.see('code='); + I.dontSee('error='); + I.resetRequestInterception(); +}).retry(TestData.SCENARIO_RETRY_LIMIT); + Scenario('@functional @mfaLogin I am not able to login with MFA for the block policy ', async (I) => { const loginUrl = `${TestData.WEB_PUBLIC_URL}/login?redirect_uri=${TestData.SERVICE_REDIRECT_URI}&client_id=${serviceName}`; diff --git a/src/test/js/shared/idam_helper.js b/src/test/js/shared/idam_helper.js index efe609c77..5e8fee516 100644 --- a/src/test/js/shared/idam_helper.js +++ b/src/test/js/shared/idam_helper.js @@ -482,7 +482,10 @@ class IdamHelper extends Helper { } async extractOtpFromEmail(searchEmail) { - const emailResponse = await this.getEmail(searchEmail); + return this.extractOtpFromEmailBody(await this.getEmail(searchEmail)) + } + + async extractOtpFromEmailBody(emailResponse) { if(emailResponse) { const regex = "[0-9]{8}"; const url = emailResponse.body.match(regex); diff --git a/src/test/js/shared/welsh_constants.js b/src/test/js/shared/welsh_constants.js index ef2d1788b..59eed286d 100644 --- a/src/test/js/shared/welsh_constants.js +++ b/src/test/js/shared/welsh_constants.js @@ -32,5 +32,6 @@ module.exports = { resetYourPassword: 'ailosod eich cyfrinair', submitBtn: 'Cyflwyno', createANewPassword: 'Creu cyfrinair newydd', - passwordChanged: 'Mae eich cyfrinair wedi cael ei newid' + passwordChanged: 'Mae eich cyfrinair wedi cael ei newid', + verificationRequired: 'Mae angen dilysu eich cyfrif' }; diff --git a/src/test/js/welsh_language_test.js b/src/test/js/welsh_language_test.js index 9c1b7cf45..ab70d0259 100644 --- a/src/test/js/welsh_language_test.js +++ b/src/test/js/welsh_language_test.js @@ -80,8 +80,7 @@ Scenario('@functional @welshLanguage I can set the language to English with an i I.waitForText('Access Denied', 20, 'h1'); }); -// todo I can reset my password in Welsh -Scenario('@functional @welshLanguage I can reset my password in Welsh @1234', async (I) => { +Scenario('@functional @welshLanguage I can reset my password in Welsh', async (I) => { const loginPage = `${TestData.WEB_PUBLIC_URL}/login?redirect_uri=${TestData.SERVICE_REDIRECT_URI}&client_id=${serviceName}${Welsh.urlForceCy}`; @@ -104,5 +103,3 @@ Scenario('@functional @welshLanguage I can reset my password in Welsh @1234', as I.waitInUrl('doResetPassword'); I.waitForText(Welsh.passwordChanged, 20, 'h1'); }); - -// todo I can login with OTP in Welsh