Skip to content

Commit

Permalink
Merge pull request #1304 from hmcts/fix-nightly-tests
Browse files Browse the repository at this point in the history
remove deprecated defineSupportCode
  • Loading branch information
Josh-HMCTS authored Oct 11, 2024
2 parents c273a23 + 308e9c7 commit dbab229
Show file tree
Hide file tree
Showing 33 changed files with 1,863 additions and 1,412 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,5 @@ withPipeline(type, product, component) {
reportName : 'AAT Functional Test'
])
}

}
13 changes: 9 additions & 4 deletions Jenkinsfile_nightly
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ def channel = '#xui-pipeline'

def secrets = [
'rpx-${env}': [
secret('test-email', 'TEST_EMAIL'),
secret('test-password', 'TEST_PASSWORD'),
secret('test-user1-email', 'TEST_USER1_EMAIL'),
secret('test-user1-password', 'TEST_USER1_PASSWORD'),
secret('test-user2-email', 'TEST_USER2_EMAIL'),
secret('test-user2-password', 'TEST_USER2_PASSWORD'),
secret('test-townley-email', 'TEST_TOWNLEY_EMAIL'),
secret('test-townley-password', 'TEST_TOWNLEY_PASSWORD'),
secret('test-api-email', 'TEST_API_EMAIL'),
secret('test-api-password', 'TEST_API_PASSWORD'),
secret('test-api-password', 'TEST_API_PASSWORD')
],
]

