Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Ionic/Cordova Vehicle Testing Application.

License

Notifications You must be signed in to change notification settings

dvsa/cvs-app-mobile-retired

Repository files navigation

cvs-app-mobile

Note: this repository has been archived as a result of re-platforming the application. Please see this repository for future development

The app, added to DVSA mobile devices, allows assessors to check and record all aspects of a vehicle’s safety digitally ​

Synopsis

​ This project contains the mobile app that demonstrates a business workflow for CVS Alpha. ​

Architecture

VTA High Level View

End to end design

All in one view

Microservices and backend

VTA uses the following AWS backend microservices:

Azure is used for identity management and in itegrates with EDH

Getting Started

This project using Ionic, if you don't have ionic follow these steps. Please install and configure nvm with this node version so it can be used during installation 10.x. The application currently run on 10.18.1, please run nvm use once the correct node(s) versions have been downloaded with nvm.

Security

scanrepo

Please install and run the following securiy programs as part of your testing process:

repo-security-scanner and after installing run it with git log -p | scanrepo.

Sonarqube

In order to generate SonarQube reports on local, follow the steps (brew or docker approach is recommended):

  • install sonarqube using brew - formula -
  • change sonar.host.url to point to localhost, by default, sonar runs on http://localhost:9000.
  • run the sonar server - sonar start - then perform your analysis - npm run sonar-scanner -
  • report will be available on http://localhost:9000/dashboard?id=org.sonarqube%3Acvs-app-mobile.

or alternatively you can manually install sonar server and its scanner:

  • Download SonarQube server - sonarqube
  • Download SonarQube scanner - scanner
  • Add sonar-scanner in environment variables -> In bash_profile add the line export PATH=<PATH_TO_SONAR_SCANNER>/sonar-scanner-3.3.0.1492-macosx/bin:$PATH - Add sonar-scanner in environment variables -> In bash_profile add the line "export PATH=<PATH_TO_SONAR_SCANNER>/sonar-scanner-3.3.0.1492-macosx/bin:$PATH"
  • Start the SonarQube server -> cd <PATH_TO_SONARQUBE_SERVER>/bin/macosx-universal-64 ./sonar.sh start - Start the SonarQube server - cd <PATH_TO_SONARQUBE_SERVER>/bin/macosx-universal-64 ./sonar.sh start
  • In the microservice folder run the command -> npm run sonar-scanner - In the microservice folder run the command - npm run sonar-scanner

API Reference

​ This repo does not contain references to API endpoints, and requires them to be injected at build time using values from .env file. The scripts/config/create-config.ts generates a config/application.<appType>.ts. Please rename your env file to .env with the appropriate values/secrets.

Running the project

It is recommended to use 10.x to run this project (supported versions up to 12) with the relevant node version(s), please refer to the package.json meta-data to find out about the version or .nvmrc file in the project.

To get a working build running locally follow these steps:

  1. Clone the repository.

  2. Rename the env to .env. Go to .env section and under the subheading .env copy and paste the content into the .env file. Source your .env file by running source .env (Linux users)

  3. You can use nvm use to switch to the supported version of 10.x if you have more than one version of node installed Run npm install.

  4. You can launch the app in the web browser of choice at this stage:
    Run npm run start or npm run emulate:web to start. Gotcha: ⚠️ The authentication process requires a new tab to be opened so that the user name and password can be entered. Most browsers block this by default. So you should allow the browser pop up option ⚠️ .

Build in xCode and run app natively (ios only)

The application runs on Xcode 11 which will need to be installed on your machine. Once the platform is successfully installed, you can run the following script:

# use this to cleanup previously generated cordova platorm files and folders. Only needed for clean up to aid native build re-installation
npm run prepare:ios:remove
# use this to install and build the supported cordova-ios version 5 for native execution
npm run prepare:ios

You can then go to platforms/ios/Vehicle Testing.xcodeproj and open with xcode and run the app using IPhone 8 (our target device).

# use this in development mode to build any file changes for reloading
npm run build:ios

Known issues

Builds in the XCode may fail due to XCode 11 backward compatability with some outdated cordova-plugins, ionic 3. Even if the cordova build is successful, the XCode build may sometimes fails. Should it happen, remove the platforms (ios) and plugins and reinstall the ios platform.

npm run prepare:ios:remove
npm run prepare:ios

in the emulator:

You can run the following script - npm run emulate:ios to run the application in the emulator with the live reload once you retrieve your IPhone emulator id.

You will first need to get your iPhone 8 Plus that you can find under Simulator > Hardware menu > Devices > Manage devices. The ID will be shown on the Identifier key. You can then copy paste the value in the env file to the following variable to your .env (Please see placeholder env file in project):

export IPHONE8_P_ID=

For testing on an iOS device:

Run npm run build:ios script and open your .xcodeproj file to build the hybrid app.

Contributing to the project

Code style

Committing code

Before commiting code, please make sure scanrepo is configured.
We use commitlint when commiting code so make sure you are familiar with conventional commit format.

Testing

Unit testing and integration

In order to test, you need to run the following:

  • npm run test:unit:watch for unit tests.
  • npm run test:unit:coverage for code coverage
  • npm run sonar-scanner for sonarqube.

Framework: Jasmine with Karma runner.

End to end

Infrastructure

For the CI/CD and automation please refer to the following pages for further details:

Sentry Integration and Setup for production logs

The app would have been fully integrated with Sentry at this stage in the setup process. However if you wish to create a different sentry account you would need to follow these steps:

  • Create an account in https://sentry.io/signup/ and create a default project to receive mobile app generated errors
  • npm install --save-dev @sentry/wizard to help in configuring the mobile app with Sentry.io for the first time i.e. when the app does not exist in Sentry
  • Add the relevant Sentry keys to your .env file.
  • Run npm run config when used locally or in the pipeline will create:
    • sentry.properties file provided that .env file already exist with required key/value pairs This file would have also being generated during @sentry/wizard integration setup
    • SENTRY_DNS when set to blank in the .env file will disable sentry integration with the mobile app. Hence no logs will be sent to sentry for analysis.