This repository is archived due to Sepes being decomissioned and as of Q2 2023 not in production.
Source code for the Sepes web application
Use conventional commits as described in https://github.com/equinor/sdscoredev-handbook#git-commits
Valid scope
-s for Sepes are:
- study
- sandbox
- dataset
The command "npm run test" or "npm test" runs all tests with filename including .test.filename. There are two dummy tests in the projects already under the folder named "tests". To get coverage, append the command "-- --coverage". So it will be "npm run test -- --coverage".
There is a script named runcypress.ps1 in the repo. When you run this script you will get two options: One for running cypress in console, and one in window mode. These tests will run as a mock user and is a true E2E test.
Old way:
The command "npx cypress open" will open a new window containg all the cypress tests in the project. Clicking one will open a broweser window and run the test. The tests need an Token to work. To get this token is now a manual process. Before running a test. do these steps:
- Npm start and run the application
- Open your browser and navigate to application
- Click F12 and go to the application tab
- Find "Session Store" and look after "access token". A very long string of numbers and charachters. Copy it
- Paste access token into the variable "cyToken" in cypress/support/commands.js
- Run npx cypress open
Jest and cypress test will run with every pull request. Long cypress test will be put in it's own folder and rund at night time. To get the coverage report, click on either the jest or cypress action, and it will be an artifact there.
With pull request, the pipeline will create comments with a short overview of the results from testing.
When creating a PR, you can pick a label named "Run all tests" to run all the cypress tests in the project. If you are wondering what tests will run, look in the cypress folder.
If you do not want to run any tests, pick the label named "Do not run tests".
If you change labels, they will only apply if you push a new commit or create a new pull request. You can not add a label and rerun the tests after creating a pull request (Without commiting).
- Clone project into local folder
- Npm install in root folder of project
- Create a file named "docker-compose.yml". Inside this file, you can create environment variables that can be used in the app. For instance ClientID or redirectUris
version: "3.7"
services:
web:
build: .
ports:
- 8080:3000
environment:
- REACT_APP_SEPES_REDIRECT_URI=http://localhost:8080/
- REACT_APP_SEPES_BASE_API_URL=http://localhost:8081/
- REACT_APP_SEPES_AUTHORITY=https://login.microsoftonline.com/placeyourIdHere
- REACT_APP_SEPES_CLIENTID=123
- The environment variables are used in the AuthConfig and AuthFunctions files under the "Auth" folder. These needs to be the same as the radixconfig variables (used in the pipeline) and docker-compose.yml (local variables) files.
- To run the app, run "Docker-compose up -d --build
- If it does not work properly, try a different version of docker compose. Top line in docker-compose.yml.
- To take down the app, run Docker-compose down
docker build -f local.Dockerfile -t sepes-local .
docker run -p 3000:3000 -d sepes-local
First you need to build a production build of the app
npm run build
Then you can run it with this command
npm run start:prod
If you need to add a new enviornment variable, you have to do the following
- Add a build secret(s) to the radixconfig-yaml file.
- Create a branch with the changes and commit the to the MASTER branch
- Go to https://console.radix.equinor.com/applications/sepes-web/config/
- Add the values of the secrets under build secrets
- Go to the DockerFile
- Add an ARG with the build secret(s)
ARG SEPES_NEW_VARIABLE
- Then add it as an export statement
export REACT_APP_SEPES_NEW_VARIABLE=$(echo $SEPES_AUTHORITY|base64 -d)
- Variable should be available under process.env.REACT_APP_SEPES_NEW_VARIABLE