From d432f40056e37d1f1afef39b984b5af379092997 Mon Sep 17 00:00:00 2001 From: weskubo-cgi Date: Thu, 15 Aug 2024 12:46:31 -0700 Subject: [PATCH] Incorporated tests from qa-ofmcc-1250-crm-login. --- .../deploy-to-openshift-backend-dev.yml | 25 +-------- .../crm_login.cy.js | 53 +++++++++++++++---- testing/package.json | 1 - 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/.github/workflows/deploy-to-openshift-backend-dev.yml b/.github/workflows/deploy-to-openshift-backend-dev.yml index 9e083c82..cd1661c0 100644 --- a/.github/workflows/deploy-to-openshift-backend-dev.yml +++ b/.github/workflows/deploy-to-openshift-backend-dev.yml @@ -202,30 +202,9 @@ jobs: # target: 'https://${{ env.HOST_ROUTE }}/api' cypress-run: - name: Run Cypress E2E tests needs: openshift-ci-cd - runs-on: ubuntu-24.04 - environment: dev - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ env.BRANCH }} - - name: Cypress run - uses: cypress-io/github-action@v6 - with: - working-directory: ./testing - #project: ./testing - browser: electron - wait-on: 'https://${{ env.HOST_ROUTE }}' - env: - CYPRESS_AAD_USERNAME: ${{ secrets.CYPRESS_AAD_USERNAME }} - CYPRESS_AAD_PASSWORD: ${{ secrets.CYPRESS_AAD_PASSWORD }} - CYPRESS_PORTAL_USERNAME: ${{ secrets.CYPRESS_PORTAL_USERNAME }} - CYPRESS_PORTAL_PASSWORD: ${{ secrets.CYPRESS_PORTAL_PASSWORD }} - CYPRESS_CRM_URL: ${{ secrets.CYPRESS_CRM_URL }} - CYPRESS_CRM_BASE_URL: ${{ secrets.CYPRESS_CRM_BASE_URL }} - CYPRESS_PORTAL_URL: 'https://${{ env.HOST_ROUTE }}/' + uses: ./.github/workflows/cypress-e2e.yml + secrets: inherit zap-scan: name: ZAP Scan diff --git a/testing/cypress/e2e/1-portal-and-crm-login-and-security/crm_login.cy.js b/testing/cypress/e2e/1-portal-and-crm-login-and-security/crm_login.cy.js index 0e78102b..7ae5a892 100644 --- a/testing/cypress/e2e/1-portal-and-crm-login-and-security/crm_login.cy.js +++ b/testing/cypress/e2e/1-portal-and-crm-login-and-security/crm_login.cy.js @@ -26,17 +26,52 @@ describe('Login to CRM via AAD', () => { }) }) - it.skip('failed login', () => { + it('navigate to organization', () => { cy.webExceptions(CRM_BASE_URL) cy.visit('https://google.ca') - cy.loginToAAD('doesnotexist@gov.bc.ca', 'password', CRM_URL, CRM_BASE_URL) - - // Validate urror - cy.get('div[role="alert"]') - .contains( - 'This username may be incorrect. Make sure you typed it correctly. Otherwise, contact your admin.' - ) - .should('exist') + cy.loginToAAD(AAD_USERNAME, AAD_PASSWORD, CRM_URL, CRM_BASE_URL) cy.visit(CRM_URL) + cy.origin(CRM_BASE_URL, () => { + cy.on('uncaught:exception', (e) => { + return false + }) + + cy.get('ul[aria-label="Childcare Providers"]') + .contains('Organization-Facilities') + .click() + cy.get( + 'input[aria-label="Organization-Facility Filter by keyword"]' + ).type('Test-1088 Organization{enter}') + cy.wait(5000) + cy.get('div[row-index="0"]') + .find('input[type="checkbox"]') + .click({ force: true }) + cy.get('ul[aria-label="Organization-Facility Commands"]') + .find('button') + // XXX This should be Edit but for some reason it's not displaying + // Test is still valid as Org can be actioned with either button + .contains('Activate') + .click() + }) + }) + + it('failed login', () => { + cy.webExceptions(CRM_BASE_URL) + cy.visit('https://google.ca') + //cy.loginToAAD('doesnotexist@gov.bc.ca', 'password', CRM_URL, CRM_BASE_URL) + cy.visit(CRM_BASE_URL) + cy.origin('login.microsoftonline.com', () => { + cy.get('input[type="email"]').type('doesnotexist@gov.bc.ca', { + log: false, + }) + cy.get('input[type="submit"]').click() + + // Validate error + cy.get('div[role="alert"]') + .contains( + 'This username may be incorrect. Make sure you typed it correctly. Otherwise, contact your admin.' + ) + .should('exist') + }) }) }) diff --git a/testing/package.json b/testing/package.json index f5f6acf4..a7d83a8a 100644 --- a/testing/package.json +++ b/testing/package.json @@ -5,7 +5,6 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "report": "npx cypress run --spec ./cypress/e2e/examples/portal-automation/assistance_request.cy.js --browser electron --headed", "cy:open": "cypress open", "cy:run": "cypress run --browser electron --headless ", "cy:run-one": "cypress run --browser electron --headed --spec "