Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging conversion and transfers Cypress tests #1254

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 49 additions & 21 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,73 +41,101 @@ jobs:
]
container:
image: cypress/browsers:22.12.0
defaults:
run:
working-directory: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Prepare Cypress cache
# Step 1: Install Cypress for Transfers Tests
- name: Install Cypress for Transfers
run: npm install cypress
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareTransfers.CypressTests

- name: Run Transfers Tests (${{ inputs.environment }})
if: inputs.environment == 'staging' || inputs.environment == 'dev'
uses: cypress-io/github-action@v6
env:
CYPRESS_db: ${{ secrets.DB_CONNECTION_STRING }}
CYPRESS_url: ${{ secrets.AZURE_ENDPOINT }}
CYPRESS_cypressTestSecret: ${{ secrets.CYPRESS_TEST_SECRET }}
CYPRESS_academisationApiUrl: ${{ secrets.CYPRESS_ACADEMISATION_API_URL }}
CYPRESS_academisationApiKey: ${{ secrets.CYPRESS_ACADEMISATION_API_KEY }}
with:
runTests: false
browser: ${{ matrix.browser }}
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
browser: edge
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareTransfers.CypressTests
wait-on: ${{ secrets.AZURE_ENDPOINT }}
install: false

- name: Upload screenshots (Transfers)
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: screenshots-transfers-${{ inputs.environment }}-${{ matrix.browser }}
path: Dfe.PrepareConversions/Dfe.PrepareTransfers.CypressTests/cypress/screenshots

# Step 2: Install Cypress for Conversions Tests
- name: Install Cypress for Conversions
run: npm install cypress
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests

- name: Run (dev)
- name: Run Conversions (dev)
if: inputs.environment == 'dev'
uses: cypress-io/github-action@v6
env:
CYPRESS_db: ${{ secrets.DB_CONNECTION_STRING }}
CYPRESS_url: ${{ secrets.AZURE_ENDPOINT }}
CYPRESS_cypressTestSecret: ${{ secrets.CYPRESS_TEST_SECRET }}
CYPRESS_academisationApiUrl: ${{secrets.CYPRESS_ACADEMISATION_API_URL}}
CYPRESS_academisationApiKey: ${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}
CYPRESS_academisationApiUrl: ${{ secrets.CYPRESS_ACADEMISATION_API_URL }}
CYPRESS_academisationApiKey: ${{ secrets.CYPRESS_ACADEMISATION_API_KEY }}
with:
browser: ${{ matrix.browser }}
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
wait-on: ${{ secrets.AZURE_ENDPOINT }}
install: false

- name: Run (staging)
- name: Run Conversions (staging)
if: inputs.environment == 'staging'
uses: cypress-io/github-action@v6
env:
CYPRESS_db: ${{ secrets.DB_CONNECTION_STRING }}
CYPRESS_url: ${{ secrets.AZURE_ENDPOINT }}
CYPRESS_cypressTestSecret: ${{ secrets.CYPRESS_TEST_SECRET }}
CYPRESS_academisationApiUrl: ${{secrets.CYPRESS_ACADEMISATION_API_URL}}
CYPRESS_academisationApiKey: ${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}
CYPRESS_academisationApiUrl: ${{ secrets.CYPRESS_ACADEMISATION_API_URL }}
CYPRESS_academisationApiKey: ${{ secrets.CYPRESS_ACADEMISATION_API_KEY }}
CYPRESS_grep: '-dao'
with:
browser: ${{ matrix.browser }}
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
wait-on: ${{ secrets.AZURE_ENDPOINT }}
install: false

- name: Upload screenshots
- name: Upload screenshots (Conversions)
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: screenshots-${{ inputs.environment }}-${{ matrix.browser }}
name: screenshots-conversions-${{ inputs.environment }}-${{ matrix.browser }}
path: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/screenshots

- name: Generate report
# Step 3: Generate Combined Report
- name: Generate combined report
if: always()
run: |
mkdir mochareports
npm run generate:html:report
npm run generate:html:report --prefix Dfe.PrepareConversions/Dfe.PrepareTransfers.CypressTests
npm run generate:html:report --prefix Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
mv Dfe.PrepareConversions/Dfe.PrepareTransfers.CypressTests/mochareports/*.html mochareports/
mv Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/mochareports/*.html mochareports/
echo "Combined reports generated"
npx mochawesome-merge mochareports/*.html > mochareports/combined-reports-${{ inputs.environment }}-${{ matrix.browser }}.html

- name: Upload report
- name: Upload combined report
if: always()
uses: actions/upload-artifact@v4
with:
name: reports-${{ inputs.environment }}-${{ matrix.browser }}
path: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/mochareports
name: combined-reports-${{ inputs.environment }}-${{ matrix.browser }}
path: mochareports

- name: Report results
- name: Report results to Slack
if: always()
run: npm run cy:notify -- --custom-text="Environment ${{ inputs.environment }}, See more information https://github.com/DFE-Digital/prepare-academy-conversions/actions/runs/${{github.run_id}}"
env:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
videos/
screenshots/
downloads/
downloads/
cypress.env.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env node */

import { defineConfig } from 'cypress'
import { generateZapReport } from './cypress/plugins/generateZapReport'
import { defineConfig } from 'Cypress'
import { generateZapReport } from './cypress/plugins/generateZapReport.js'

export default defineConfig({
reporter: 'cypress-multi-reporters',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Scans each page for accessibility violations
// Note: there are some pages that cannot be scanned in this way as they require
// session data setting so must be done manually -
// transfers/outgoingtrustacademies and transfers/checkyouranswers

describe('Check accessibility of the different pages', () => {
it('Validate accessibility', () => {
cy.fixture('transfersLinks.json').then((transfersLinks) => {
transfersLinks.forEach((link) => {
cy.visit(`${Cypress.env('transfersUrl')}${link}`)
cy.excuteAccessibilityTests()
})
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
describe('Cookie Policy', () => {

beforeEach(() => {
cy.visit(Cypress.env('url'))
})

it('Should show cookie banner when no preference set', () => {
cy.get('[data-test="cookie-banner"]').should('be.visible')
})

context("When cookie banner clicked", () => {
beforeEach(() => {
cy.get('[data-test="cookie-banner-accept"]').click()
})

it('Should consent to cookies from cookie header button', () => {
cy.getCookie('.ManageAnAcademyTransfer.Consent')
.should('exist')
.should('have.property', 'value', 'True')
});

it('Should hide the cookie banner when consent has been given', () => {
cy.get("[data-test='cookie-banner']").should('not.exist')
});
})

context("When cookie link in footer clicked", () => {
beforeEach(() => {
cy.get("[data-test='cookie-preferences']").click()
})

it('Should navigate to cookies page', () => {
cy.url().then(href => {
expect(href).includes('cookie-preferences')
});
});

it('Should set cookie preferences', () => {
cy.get('#cookie-consent-deny').click()
cy.get("[data-qa='submit']").click()
cy.getCookie('.ManageAnAcademyTransfer.Consent').should('have.property', 'value', 'False')
});

it('Should return show success banner', () => {
cy.get('#cookie-consent-deny').click()
cy.get("[data-qa='submit']").click()
cy.get('[data-test="success-banner-return-link"]').click()
cy.url().then(href => {
expect(href).includes('/home')
});
});
})
})
Loading
Loading