Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
paullocknimble committed Jun 10, 2024
2 parents a415119 + b9a0393 commit bc2c171
Show file tree
Hide file tree
Showing 54 changed files with 866 additions and 321 deletions.
60 changes: 4 additions & 56 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ jobs:
name: Tag and release
needs: [ set-env, deploy-image ]
runs-on: ubuntu-22.04
if: needs.set-env.outputs.environment == 'production'
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -89,58 +88,7 @@ jobs:
name: Run Cypress Tests
if: needs.set-env.outputs.environment == 'staging' || needs.set-env.outputs.environment == 'dev'
needs: [ deploy-image, set-env ]
runs-on: ubuntu-22.04
environment: ${{ needs.set-env.outputs.environment }}
defaults:
run:
working-directory: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Npm install
run: npm install

- name: Run cypress (staging)
if: needs.set-env.outputs.environment == 'staging'
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 }}',cypressTestSecret='${{ secrets.CYPRESS_TEST_SECRET }}, academisationApiUrl=${{secrets.CYPRESS_ACADEMISATION_API_URL}}, academisationApiKey=${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}'
env:
db: ${{ secrets.DB_CONNECTION_STRING }}

- name: Upload screenshots
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: screenshots-${{ needs.set-env.outputs.environment }}
path: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/screenshots

- name: Generate report
if: always()
run: |
mkdir mochareports
npm run generate:html:report
- name: Upload report
if: always()
uses: actions/upload-artifact@v4
with:
name: reports-${{ needs.set-env.outputs.environment }}
path: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/mochareports

- 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 }}
uses: ./.github/workflows/cypress.yml
with:
environment: ${{ needs.set-env.outputs.environment }}
secrets: inherit
34 changes: 32 additions & 2 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
name: Run Cypress Accessibility checks
name: Run Cypress tests

on:
workflow_call:
inputs:
environment:
required: true
type: string
secrets:
AZURE_ENDPOINT:
required: true
CYPRESS_TEST_SECRET:
required: true
CYPRESS_ACADEMISATION_API_URL:
required: true
CYPRESS_ACADEMISATION_API_KEY:
required: true
DB_CONNECTION_STRING:
required: true
SLACK_WEBHOOK_URL:
required: true
workflow_dispatch:
inputs:
environment:
description: 'Environment to run tests against'
required: true
type: environment

concurrency:
group: ${{ github.workflow }}
Expand All @@ -13,7 +36,7 @@ jobs:
cypress-tests:
name: Run Cypress Tests
runs-on: ubuntu-latest
environment: dev
environment: ${{ inputs.environment }}
defaults:
run:
working-directory: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
Expand All @@ -31,10 +54,17 @@ jobs:
run: npm install

- name: Run cypress (dev)
if: inputs.environment == 'dev'
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 }}

- name: Run cypress (staging)
if: inputs.environment == 'staging'
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: Upload screenshots
if: ${{ failure() }}
uses: actions/upload-artifact@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ export default defineConfig({
}
})

on('task', {
log(message) {
console.log(message);
return null;
},
});

require('./cypress/plugins/index.js')(on, config)
return config;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import projectTaskList from "../../pages/projectTaskList";
import { decisionPage } from '../../pages/decisionPage';
import { Logger } from '../../support/logger'

