Coder Social home page Coder Social logo

nfdiv-frontend's Introduction

nfdiv-frontend

License: MIT Quality Gate Status Reliability Rating Vulnerabilities Coverage

nfdiv-frontendnfdiv-case-apinfdiv-shared-infrastructurenfdiv-performancenfdiv-solicitor-e2e-tests


Citizen view
Caseworker view

Getting Started

Prerequisites

Running the application requires the following tools to be installed in your environment:

Running the application

Install dependencies by executing the following command:

yarn install

Bundle:

yarn webpack

Start server:

yarn start

The application's home page will be available at https://localhost:3001

Running end-to-end

The application makes calls to case orchestration service. Make sure you have this running to run the frontend e2e.

Running the scripts present would require zsh to be installed.

Please see https://www.freecodecamp.org/news/how-to-configure-your-macos-terminal-with-zsh-like-a-pro-c0ab3f3c1156/ if zsh is not installed on your machine. Steps 1 to 3 of the above link should suffice.

Running with Docker

Create docker image:

docker-compose build

Run the application by executing the following command:

docker-compose up

This will start the frontend container exposing the application's port 3001.

In order to test if the application is up, you can visit https://localhost:3001 in your browser.

Developing

Starting the server in development mode:

yarn build
DEBUG=axios yarn start:dev

Code style

We use Prettier alongside ESLint and sass-lint

Running the linting with auto fix:

yarn lint --fix

Running the tests

Unit tests

We uses Jest as the test engine. You can run unit tests by executing the following command:

yarn test

Functional tests

Running the functional tests:

TEST_HEADLESS=false yarn test:cucumber

Note: By default tests are run heedlessly (i.e. without displaying the browser) setting the TEST_HEADLESS flag to false will open the test browser window allowing you to see whats happening in realtime.

Running the functional tests against local Docker:

NODE_ENV=docker yarn test:cucumber

Note: Other options can still be used with the above command

Running a single test:

yarn test:cucumber:grep 'Name of Feature, Scenario, or @tag'

Viewing functional test reports locally:

yarn test:cucumber:reports

To view the report from Jenkins, navigate to the build artefacts page scroll to the bottom and click “Download All”.

Then extract it and run:

npx allure-commandline serve ~/Downloads/archive/functional-output/functional/reports

Accessibility tests

Running accessibility tests:

yarn test:a11y

By default all of the pages in listed urls.ts will be tested.

Cross browser tests

Cross browser tests are run via CodeceptJS using the Playwright plugin which tests Chrome/Edge, Safari and Firefox. The WebDriver plugin is used to test Edge on Windows via Sauce Labs.

Cross browser tests are automatically run via the nightly Jenkins pipeline.

Running cross browser tests locally, start the server then run:

# Playwright - Chrome/Edge, Safari and Firefox
TEST_HEADLESS=false yarn test:crossbrowser:playwright

To run the cross browser tests using Sauce Labs, install the Sauce Labs connect proxy tunnel and set the following environment variables with your own Sauce Labs account details: SAUCE_USERNAME, SAUCE_ACCESS_KEY, and SAUCE_TUNNEL_IDENTIFIER.

# WebDriver (via Sauce Labs)
sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY -x https://eu-central-1.saucelabs.com/rest/v1 -i $SAUCE_TUNNEL_IDENTIFIER -B all
yarn test:crossbrowser:sauce

See TESTING.md for more information on testing processes.

Security

CSRF prevention

Cross-Site Request Forgery prevention has already been set up, at the application level. However, you need to make sure that CSRF token is present in every HTML form that requires it. For that purpose you can use the csrfProtection macro. Your njk file would include it like this:

{% from "macros/csrf.njk" import csrfProtection %}
<form>{{ csrfProtection(csrfToken) }}</form>

Helmet

This application uses Helmet, which adds various security-related HTTP headers to the responses. Apart from default Helmet functions, following headers are set:

There is a configuration section related with those headers, where you can specify:

  • referrerPolicy - value of the Referrer-Policy header

Here's an example setup:

"security": {
  "referrerPolicy": "origin",
}

Make sure you have those values set correctly for your application.

Healthcheck

The application exposes a health endpoint https://localhost:3001/health, created with the use of Nodejs Healthcheck library. This endpoint is defined in health.ts file. Make sure you adjust it correctly in your application. In particular, remember to replace the sample check with checks specific to your frontend app, e.g. the ones verifying the state of each service it depends on.

Migrating backend field changes

Once you have created a NFDIV-Case-API Pull Request with the case definition changes, update CCD_URL in values.yaml and services.case.url in default.yaml so that the CCD Data Store is pointing at the Preview version deployed as part of your No Fault Divorce Case API pull request.

For example: CCD_URL: 'https://ccd-data-store-api-nfdiv-case-api-pr-232.preview.platform.hmcts.net'

Next, run the generateTypescript Gradle task in the Case API. Once this has completed, navigate to build/ts/index.ts in the Case API and copy the contents of the file. Navigate back to the frontend repository and paste the contents of the file into definition.ts. Depending on how your IDE is configured, the formatting of strings from double to single quotes should be carried out automatically.

Once you have pasted the code into definition.ts you may notice some compilation errors in case.ts, from-api-format.ts and to-api-format.ts. This is typically caused by either changes to the field name or to the field type. You will need to resolve these compilation errors manually.

You will now be in a position to test your changes either in isolation (yarn start:dev) or with Docker (yarn start:docker).

One final important point to remember is that the CCD_URL in values.yaml and services.case.url in default.yaml will need to be reverted to their original values once migration is complete and before any Pull Requests into master are merged.

License

This project is licensed under the MIT License - see the LICENSE file for details.

nfdiv-frontend's People

Contributors