Expand All @@ -40,7 +44,7 @@ withNightlyPipeline(type, product, component) {
enableSlackNotifications(channel)
loadVaultSecrets(secrets)
// enableFortifyScan('rpx-aat')
// enableFullFunctionalTest(60)
//enableFullFunctionalTest(120)
// enableSecurityScan()
enableMutationTest()
enableCrossBrowserTest()
Expand Down Expand Up @@ -124,5 +128,6 @@ withNightlyPipeline(type, product, component) {
reportFiles : 'index.html',
reportName : 'XUI Manage Organisation Cross Browser Tests'
])
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/crossbrowser/**/*'
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"@angular/platform-browser-dynamic": "^17.3.6",
"@angular/router": "^17.3.6",
"@circlon/angular-tree-component": "^11.0.4",
"@cucumber/cucumber": "^11.0.0",
"@cucumber/pretty-formatter": "^1.0.1",
"@edium/fsm": "^2.1.2",
"@hmcts/ccd-case-ui-toolkit": "7.0.40",
"@hmcts/ccpay-web-component": "6.2.1",
Expand Down
8 changes: 7 additions & 1 deletion test/e2e/config/common.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ const localConfig = [

const config = {
config: {
baseUrl: process.env.TEST_URL || 'http://localhost:3000/'
baseUrl: process.env.TEST_URL || 'http://localhost:3000/',
username: process.env.TEST_USER1_EMAIL,
password: process.env.TEST_USER1_PASSWORD,
username_rw: process.env.TEST_USER2_EMAIL,
password_rw: process.env.TEST_USER2_PASSWORD,
townleyUser: process.env.TEST_TOWNLEY_EMAIL,
townleyPassword: process.env.TEST_TOWNLEY_PASSWORD
},
twoFactorAuthEnabled: false,
termsAndConditionsEnabled: true
Expand Down
20 changes: 12 additions & 8 deletions test/e2e/config/crossbrowser.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
const minimist = require('minimist');
const argv = minimist(process.argv.slice(2));

const cucumberPretty = require('@cucumber/pretty-formatter');
const config = {
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
Expand All @@ -17,12 +17,16 @@ const config = {
specs: ['../features/**/*.feature'],

baseUrl: (process.env.TEST_URL || 'http://localhost:3000/').replace('https', 'http'),

params: {
serverUrls: process.env.TEST_URL || 'http://localhost:3000/',
targetEnv: argv.env || 'local'
//username: process.env.TEST_EMAIL,
//password: process.env.TEST_PASSWORD,
targetEnv: argv.env || 'local',
username: process.env.TEST_USER1_EMAIL,
password: process.env.TEST_USER1_PASSWORD,
username_rw: process.env.TEST_USER2_EMAIL,
password_rw: process.env.TEST_USER2_PASSWORD,
townleyUser: process.env.TEST_TOWNLEY_EMAIL,
townleyPassword: process.env.TEST_TOWNLEY_PASSWORD
},

// sauceProxy: 'http://proxyout.reform.hmcts.net:8080', // Proxy for the REST API
Expand Down Expand Up @@ -115,9 +119,9 @@ const config = {

cucumberOpts: {
strict: true,
format: ['node_modules/cucumber-pretty', 'json:cb_reports/saucelab_results.json'],
require: ['../support/world.js', '../support/*.js', '../features/step_definitions/**/*.steps.js'],
tags: ['@crossbrowser', 'not @Flaky']
format: ['@cucumber/pretty-formatter', 'json:cb_reports/saucelab_results.json'],
require: ['../support/timeout.js', '../features/step_definitions/**/*.steps.js'],
tags: ['@crossbrowser']
},

plugins: [
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/config/fullfunctional.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const config = {
cucumberOpts: {
strict: true,
// format: ['node_modules/cucumber-pretty'],
format: ['node_modules/cucumber-pretty', 'json:reports/tests/functional/results.json'],
format: ['@cucumber/pretty-formatter', 'json:reports/tests/functional/results.json'],
tags: ['@all or @smoke or @fullFunctional or @end2end', 'not @Flaky'],
// tags: ['@edit'],
require: cucumberOpts
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/config/functional.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const config = {

cucumberOpts: {
strict: true,
format: ['node_modules/cucumber-pretty', 'json:reports_json/results.json'],
format: ['@cucumber/pretty-formatter', 'json:reports_json/results.json'],
tags: ['@all or @fullFunctional', 'not @Flaky'],
// tags: ['@all or @smoke or @fullFunctional or @end2end'],
require: cucumberOpts
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/config/smoke.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const config = {
cucumberOpts: {
strict: true,
// format: ['node_modules/cucumber-pretty'],
format: ['node_modules/cucumber-pretty', 'json:reports_json/results.json'],
format: ['@cucumber/pretty-formatter', 'json:reports_json/results.json'],
tags: ['@smoke', 'not @Flaky'],
require: [
'../support/timeout.js',
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/features/app/loginLogout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Feature: Login
Then I should be redirected to the Idam login page
Then I should see failure error summary

@crossbrowser
Scenario: login and log out from manage organisation as ManageOrg user
Given I am logged into manage organisation with ManageOrg user details
Given I am logged into Townley Services Org
Then I should be redirected to manage organisation dashboard page
When I select the sign out link
Then I should be redirected to the Idam login page
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/features/app/viewOrganisation.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@crossbrowser
Feature: view organisation workflow
@Flaky
Scenario: view organisation workflow
When I navigate to manage organisation Url
Given I am logged into manage organisation with ManageOrg user details
Given I am logged into Townley Services Org
Then I should be redirected to manage organisation dashboard page
Then I should be on display the name and address details of organisation
2 changes: 1 addition & 1 deletion test/e2e/features/pageObjects/loginLogoutObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { SHORT_DELAY, MID_DELAY, LONG_DELAY } = require('../../support/constants');

function loginLogoutObjects() {
this.emailAddress = element(by.css('input#username'));
this.emailAddress = element(by.css('[id=\'username\']'));
this.password = element(by.css('[id=\'password\']'));
this.signinTitle= element(by.xpath('//h1[@class=\'heading-large\']'));
//this.signinTitle = element(by.css("h1"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
const { Then, When } = require('@cucumber/cucumber');

const acceptTermsAndConditionsPage = require('../pageObjects/termsAndConditionsConfirmPage');
const HeaderPage = require('../pageObjects/headerPage');

const { config } = require('../../config/common.conf');
const browserWaits = require('../../support/customWaits');

const { defineSupportCode } = require('cucumber');

defineSupportCode(function ({ And, But, Given, Then, When }) {
const headerPage = new HeaderPage();
Then('I am on Accept Terms and Conditions page', async function () {
const world = this;
if (await acceptTermsAndConditionsPage.isFeatureToggleEnabled()){
await browserWaits.waitForElement(acceptTermsAndConditionsPage.accepttermsAndConditionsContainer);
expect(await acceptTermsAndConditionsPage.amOnPage()).to.be.true;
} else {
world.attach('Accept Terms and Conditions feature disabled in config. ../../config/common.conf.js. Validating Home page displayed');
await headerPage.waitForPrimaryNavigationToDisplay();
}
});
const headerPage = new HeaderPage();
Then('I am on Accept Terms and Conditions page', async function () {
const world = this;
if (await acceptTermsAndConditionsPage.isFeatureToggleEnabled()){
await browserWaits.waitForElement(acceptTermsAndConditionsPage.accepttermsAndConditionsContainer);
expect(await acceptTermsAndConditionsPage.amOnPage()).to.be.true;
} else {
world.attach('Accept Terms and Conditions feature disabled in config. ../../config/common.conf.js. Validating Home page displayed');
await headerPage.waitForPrimaryNavigationToDisplay();
}
});

When('I click Confirm in Accept Terms and Conditions page', async function () {
const world = this;
if (await acceptTermsAndConditionsPage.isFeatureToggleEnabled()) {
await browserWaits.waitForElement(acceptTermsAndConditionsPage.accepttermsAndConditionsContainer);
await acceptTermsAndConditionsPage.acceptTremsAndConditions();
await headerPage.waitForPrimaryNavigationToDisplay();
} else {
world.attach('Accept Terms and Conditions feature disabled in config. ../../config/common.conf.js.Validating Home page displayed');
await headerPage.waitForPrimaryNavigationToDisplay();
}
});
When('I click Confirm in Accept Terms and Conditions page', async function () {
const world = this;
if (await acceptTermsAndConditionsPage.isFeatureToggleEnabled()) {
await browserWaits.waitForElement(acceptTermsAndConditionsPage.accepttermsAndConditionsContainer);
await acceptTermsAndConditionsPage.acceptTremsAndConditions();
await headerPage.waitForPrimaryNavigationToDisplay();
} else {
world.attach('Accept Terms and Conditions feature disabled in config. ../../config/common.conf.js.Validating Home page displayed');
await headerPage.waitForPrimaryNavigationToDisplay();
}
});
27 changes: 12 additions & 15 deletions test/e2e/features/step_definitions/approveOrg.steps.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
const { When } = require('@cucumber/cucumber');

const approveOrganizationService = require('../pageObjects/approveOrganizationService');

const mailinatorService = require('../pageObjects/mailinatorService');

const { defineSupportCode } = require('cucumber');
When('I approve organisation', { timeout: 300*1000 }, async function () {
await approveOrganizationService.init();
await approveOrganizationService.approveOrg(global.latestOrgCreated);
await approveOrganizationService.destroy();
},);

defineSupportCode(function ({ And, But, Given, Then, When }) {
When('I approve organisation', { timeout: 300*1000 }, async function () {
await approveOrganizationService.init();
await approveOrganizationService.approveOrg(global.latestOrgCreated);
await approveOrganizationService.destroy();
},);

When('I activate approved organisation super user', { timeout: 600 * 1000 }, async function () {
await mailinatorService.init();
mailinatorService.setLogger((message, isScreenshot) => logger(this, message, isScreenshot));
await mailinatorService.openRegistrationEmailForUser(global.latestOrgSuperUser);
await mailinatorService.completeUserRegistrationFromEmail();
await mailinatorService.destroy();
});
When('I activate approved organisation super user', { timeout: 600 * 1000 }, async function () {
await mailinatorService.init();
mailinatorService.setLogger((message, isScreenshot) => logger(this, message, isScreenshot));
await mailinatorService.openRegistrationEmailForUser(global.latestOrgSuperUser);
await mailinatorService.completeUserRegistrationFromEmail();
await mailinatorService.destroy();
});

function logger(world, message, isScreenshot) {
Expand Down
Loading

0 comments on commit dbab229

Please sign in to comment.