Skip to content

Commit

Permalink
Merge pull request #970 from DFE-Digital/Cypress-Refactoring-plus-Slack
Browse files Browse the repository at this point in the history
Cypress refactoring plus slack
  • Loading branch information
FahadDarw authored Jan 12, 2024
2 parents ba16fb2 + 04b0d55 commit 266911a
Show file tree
Hide file tree
Showing 10 changed files with 9,119 additions and 3,543 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ jobs:

- name: Run cypress (staging)
if: needs.set-env.outputs.environment == 'staging'
run: npm run cy:run -- --env url='${{ secrets.AZURE_ENDPOINT }}',grep='-dao',authorizationHeader='${{ secrets.CYPRESS_TEST_SECRET }}, academisationApiUrl=${{secrets.CYPRESS_ACADEMISATION_API_URL}}, academisationApiKey=${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}'
run: npm run cy:run -- --env url='${{ secrets.AZURE_ENDPOINT }}',grep='-dao',cypressTestSecret='${{ secrets.CYPRESS_TEST_SECRET }}, academisationApiUrl=${{secrets.CYPRESS_ACADEMISATION_API_URL}}, academisationApiKey=${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}'
env:
db: ${{ secrets.DB_CONNECTION_STRING }}

- name: Run cypress (dev)
if: needs.set-env.outputs.environment == 'dev'
run: npm run cy:run -- --env url='${{ secrets.AZURE_ENDPOINT }}',authorizationHeader='${{ secrets.CYPRESS_TEST_SECRET }}, academisationApiUrl=${{secrets.CYPRESS_ACADEMISATION_API_URL}}, academisationApiKey=${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}'
run: npm run cy:run -- --env url='${{ secrets.AZURE_ENDPOINT }}',cypressTestSecret='${{ secrets.CYPRESS_TEST_SECRET }}, academisationApiUrl=${{secrets.CYPRESS_ACADEMISATION_API_URL}}, academisationApiKey=${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}'
env:
db: ${{ secrets.DB_CONNECTION_STRING }}

Expand All @@ -173,3 +173,9 @@ jobs:
with:
name: screenshots-${{ needs.set-env.outputs.environment }}
path: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/screenshots

- name: Report results
if: always()
run: npm run cy:notify -- --custom-text="Environment ${{ needs.set-env.outputs.environment }}, See more information https://github.com/DFE-Digital/prepare-academy-conversions/actions/runs/${{github.run_id}}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
2 changes: 1 addition & 1 deletion .github/workflows/security-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
ZAP_API_KEY: ${{ secrets.ZAP_API_KEY }}
ZAP_ADDRESS: ${{ env.ZAP_ADDRESS }}
ZAP_PORT: ${{ env.ZAP_PORT }}
run: npm run cy:run -- --env url=$URL,authorizationHeader=$API_KEY
run: npm run cy:run -- --env url=$URL,cypressTestSecret=$API_KEY

- name: Get git sha
if: '!cancelled()'
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,5 @@ backend.vars
/terraform/Brewfile.lock.json

# sonar cloud
/Dfe.PrepareConversions/.sonarlint
/Dfe.PrepareConversions/.sonarlint
Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress.env.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class projectList extends BasePage {

static getNthProjectDeliveryOfficer(n = 0) {
this.checkProjectListPage()
return cy.get(`[id="delivery-officer-${n}"]`)
return cy.get(`[id="assigned-to-${n}"]`)
}

static filterProjectList(titleFilter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@
* @type {Cypress.PluginConfig}
*/

/// <reference types="cypress" />

// Load the TypeScript plugin
import * as webpackPreprocessor from '@cypress/webpack-preprocessor';

// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
require('eslint/src/plugin')(config)
}
on('file:preprocessor', webpackPreprocessor());

// Other configurations or plugins...

return config;
};

Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,15 @@ Cypress.Commands.add('generateProjectTempBtn', () => {
})

Cypress.Commands.add('enterDate', (idSelector, day, month, year) => {
cy.get(`[id*="${idSelector}-day"]`).as('day')
cy.get(`[id*="${idSelector}-month"]`).as('month')
cy.get(`[id*="${idSelector}-year"]`).as('year')

cy.get(`@day`).then((dayLoc) => {
dayLoc.should('be.visible')
dayLoc.clear()
dayLoc.type(day)
})
cy.get(`@month`).then((monthLoc) => {
monthLoc.should('be.visible')
monthLoc.clear()
monthLoc.type(month)
})
cy.get(`@year`).then((yearLoc) => {
yearLoc.should('be.visible')
yearLoc.clear()
yearLoc.type(year)
})
})
cy.get(`[id*="${idSelector}-day"]`).as('day');
cy.get(`[id*="${idSelector}-month"]`).as('month');
cy.get(`[id*="${idSelector}-year"]`).as('year');

cy.get('@day').should('be.visible').invoke('val', '').type(day);
cy.get('@month').should('be.visible').invoke('val', '').type(month);
cy.get('@year').should('be.visible').invoke('val', '').type(year);
});


// No Radio Btn
Cypress.Commands.add('NoRadioBtn', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ beforeEach(() => {
cy.intercept(
{ url: Cypress.env('url') + '/**', middleware: true },
//Add authorization to all Cypress requests
(req) => req.headers['Authorization'] = 'Bearer ' + Cypress.env('authorizationHeader'),
(req) => req.headers['Authorization'] = 'Bearer ' + Cypress.env('cypressTestSecret'),
(req) => req.headers['AuthorizationRole'] = 'conversions.create'
)
})
Expand Down
Loading

0 comments on commit 266911a

Please sign in to comment.