diff --git a/Jenkinsfile_CNP b/Jenkinsfile_CNP index ab21e8f4d..c5794c1f8 100644 --- a/Jenkinsfile_CNP +++ b/Jenkinsfile_CNP @@ -7,20 +7,16 @@ properties([ projectUrlStr: 'https://github.com/hmcts/rpx-xui-manage-organisations' ], pipelineTriggers([ - [$class: 'GitHubPushTrigger'] + cron('H 07 * * 1-5') ]) ]) @Library("Infrastructure") -//To enable PACT testing on pipeline uncomment the next line -import uk.gov.hmcts.contino.AppPipelineDsl - def type = "nodejs" def product = "xui" def component = "mo-webapp" def channel = '#xui-pipeline' -def yarnBuilder = new uk.gov.hmcts.contino.YarnBuilder(this) def secrets = [ 'rpx-${env}': [ @@ -39,163 +35,59 @@ def secrets = [ secret('launch-darkly-client-id', 'LAUNCH_DARKLY_CLIENT_ID'), secret('system-user-name', 'SYSTEM_USER_NAME'), secret('system-user-password', 'SYSTEM_USER_PASSWORD'), - secret('mo-webapp-redis6-connection-string', 'REDISCLOUD_URL'), - + secret('mo-webapp-redis6-connection-string', 'REDISCLOUD_URL') ], ] -def branchesToSync = ['demo', 'perftest', 'ithc'] - static LinkedHashMap secret(String secretName, String envVar) { - [ $class: 'AzureKeyVaultSecret', - secretType: 'Secret', - name: secretName, - version: '', - envVariable: envVar - ] + [ $class: 'AzureKeyVaultSecret', + secretType: 'Secret', + name: secretName, + version: '', + envVariable: envVar + ] } -withPipeline(type, product, component) { - disableCleanupOfHelmReleaseOnFailure() +withNightlyPipeline(type, product, component) { enableSlackNotifications(channel) loadVaultSecrets(secrets) - enableAksStagingDeployment() - syncBranchesWithMaster(branchesToSync) - - enablePactAs([ - AppPipelineDsl.PactRoles.CONSUMER -]) + // enableFortifyScan('rpx-aat') + // enableFullFunctionalTest(120) + // enableSecurityScan() + enableCrossBrowserTest() + env.TEST_URL = 'https://manage-org.aat.platform.hmcts.net/' + afterSuccess('checkout') {sh 'yarn cache clean'} afterSuccess('build') { - yarnBuilder.yarn('build') - } - - afterSuccess('test') { - - publishHTML ( [ - allowMissing : true, - alwaysLinkToLastBuild: true, - keepAll : true, - reportDir : "reports/tests/coverage/node", - reportFiles : "index.html", - reportName : "node coverage tests" - ]) - - publishHTML ( [ - allowMissing : true, - alwaysLinkToLastBuild: true, - keepAll : true, - reportDir : "reports/tests/coverage/ng", - reportFiles : "index.html", - reportName : "ng coverage tests" - ]) - + sh 'npm run build' publishHTML([ allowMissing : true, alwaysLinkToLastBuild: true, keepAll : true, - reportDir : "reports/tests/a11y/", - reportFiles : 'Report.html', - reportName : 'Manage Org a11y Test' - ]) - - - - - } - -// after('smoketest:demo') { -// publishHTML([ -// allowMissing : true, -// alwaysLinkToLastBuild: true, -// keepAll : true, -// reportDir : "reports/tests/smoke/", -// reportFiles : 'index.html', -// reportName : 'DEMO Smoke Test' -// ]) -// } - - afterSuccess('smoketest:preview') { - publishHTML([ - allowMissing : true, - alwaysLinkToLastBuild: true, - keepAll : true, - reportDir : "reports/tests/api_functional/", - reportFiles : 'mochawesome.html', - reportName : 'PREVIEW API Test' - ]) - - publishHTML([ - allowMissing : true, - alwaysLinkToLastBuild: true, - keepAll : true, - reportDir : "reports/smoke_tests/functional", + reportDir : "test/reports/lint/node/", reportFiles : 'index.html', - reportName : 'PREVIEW Manage Org Smoke Test' + reportName : 'node lint Report' ]) - } - - afterSuccess('functionalTest:preview') { - - publishHTML([ - allowMissing : true, - alwaysLinkToLastBuild: true, - keepAll : true, - reportDir : "reports/tests/api_functional/", - reportFiles : 'mochawesome.html', - reportName : 'PREVIEW API Functional Test' - ]) - publishHTML([ allowMissing : true, alwaysLinkToLastBuild: true, keepAll : true, - reportDir : "reports/tests/functional/", + reportDir : "test/reports/lint/ng/", reportFiles : 'index.html', - reportName : 'PREVIEW Functional Test' + reportName : 'ng lint Report' ]) } - afterSuccess('smoketest:aat') { - publishHTML([ - allowMissing : true, - alwaysLinkToLastBuild: true, - keepAll : true, - reportDir : "reports/tests/api_functional/", - reportFiles : 'mochawesome.html', - reportName : 'API Smoke Test' - ]) - - publishHTML([ - allowMissing : true, - alwaysLinkToLastBuild: true, - keepAll : true, - reportDir : "reports/smoke_tests/functional", - reportFiles : 'index.html', - reportName : 'AAT Manage Org Smoke Test' - ]) - } - - afterSuccess('functionalTest:aat') { - - publishHTML([ - allowMissing : true, - alwaysLinkToLastBuild: true, - keepAll : true, - reportDir : "reports/tests/api_functional/", - reportFiles : 'mochawesome.html', - reportName : 'API Functional Test' - ]) - + afterSuccess('crossBrowserTest') { publishHTML([ allowMissing : true, alwaysLinkToLastBuild: true, keepAll : true, - reportDir : "reports/tests/functional/", + reportDir : "reports/tests/crossbrowser/", reportFiles : 'index.html', - reportName : 'AAT Functional Test' + reportName : 'XUI Manage Organisation Cross Browser Tests' ]) + steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/crossbrowser/**/*' } - } diff --git a/package.json b/package.json index 14ac1edae..cb36eabe0 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "test:functional": "yarn build && node ./test_codecept/backendMock/configCopy.js && NODE_CONFIG_ENV=mock && yarn playwright install chromium && yarn test:api && yarn run test:xuiIntegration && yarn run test:codeceptE2E && yarn run test:a11yInTest", "test:functional:backup": "webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/functional.conf.js", "test:functional:local": "webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/functional.conf.js --local", - "test:fullfunctional": "yarn test:api && yarn run test:codeceptE2E", + "test:fullfunctional": "yarn run test:codeceptE2E", "test:fullfunctional:local": "webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/fullfunctional.conf.js --local", "test:mutation": "echo 'not implemented'", "test:mutation:fix": "NODE_ENV=development npx nyc stryker run stryker.node.conf.js ", @@ -251,5 +251,5 @@ "minimist": "^1.2.8", "loader-utils": "~2.0.3" }, - "packageManager": "yarn@3.6.4" + "packageManager": "yarn@3.6.3" } diff --git a/test/e2e/features/step_definitions/loginLogout.steps.js b/test/e2e/features/step_definitions/loginLogout.steps.js index eca8ecdbe..507695d1b 100644 --- a/test/e2e/features/step_definitions/loginLogout.steps.js +++ b/test/e2e/features/step_definitions/loginLogout.steps.js @@ -25,14 +25,19 @@ async function waitForElement(el) { When(/^I navigate to manage organisation Url$/, { timeout: 600 * 1000 }, async function () { const world = this; + console.log('in I navigate to manage organisation Url !!!!!!!!!!!'); await browser.driver.manage().deleteAllCookies(); await browser.get(config.config.baseUrl); + console.log('browser.get(config.config.baseUrl) !!!!!!!!!!!' + config.config.baseUrl); + console.log('browser name !!!!!!!!!!!' + browser.browserName); + console.log('calling browserWaits.waitForElement(loginPage.emailAddress) !!!!!!!!!!!'); await browserWaits.retryWithAction(loginPage.emailAddress, async function (message) { const stream = await browser.takeScreenshot(); const decodedImage = new Buffer(stream.replace(/^data:image\/(png|gif|jpeg);base64,/, ''), 'base64'); world.attach(decodedImage, 'image/png'); await browser.get(config.config.baseUrl); }); + console.log('calling browserWaits.waitForElement(loginPage.emailAddress) !!!!!!!!!!!'); await browserWaits.waitForElement(loginPage.emailAddress, LONG_DELAY, 'IDAM login page Email Address input not present'); }); diff --git a/test/e2e/support/customWaits.js b/test/e2e/support/customWaits.js index ffb67b38c..a6c5170d3 100644 --- a/test/e2e/support/customWaits.js +++ b/test/e2e/support/customWaits.js @@ -8,6 +8,12 @@ class BrowserWaits { } async waitForElement(waitelement, customWait, message) { + console.log('in waitForElement'); + console.log('browser type is: ' + browser.browserName); + console.log('waitelement is: ' + waitelement.toString()); + console.log('element type of -> ' + typeof(waitelement)); + console.log('element stringify -> ' + JSON.stringify(waitelement)); + console.log('element.locator.toString is: ' + waitelement.locator().toString()); await browser.wait(EC.visibilityOf(waitelement), customWait ? customWait : this.waitTime, 'Error : ' + waitelement.locator().toString() + (message ? ' => ' + message : '_')); } @@ -85,6 +91,7 @@ class BrowserWaits { while (retryCounter < 3) { try { + console.log('in retryWithAction, element: ' + element.value); await this.waitForElement(element, 15000); retryCounter += 3; } catch (err) { diff --git a/test_codecept/codeceptCommon/browser.js b/test_codecept/codeceptCommon/browser.js index 6b9aa89ed..6a2972583 100644 --- a/test_codecept/codeceptCommon/browser.js +++ b/test_codecept/codeceptCommon/browser.js @@ -2,6 +2,8 @@ const helper = require('codeceptjs').helper; function getActor(){ + console.log('in getActor()'); + console.log('actor() --> ' + actor()); return actor().retry({ retries: 3, minTimeout: 30 }); } @@ -72,13 +74,17 @@ class Browser{ } async get(url){ + console.log('in Browser get'); + console.log('url --> ' + url); + console.log('getActor() --> ' + getActor()); + console.log('getActor().amOnPage --> ' + getActor().amOnPage); await getActor().amOnPage(url); } async getCurrentUrl(){ return await getActor().grabCurrentUrl() } - + async refresh(){ const url = await this.getCurrentUrl(); await this.get(url); @@ -91,15 +97,15 @@ class Browser{ }catch(err){ } - + } async executeScript(fn, element){ - return getActor().executeScript(fn, element.selector); + return getActor().executeScript(fn, element.selector); } async getBrowserLogs(){ - return await getActor().grabBrowserLogs(); + return await getActor().grabBrowserLogs(); } async captureBrowserLogs(){ @@ -114,7 +120,7 @@ class Browser{ async getSessionStorage(key) { return await getActor().executeScript((key) => { return window.sessionStorage[key] - },key); + },key); } async getLocalStorage(key) {