describe('Decisions Tests', () => {
beforeEach(() => {
Logger.log("Visit the homepage before each test");
projectTaskList.getHomePage();
});

it('Creating a conversion project and recording a new decision then editing the decision', () => {
Logger.log("Go to the home page then click create new conversion");
projectTaskList.clickCreateNewConversionBtn();

Logger.log("Click on create new conversion button on the next page");
projectTaskList.clickCreateNewConversionBtn();

Logger.log("Search and select the school, then click continue");
decisionPage.searchSchool('Manchester Academy (134224)').clickContinue();

Logger.log("Select no and continue on the next 3 pages regarding the school");
decisionPage.selectNoAndContinue();
decisionPage.selectNoAndContinue();
decisionPage.selectNoAndContinue();

Logger.log("Verify the selected school details");
decisionPage.assertSchoolDetails(
'Manchester Academy',
'134224',
'Manchester',
'Academy'
);

Logger.log("Click school details are correct, click continue");
decisionPage.clickContinue();

Logger.log("Search for the created project then select first one on the list");
decisionPage.clickOnFirstProject();

Logger.log("Click on record a decision menubar button");
decisionPage.clickRecordDecisionMenu();

Logger.log("Click on record a decision button");
decisionPage.clickRecordDecision();

Logger.log("Record the decision with the necessary details");
decisionPage.makeDecision("approved")
.decsionMaker("grade6")
.enterDecisionMakerName('Fahad Darwish')
.selectNoConditions()
.enterDecisionDate('12', '12', '2023')
.verifyDecisionDetails('Approved', 'Grade 6', 'Fahad Darwish', 'No', '12 December 2023');

Logger.log("Verify that decision was recoded successfully then change the decision details, verify the changes");
decisionPage.changeDecisionDetails();

Logger.log("Change the current decision to DAO (Directive Academy Order) revoked and verify the changes");
decisionPage.changeDecisionDAODetails()

});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
export class DecisionPage {


searchSchool(schoolName) {
cy.get('#SearchQuery').type(schoolName);
cy.get('.autocomplete__input--default').first().click();
return this;
}

clickContinue() {
cy.get('[data-id="submit"]').click();
return this;
}

selectNoAndContinue() {
cy.get('[data-cy="select-legal-input-no"]').click();
cy.get('[data-cy="select-common-submitbutton"]').click();
return this;
}

assertSchoolDetails(schoolName, urn, localAuthority, schoolType) {
cy.get('[data-cy="school-name"]').should('contain', schoolName);
cy.get('.govuk-summary-list__value').eq(1).should('contain', urn);
cy.get('.govuk-summary-list__value').eq(3).should('contain', localAuthority);
cy.get('.govuk-summary-list__value').eq(5).should('contain', schoolType)
return this;
}

clickOnFirstProject() {
cy.get('[data-cy="select-projectlist-filter-title"]').type('Manchester Academy');
cy.get('[data-cy="select-projectlist-filter-apply"]').click();
cy.get('[data-cy="trust-name-Manchester Academy-0"]').click();
return this;
}

clickRecordDecisionMenu() {
cy.get('[data-cy="record_decision_menu"]').click();
return this;
}

clickRecordDecision() {
cy.get('[data-cy="record_decision_btn"]').click();
return this;
}

makeDecision(decision) {
cy.get(`#${decision}-radio`).click();
cy.get('#submit-btn').click();
return this;
}

decsionMaker(grade) {
cy.get(`#${grade}-radio`).click();
cy.get('#submit-btn').click();
return this;
}

enterDecisionMakerName(name) {
cy.get('#decision-maker-name').type(name);
cy.get('#submit-btn').click();
return this;
}

selectNoConditions() {
cy.get('#no-radio').click();
cy.get('#submit-btn').click();
return this;
}

enterDecisionDate(day, month, year) {
cy.get('#decision-date-day').type(day);
cy.get('#decision-date-month').type(month);
cy.get('#decision-date-year').type(year);
cy.get('#submit-btn').click();
return this;
}

dateAOWasSent(day, month, year) {
cy.get('#academy-order-date-day').type(day);
cy.get('#academy-order-date-month').type(month);
cy.get('#academy-order-date-year').type(year);
cy.get('#submit-btn').click();
return this;
}

verifyDecisionDetails(decision, grade, name, conditions, date) {
cy.get('#decision').should('contain', decision);
cy.get('#decision-made-by').eq(0).should('contain', grade);
cy.get('#decision-maker-name').should('contain', name);
cy.get('#condition-set').should('contain', conditions);
cy.get('#decision-date').should('contain', date);
cy.get('#submit-btn').click();
return this;
}

verifyDecisionDetailsBeforeChanging(decision, name, conditions, date) {
cy.get('#decision').should('contain', decision);
cy.get('#decision-maker-name').should('contain', name);
cy.get('#condition-set').should('contain', conditions);
cy.get('#decision-date').should('contain', date);
return this;
}

verifyDecisionDetailsAfterChanging(decision, name, date) {
cy.get('#decision').should('contain', decision);
cy.get('#decision-made-by').should('contain', name);
console.log('Date:', date);
cy.get('#decision-date').should('contain', date);
return this;
}

changeDecisionDetails() {
cy.get('[data-cy="record_decision_menu"]').click();
this.verifyDecisionDetailsBeforeChanging('Approved', 'Fahad Darwish', 'No', '12 December 2023');
cy.get('#record-decision-link').click();
cy.get('#declined-radio').click();
cy.get('#submit-btn').click();
cy.get('#directorgeneral-radio').click();
cy.get('#submit-btn').click();
//decision maker name will stay as name Fahad Darwish then click continue
cy.get('#submit-btn').click();
cy.get('#declined-reasons-finance').click();
cy.get('#reason-finance').type('Fahads Cypress Reason is Finance');
cy.get('#submit-btn').click();

//change the date to 12th November 2023
cy.get('#decision-date-day').clear();
cy.get('#decision-date-day').type('12');
cy.get('#decision-date-month').clear();
cy.get('#decision-date-month').type('11');
cy.get('#decision-date-year').clear();
cy.get('#decision-date-year').type('2023');
cy.get('#submit-btn').click();
this.verifyDecisionDetailsAfterChanging('Declined', 'Director General', '12 November 2023');
cy.get('#submit-btn').click();
return this;
}
changeDecisionDAODetails() {
cy.get('[data-cy="record_decision_menu"]').click();
cy.get('#record-decision-link').click();
cy.get('#daorevoked-radio').click();
cy.get('#submit-btn').click();
cy.get('#submit-btn').click();
cy.get('#submit-btn').click();
cy.get('#schoolclosedorclosing-checkbox').click();
cy.get('#schoolclosedorclosing-txtarea').type('Cypress Test Fahad - Reason school is closing');
cy.get('#submit-btn').click();
cy.get('#submit-btn').click();
this.verifyDecisionDetailsAfterChanging('DAO', 'Director General', '12 November 2023');
return this;
}
}


export const decisionPage = new DecisionPage();
Loading

0 comments on commit bc2c171

Please sign in to comment.