Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRMDR-464 Remove hardcoded port numbers #201

Merged
merged 46 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
baa7d7a
boiler plate for smoketest GitHub action
Dec 4, 2023
2c511de
yml errors removed
Dec 4, 2023
8ee1ddb
cypress smoketesting configuration changes
Dec 4, 2023
23d6833
Merge branch 'main' into prmdr_485
RioKnightleyNHS Dec 6, 2023
a9522c5
Migrate Cypress baseUrl to cross-env
RioKnightleyNHS Dec 6, 2023
fb2d150
Update cypress smoke workflow to use cross-env
RioKnightleyNHS Dec 6, 2023
7096e55
Amend cypress cross-env
RioKnightleyNHS Dec 6, 2023
ace6e69
Add final adjustments to smoke test workflow
RioKnightleyNHS Dec 6, 2023
93cf719
Add sandbox input to smoke test workflow
RioKnightleyNHS Dec 6, 2023
e451f1e
Add checkout input for smoke test workflow
RioKnightleyNHS Dec 6, 2023
cf5ed06
Fix input typo in build branch
RioKnightleyNHS Dec 6, 2023
109dfda
Fix null on url
RioKnightleyNHS Dec 6, 2023
fec4c91
Update input verbiage
RioKnightleyNHS Dec 6, 2023
5f537af
Add cypress/grep package
RioKnightleyNHS Dec 6, 2023
1861a20
Fix missing env variables
RioKnightleyNHS Dec 6, 2023
7a3d896
Sandbox input change to url
RioKnightleyNHS Dec 6, 2023
4ca8d60
Update other input urls
RioKnightleyNHS Dec 6, 2023
e0494e1
Restore cypress env variable
RioKnightleyNHS Dec 6, 2023
278835a
Change cypress input env
RioKnightleyNHS Dec 6, 2023
59248be
Update URL test
RioKnightleyNHS Dec 6, 2023
0b24b4e
Remove cross-env test
RioKnightleyNHS Dec 6, 2023
6b1a0e6
Fix inconsistencies in trailing slashes
RioKnightleyNHS Dec 6, 2023
d38d8ec
Add new smoke test layout
RioKnightleyNHS Dec 6, 2023
42dbf80
Add first smoke test
RioKnightleyNHS Dec 6, 2023
47967ca
Add grepTags for regression and smoke cypress tests
RioKnightleyNHS Dec 6, 2023
96e90f5
Update grepTags workflow env
RioKnightleyNHS Dec 6, 2023
41520c9
Alter cy.visit with new config usage
RioKnightleyNHS Dec 6, 2023
a6fddd1
Fix grepTags on other workflows
RioKnightleyNHS Dec 6, 2023
8b87048
[PRMDR-464] (WIP) Remove hardcoded port number from nginx.conf and do…
joefong-nhs Dec 7, 2023
7c8a064
[PRMDR-464] Edit github actions to read env var CONTAINER_PORT before…
joefong-nhs Dec 11, 2023
5635abd
[PRMDR-464] Fix typo in yml
joefong-nhs Dec 11, 2023
1dc1740
[PRMDR-464] Edit github action
joefong-nhs Dec 11, 2023
7a929ff
[PRMDR-464] Add CONTAINER_PORT to sh script which build .env
joefong-nhs Dec 11, 2023
f510a67
[PRMDR-464] edit docker file to get CONTAINER_PORT from build_arg
joefong-nhs Dec 11, 2023
e75733b
[PRMDR-464] Revert change to react-environment-config.sh, add build_a…
joefong-nhs Dec 11, 2023
a50be6b
[PRMDR-464] Add build arg to docker-compose and github action files
joefong-nhs Dec 11, 2023
8788ac5
[PRMDR-464] Remove all occurence of port 3000 in code (except github …
joefong-nhs Dec 13, 2023
bdec147
[PRMDR-464] Fix inconsistency related to slash (/) after baseUrl in c…
joefong-nhs Dec 13, 2023
c0ce0a4
Merge branch 'prmdr_485' into PRMDR-464
joefong-nhs Dec 13, 2023
2a731ff
[PRMDR-464] Introduce newer ver of cypress tests from branch PRMDR-48…
joefong-nhs Dec 13, 2023
3917231
[PRMDR-464] Replace hardcoded CYPRESS_BASE_URL in github action yml w…
joefong-nhs Dec 13, 2023
b80d747
[PRMDR-464] Update README.md
joefong-nhs Dec 13, 2023
0c0f1ed
[PRMDR-464] fix typo in README.md
joefong-nhs Dec 13, 2023
738e7a2
[PRMDR-464] Fix cy.visit(baseUrl + '/endpoint') pattern
joefong-nhs Dec 15, 2023
98dbcd8
Merge branch 'main' into PRMDR-464
joefong-nhs Dec 15, 2023
bd1c177
Merge branch 'main' into PRMDR-464
joefong-nhs Dec 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/full-ui-dispatch-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ jobs:

- uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: '/ndr/${{ github.event.client_payload.sandbox }}/api_endpoint = DOC_STORE_API_ENDPOINT'
parameterPairs: '/ndr/${{ github.event.client_payload.sandbox }}/api_endpoint = DOC_STORE_API_ENDPOINT,
/ndr/${{ github.event.client_payload.sandbox }}/container_port = CONTAINER_PORT'
withDecryption: 'true' # defaults to true

- name: Configure React environment vars
Expand All @@ -97,8 +98,9 @@ jobs:
ECR_REPOSITORY: ndr-${{ github.event.client_payload.sandbox }}-app
IMAGE_TAG: latest
IMAGE_TAG_SHA: ${{ github.sha }}
CONTAINER_PORT: ${{ env.CONTAINER_PORT }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA .
docker build --build-arg="CONTAINER_PORT=$CONTAINER_PORT" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA" >> $GITHUB_OUTPUT
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/new-ui-deploy-feature-to-sandbox-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ jobs:

- uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: '/ndr/${{ inputs.sandbox }}/api_endpoint = DOC_STORE_API_ENDPOINT'
parameterPairs: '/ndr/${{ inputs.sandbox }}/api_endpoint = DOC_STORE_API_ENDPOINT,
/ndr/${{ inputs.sandbox }}/container_port = CONTAINER_PORT'
withDecryption: 'true' # defaults to true

- name: Configure React environment vars
Expand All @@ -124,8 +125,9 @@ jobs:
ECR_REPOSITORY: ndr-${{ inputs.sandbox }}-app
IMAGE_TAG: latest
IMAGE_TAG_SHA: ${{ github.sha }}
CONTAINER_PORT: ${{ env.CONTAINER_PORT }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA .
docker build --build-arg="CONTAINER_PORT=$CONTAINER_PORT" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA" >> $GITHUB_OUTPUT
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ui-deploy-to-perf-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ jobs:

- uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: '/ndr/${{ vars.BUILD_ENV }}/api_endpoint = DOC_STORE_API_ENDPOINT'
parameterPairs: '/ndr/${{ vars.BUILD_ENV }}/api_endpoint = DOC_STORE_API_ENDPOINT,
/ndr/${{ vars.BUILD_ENV }}/container_port = CONTAINER_PORT'
withDecryption: 'true' # defaults to true

- name: Configure React environment vars
Expand All @@ -99,8 +100,9 @@ jobs:
ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }}
IMAGE_TAG: perf-${{ github.event.inputs.tagVersion}}
IMAGE_TAG_SHA: ${{ github.sha }}
CONTAINER_PORT: ${{ env.CONTAINER_PORT }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA .
docker build --build-arg="CONTAINER_PORT=$CONTAINER_PORT" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA" >> $GITHUB_OUTPUT
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/ui-deploy-to-pre-prod-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
name: build
path: ./app/build
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

# Npm run will run the app locally, we want to test the built application with env vars using serve
Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:
browser: firefox
working-directory: ./app
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

cypress-run-edge:
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
browser: edge
working-directory: ./app
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

react_build_and_deploy_docker_image:
Expand Down Expand Up @@ -245,7 +245,8 @@ jobs:

- uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: '/ndr/${{ vars.BUILD_ENV }}/api_endpoint = DOC_STORE_API_ENDPOINT'
parameterPairs: '/ndr/${{ vars.BUILD_ENV }}/api_endpoint = DOC_STORE_API_ENDPOINT,
/ndr/${{ vars.BUILD_ENV }}/container_port = CONTAINER_PORT'
withDecryption: 'true' # defaults to true

- name: Configure React environment vars
Expand All @@ -264,8 +265,9 @@ jobs:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }}
IMAGE_TAG: ${{needs.tag_and_release.outputs.tag}}
CONTAINER_PORT: ${{ env.CONTAINER_PORT }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker build --build-arg="CONTAINER_PORT=$CONTAINER_PORT" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/ui-deploy-to-prod-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
browser: chrome
working-directory: ./app
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

cypress-run-firefox:
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
browser: firefox
working-directory: ./app
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

cypress-run-edge:
Expand Down Expand Up @@ -185,7 +185,7 @@ jobs:
browser: edge
working-directory: ./app
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

react_build_and_deploy_docker_image:
Expand Down Expand Up @@ -215,7 +215,8 @@ jobs:

- uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: '/ndr/${{ vars.BUILD_ENV }}/api_endpoint = DOC_STORE_API_ENDPOINT'
parameterPairs: '/ndr/${{ vars.BUILD_ENV }}/api_endpoint = DOC_STORE_API_ENDPOINT,
/ndr/${{ vars.BUILD_ENV }}/container_port = CONTAINER_PORT'
withDecryption: 'true' # defaults to true

- name: Configure React environment vars
Expand All @@ -234,8 +235,9 @@ jobs:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }}
IMAGE_TAG: prod-${{ github.event.inputs.tagVersion}}
CONTAINER_PORT: ${{ env.CONTAINER_PORT }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker build --build-arg="CONTAINER_PORT=$CONTAINER_PORT" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ui-deploy-to-test-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
browser: chrome
working-directory: ./app
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

cypress-run-firefox:
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:
browser: firefox
working-directory: ./app
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

cypress-run-edge:
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
browser: edge
working-directory: ./app
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

react_build_and_deploy_docker_image:
Expand Down Expand Up @@ -232,8 +232,9 @@ jobs:
ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }}
IMAGE_TAG: latest
IMAGE_TAG_SHA: ${{ github.sha }}
CONTAINER_PORT: ${{ env.CONTAINER_PORT }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA .
docker build --build-arg="CONTAINER_PORT=$CONTAINER_PORT" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA" >> $GITHUB_OUTPUT
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/ui-dev-to-main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
browser: chrome
working-directory: ./app
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

cypress-run-firefox:
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
browser: firefox
working-directory: ./app
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

cypress-run-edge:
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:
browser: edge
working-directory: ./app
env:
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
CYPRESS_grepTags: 'regression'

react_build_and_deploy_docker_image:
Expand Down Expand Up @@ -218,7 +218,8 @@ jobs:

- uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: '/ndr/${{ vars.BUILD_ENV }}/api_endpoint = DOC_STORE_API_ENDPOINT'
parameterPairs: '/ndr/${{ vars.BUILD_ENV }}/api_endpoint = DOC_STORE_API_ENDPOINT,
/ndr/${{ vars.BUILD_ENV }}/container_port = CONTAINER_PORT'
withDecryption: 'true' # defaults to true

- name: Configure React environment vars
Expand All @@ -238,8 +239,9 @@ jobs:
ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }}
IMAGE_TAG: latest
IMAGE_TAG_SHA: ${{ github.sha }}
CONTAINER_PORT: ${{ env.CONTAINER_PORT }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA .
docker build --build-arg="CONTAINER_PORT=$CONTAINER_PORT" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA" >> $GITHUB_OUTPUT
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ coverage.xml
.hypothesis/
.pytest_cache/
cover/
app/mochawesome-report/
app/mochawesomemerged.json

# Translations
*.mo
Expand Down
3 changes: 2 additions & 1 deletion app/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules
/node_modules
Dockerfile
6 changes: 5 additions & 1 deletion app/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ REACT_APP_DOC_STORE_API_ENDPOINT=%DOC_STORE_API_ENDPOINT%
REACT_APP_AWS_REGION=%AWS_REGION%
REACT_APP_OIDC_PROVIDER_ID=%OIDC_PROVIDER_ID%
REACT_APP_ENVIRONMENT=%BUILD_ENV% # 'local'
REACT_APP_IMAGE_VERSION="%IMAGE_VERSION%"
REACT_APP_IMAGE_VERSION="%IMAGE_VERSION%"
CONTAINER_PORT=xx # Port number within the container. Needed for building the docker image
HOST_PORT=xxxx # Port number that the docker-compose localhost exposes. Only need this if we run docker-compose
PORT=xxxx # Port number of the localhost dev server when we run `make start`
CYPRESS_BASE_URL=http://localhost:xxxx # Use the port number same as above PORT
6 changes: 4 additions & 2 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ RUN npm run build

# Host the App
FROM nginx:latest
ARG CONTAINER_PORT
WORKDIR /usr/share/nginx/html
RUN rm -rf ./*
COPY --from=builder /app/build .
WORKDIR /etc/nginx
COPY --from=builder ./app/docker/nginx.conf .
EXPOSE 80
COPY --from=builder ./app/docker/nginx.conf ./nginx.conf.template
RUN sed "s/\$CONTAINER_PORT/${CONTAINER_PORT}/g" ./nginx.conf.template > ./nginx.conf
EXPOSE ${CONTAINER_PORT}
ENTRYPOINT ["nginx", "-g", "daemon off;"]
9 changes: 6 additions & 3 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The National Document Repository user interface (UI) has been developed with Rea

### 1. Set Env Variables

Create a `.env` file by duplicating [.env.example](.env_example) and adding any missing values. This file is sourced to
Create a `.env` file by duplicating [.env.template](.env.template) and adding any missing values. This file is sourced to
your shell env so make sure it doesn't have any extra whitespace, comments etc.
The `local` environment variable will allow your local app to bypass auth and mock most lambda requests.

Expand All @@ -40,7 +40,7 @@ Once the packages have been installed, you can then run the app through the foll
make start
```

Once everything is up and running you should see a prompt in the CLI that the app is running on http://localhost:3000. You should now be able to visit the site in a browser of your choice.
Once everything is up and running you should see a prompt in the CLI that the app is running on http://localhost:xxxx, where xxxx is the value of PORT specified in `.env` file. You should now be able to visit the site in a browser of your choice.

## Testing

Expand All @@ -57,7 +57,10 @@ The applications unit tests will also run automatically every-time a push is mad

### 2. E2E Tests

There are also Cypress end-to-end tests written against each user journey and it's functionality. You can run these by running
There are also Cypress end-to-end tests written against each user journey and it's functionality.

Before running the E2E tests, please make sure you have got the value `CYPRESS_BASE_URL=http://localhost:xxxx` set up in your .env file.
You can then start the E2E tests by running

```bash
make cypress-open
Expand Down
8 changes: 7 additions & 1 deletion app/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { defineConfig } from 'cypress';
import * as dotenv from 'dotenv';

function getBaseUrlFromEnv() {
dotenv.config();
return process.env.CYPRESS_BASE_URL;
}
carlsmith101 marked this conversation as resolved.
Show resolved Hide resolved

export default defineConfig({
e2e: {
Expand All @@ -7,7 +13,7 @@ export default defineConfig({
},
downloadsFolder: 'cypress/downloads',
trashAssetsBeforeRuns: true,
baseUrl: process.env.CYPRESS_BASE_URL,
baseUrl: getBaseUrlFromEnv(),
},

component: {
Expand Down
4 changes: 3 additions & 1 deletion app/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ services:
image: ndr_ui_image
build:
context: .
args:
CONTAINER_PORT: ${CONTAINER_PORT}
ports:
- 8080:80
- "${HOST_PORT}:${CONTAINER_PORT}"
env_file:
- .env
2 changes: 1 addition & 1 deletion app/docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ events {
}
http {
server {
listen 80;
listen $CONTAINER_PORT;
add_header Cache-Control "no-store" always;
add_header Pragma "no-cache" always;
add_header Strict-Transport-Security "max-age=63072000" always;
Expand Down
9 changes: 4 additions & 5 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@
"build-storybook": "storybook build",
"format": "prettier --write \"**/*.+(ts|tsx|js|scss|json|css|md)\"",
"prepare": "cd ../ && husky install ./app/.husky",
"cypress": "cross-env CYPRESS_BASE_URL=http://localhost:3000 cypress open --env grepTags=regression",
"cypress-run": "cross-env CYPRESS_BASE_URL=http://localhost:3000 cypress run --env grepTags=regression --browser chrome",
"cypress-report-run": "cross-env CYPRESS_BASE_URL=http://localhost:3000 cypress run --reporter mochawesome --env grepTags=regression",
"cypress": "cypress open --env grepTags=regression",
"cypress-run": "cypress run --env grepTags=regression --browser chrome",
"cypress-report-run": "cypress run --reporter mochawesome --env grepTags=regression",
"cypress-report-merge": "npx mochawesome-merge \"cypress/results/*.json\" > mochawesomemerged.json",
"cypress-report-generate": "npx marge mochawesomemerged.json",
"cypress-report": "rm -r cypress/results/* && npm run cypress-report-run && npm run cypress-report-merge && npm run cypress-report-generate"
"cypress-report": "rm -rf cypress/results/* && npm run cypress-report-run && npm run cypress-report-merge && npm run cypress-report-generate"
},
"dependencies": {
"@cypress/grep": "^4.0.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.5.0",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1",
"eslint-plugin-legacy-decorators": "^1.0.0",
"fake-progress": "^1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/authCallbackPage/AuthCallbackPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const params = {

const codeAndStateQueryParams = `code=${params.code}&state=${params.state}`;
const allQueryParams = `?${codeAndStateQueryParams}&client_id=${params.id}`;
const baseUiUrl = 'http://localhost:3000' + allQueryParams;
const baseUiUrl = 'http://localhost' + allQueryParams;
const originalWindowLocation = window.location;

const currentPage = '/example';
Expand Down
Loading
Loading