adamg-hmcts avatar amoriartymoj avatar aramchurn21 avatar benouaer avatar bweeks-justicegovuk avatar damongreen123 avatar danielbe11 avatar danotade avatar delythjustice avatar dependabot-preview[bot] avatar dependabot[bot] avatar faisalmoj avatar kasi-subramaniam avatar lara-mpt avatar linusnorton avatar mapingo avatar mark-butler-solirius avatar mokainos avatar nigeldunne avatar nitinprabhu avatar pallavijustice avatar renovate[bot] avatar rmtsrc avatar sanjayparekh-hmcts avatar sarahlittlejohn avatar tiagreaney avatar timja avatar tomxelliott avatar velimd avatar willorchard avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nfdiv-frontend's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm csurf Unavailable
npm node-sass Unavailable

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update dependency @playwright/test to v1.47.1
  • chore(deps): update dependency npm-run-all2 to v6.2.3

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

docker-compose
docker-compose.yml
dockerfile
Dockerfile
  • hmctspublic.azurecr.io/base/node 20-alpine
helm-values
charts/nfdiv-frontend/values.yaml
helmv3
charts/nfdiv-frontend/Chart.yaml
  • nodejs 3.1.1
  • idam-pr 2.3.0
npm
package.json
  • @hmcts/cookie-manager 1.0.0
  • @hmcts/frontend 0.0.50-alpha
  • @hmcts/nodejs-healthcheck 1.8.5
  • @hmcts/nodejs-logging 4.0.4
  • @hmcts/properties-volume 1.2.0
  • @types/config 3.3.5
  • @types/cookie-parser 1.4.7
  • @types/csurf 1.11.5
  • @types/es6-promisify 6.0.4
  • @types/express 4.17.21
  • @types/express-session 1.18.0
  • @types/glob 8.1.0
  • @types/lodash 4.17.7
  • @types/multer 1.4.12
  • @types/negotiator 0.6.3
  • @types/node 20.16.5
  • @types/nunjucks 3.2.6
  • @types/require-directory 2.1.6
  • @types/serve-favicon 2.5.7
  • @types/session-file-store 1.2.5
  • @types/toobusy-js 0.5.4
  • @types/uuid 10.0.0
  • @uppy/core 3.13.1
  • @uppy/drop-target 2.1.0
  • @uppy/file-input 3.1.2
  • @uppy/progress-bar 3.1.1
  • @uppy/xhr-upload 3.6.8
  • applicationinsights 2.9.6
  • autobind-decorator 2.4.0
  • axios 1.7.7
  • config 3.3.12
  • connect-redis 7.1.1
  • cookie-parser 1.4.6
  • csurf 1.11.0
  • dayjs 1.11.13
  • email-validator 2.0.4
  • express 4.21.0
  • express-http-proxy 2.1.1
  • express-nunjucks 3.1.2
  • express-session 1.18.0
  • form-data 4.0.0
  • glob 11.0.0
  • govuk-frontend 5.6.0
  • helmet 7.1.0
  • http-status-codes 2.3.0
  • js-yaml 4.1.0
  • jwt-decode 4.0.0
  • lodash 4.17.21
  • multer 1.4.5-lts.1
  • negotiator 0.6.3
  • node-cache 5.1.2
  • nunjucks 3.2.4
  • otplib 12.0.1
  • pdfjs-dist 4.6.82
  • redis 4.7.0
  • require-directory 2.1.1
  • serve-favicon 2.5.0
  • session-file-store 1.5.0
  • striptags 3.2.0
  • tar ^7.0.0
  • toobusy-js 0.5.1
  • ts-node 10.9.2
  • tsconfig-paths 4.2.0
  • typescript 5.6.2
  • uuid 10.0.0
  • @codeceptjs/allure-legacy 1.0.2
  • @playwright/test 1.47.0
  • @types/jest 29.5.13
  • @typescript-eslint/eslint-plugin 7.18.0
  • @typescript-eslint/parser 7.18.0
  • @wdio/cli 9.0.9
  • @wdio/sauce-service 9.0.9
  • allure-commandline 2.30.0
  • axios-debug-log 1.0.0
  • codeceptjs 3.6.5
  • copy-webpack-plugin 12.0.2
  • css-loader 7.1.2
  • eslint 8.57.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-import 2.29.1
  • eslint-plugin-jest 28.8.3
  • eslint-plugin-prettier 5.2.1
  • html-webpack-plugin 5.6.0
  • husky 9.1.6
  • jest 29.7.0
  • jest-html-reporters ^3.1.7
  • jest-junit ^16.0.0
  • lint-staged 15.2.10
  • mini-css-extract-plugin 2.9.1
  • mocha ^10.5.2
  • mochawesome ^7.1.3
  • mochawesome-merge ^4.3.0
  • mochawesome-report-generator ^6.2.0
  • node-sass 9.0.0
  • nodemon 3.1.4
  • npm-run-all2 6.2.2
  • pa11y 8.0.0
  • prettier 3.1.1
  • sass-loader 16.0.1
  • sonar-scanner 3.1.0
  • style-loader 4.0.0
  • ts-jest 29.2.5
  • ts-loader 9.5.1
  • webdriverio 9.0.9
  • webpack 5.94.0
  • webpack-cli 5.1.4
  • webpack-dev-middleware 7.4.2
  • webpack-node-externals 3.0.0
  • node >=16.15.0
  • http-cache-semantics 4.1.1
  • axios 1.7.7
  • yarn 3.8.5
nvm
.nvmrc
  • node 20.17.0
terraform
infrastructure/main.tf
infrastructure/state.tf
  • azurerm ~> 4.0
infrastructure/versions.tf
  • hashicorp/terraform >= 1.3.7
terraform-version
infrastructure/.terraform-version
  • hashicorp/terraform 1.9.5

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.