Skip to content

DFE-Digital/check-an-early-years-qualification

Repository files navigation

Check an early years qualification

A public service that allows for managers in childcare positions that require child care certifications e.g. nurseries to check a job applicants certifications against the position they are applying for.

Status badges

PR check Development build & deploy Release build & deploy SonarCloud Terraform PR Terraform Azure deploy OWASP ZAP

Prototype

The prototype can be found here.

Project structure

check-an-early-years-qualification/
├─ src/
|   ├─ Dfe.EarlyYearsQualification.Web - the .Net MVC application.
|   ├─ Dfe.EarlyYearsQualification.Node - a node.js project used to import, minify and export Gov.UK and DfE css styling for consumption by the MVC app.
|   ├─ Dfe.EarlyYearsQualification.Content - Project to store all the Contentful SDK helpers and models.
├─ tests/
|   ├─ Dfe.EarlyYearsQualification.E2ETests - a Cypress Project used to run E2E tests across multiple browsers
|   ├─ Dfe.EarlyYearsQualification.UnitTests - a .NET MSTests project used to build and run unit tests.
├─ terraform/ - Terraform project used to implement all the Azure infrastructure as code.

Dfe.EarlyYearsQualification.Web

Requirements

  • .Net 8

Development Setup

Azure environment variables

  • In order for the application to be run locally, you need to add the Dev Service Principal client id and secret to your launchSettings.json file Replace the environment variables object in the http profile with the following:
"environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "AZURE_TENANT_ID": "<TENANT_ID>",
        "AZURE_CLIENT_ID": "<CLIENT_ID>",
        "AZURE_CLIENT_SECRET": "<CLIENT_SECRET>",
      }

Speak to one of the developers about getting the values for the above settings.

Contentful Setup

  • We are using dotnet user-secrets to manage the contentful secrets.
  • We have a .sh script called set-contentful-secrets.sh that will help you set these up. Go to the Contentful space to get access to the: Delivery API Key, Preview API Key and Space ID.
  • Run this script and copy paste the keys in and you're all set!

Unit testing

To run the unit tests locally make sure you are in the root directory and then you can use the following command:

dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings

This will pull in the exclusions such as the .cshtml files and will replicate coverage in the GitHub Actions.

End to end/Smoke testing

End to end tests are ran using Playwright.

To run the tests, run the following commands:

  • Navigate to the correct folder, be it:
    • cd tests/Dfe.EarlyYearsQualification.E2ETests for the E2E tests.
    • cd tests/Dfe.EarlyYearsQualification.SmokeTests/playwright for the smoke tests.
  • Tell Node Version Manager that you want the latest version with: nvm use node --lts
  • Run the tests with: npx playwright install (install all playwright browsers)
  • Run the tests with: npx playwright test (add --ui to run the tests in playwrights UI)

Problems with Safari?

If you notice you are having issues with running Safari tests locally and them failing then there is a fix.

This is happening due to because Safari strictly enforcing the upgrade-insecure-requests header. This is converting the HTTP requests to HTTPS.

To fix this, comment out this line in the web app's Program.cs. This will remove the header from all requests and should let Safari use HTTP.