Skip to content

Commit

Permalink
EYQB-650: New smoke tests and github workflow changes (#369)
Browse files Browse the repository at this point in the history
* EYQB-650: New smoke tests and github workflow changes

* Updated action name
  • Loading branch information
sam-c-dfe authored Sep 20, 2024
1 parent 0899d8d commit 085444e
Show file tree
Hide file tree
Showing 8 changed files with 2,131 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/actions/run-smoke-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run smoke tests
description: Run smoke tests using Cypress

inputs:
webapp_name:
required: true
type: string
slot_name:
required: true
type: string
auth_secret:
required: true
type: string

runs:
using: composite

steps:
- name: Run Smoke Tests
uses: cypress-io/github-action@v6
if: success() || failure()
with:
env: auth_secret="${{ inputs.auth_secret }}"
working-directory: ./tests/Dfe.EarlyYearsQualification.SmokeTests/
browser: chrome
config: baseUrl="https://${{ inputs.webapp_name }}-${{ inputs.slot_name }}.azurewebsites.net"

- name: Store screenshots on test failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: ./tests/Dfe.EarlyYearsQualification.SmokeTests/cypress/screenshots
8 changes: 8 additions & 0 deletions .github/workflows/main-build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ jobs:
with:
webapp_name: ${{ vars.WEBAPP_NAME }}
slot_name: ${{ vars.WEBAPP_SLOT_NAME }}

# Run smoke test
- name: Run smoke tests against slot
uses: ./.github/actions/run-smoke-tests
with:
webapp_name: ${{ vars.WEBAPP_NAME }}
slot_name: ${{ vars.WEBAPP_SLOT_NAME }}
auth_secret: ${{ secrets.WEBAPP_E2E_ACCESS_KEY }}

# Swap the slots
- name: Swap to the production slot
Expand Down
19 changes: 19 additions & 0 deletions tests/Dfe.EarlyYearsQualification.SmokeTests/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
env: {
auth_secret: 'CX' // dummy value: pass in using Cypress command line --env auth_secret=an-acceptable-secret-value
},
e2e: {
baseUrl: "http://127.0.0.1:5025/",
setupNodeEvents(on, config) {
on('task', {
log(message) {
console.log(message)
return null
}
})
// implement node event listeners here
}
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
describe('A spec used to smoke test the environment once a deployment has happened', () => {
beforeEach(() => {
cy.setCookie('auth-secret', Cypress.env('auth_secret'));
cy.visit("/");
cy.get('.govuk-button--start').should('exist');
})

it("should return search results", () => {
// home page
cy.get('.govuk-button--start').click();

// where-was-the-qualification-awarded page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/where-was-the-qualification-awarded');
})

cy.get('#england').click();
cy.get('button[id="question-submit"]').click();

// when-was-the-qualification-started page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/when-was-the-qualification-started');
})

cy.get('#date-started-month').type("7");
cy.get('#date-started-year').type("2015");
cy.get('button[id="question-submit"]').click();

// what-level-is-the-qualification page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/what-level-is-the-qualification');
})
cy.get('#0').click(); // Select not sure
cy.get('button[id="question-submit"]').click();

// what-is-the-awarding-organisation page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/what-is-the-awarding-organisation');
})

cy.get('#awarding-organisation-not-in-list').click(); // Tick the not on the list
cy.get('button[id="question-submit"]').click();

// qualifications page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/qualifications');
})

// If this shows then no qualifications are getting returned indicating possible issue
cy.get('#no-result-content').should('not.exist');
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Loading

0 comments on commit 085444e

Please sign in to comment.