Skip to content

Commit

Permalink
Welsh tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Radoslaw Orlowski committed Apr 15, 2020
1 parent 7c06474 commit a70d7ec
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
26 changes: 26 additions & 0 deletions src/test/js/mfa_e2e_test.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down Expand Up @@ -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}`;
Expand Down
5 changes: 4 additions & 1 deletion src/test/js/shared/idam_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/test/js/shared/welsh_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};
5 changes: 1 addition & 4 deletions src/test/js/welsh_language_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;

Expand All @@ -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

0 comments on commit a70d7ec

Please sign in to comment.