Skip to content

Commit

Permalink
Updates frontend server, adds Tests (#3297)
Browse files Browse the repository at this point in the history
# Description and Motivation
<!--- bulleted, high level items. use keywords (eg "closes #144" or
"fixes #4323") -->
 
- closes #3152
- refactors from commonjs requires() to esmodule import() style
- re-enables dependabot on frontend server deps
- enables super linter on frontend_server
- refactors to use built in node fetch
- pins node version (required due to built in fetch)

## Has this been tested? How?

- new tests fails when intentionally breaking the code

## Screenshots (if appropriate)

<img width="757" alt="Screenshot 2024-05-14 at 11 51 10 PM"
src="https://github.com/SatcherInstitute/health-equity-tracker/assets/41567007/0a7b0bbd-b28d-453c-a692-55e6d98a6d2f">

## Types of changes

(leave all that apply)

- Refactor / chore

## New frontend preview link is below in the Netlify comment 😎
  • Loading branch information
benhammondmusic committed May 15, 2024
1 parent cd5a153 commit 15fac75
Show file tree
Hide file tree
Showing 11 changed files with 2,978 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ updates:
update-types:
- "minor"
- "patch"
open-pull-requests-limit: 0 # TODO: re-enable by increasing limit once we have test coverage #3152
open-pull-requests-limit: 1
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/runFrontendServerTests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: RUN Frontend Server Tests

env:
## Sets environment variables
NETLIFY_SITE_NAME: 'health-equity-tracker'
GITHUB_PR_NUMBER: ${{github.event.pull_request.number}}

on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- 'frontend_server/**' # Run when changes occur in the frontend subfolder
defaults:
run:
working-directory: frontend_server

jobs:
frontend_unit_tests:
name: Runs frontend server unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: frontend_server/package.json
cache: 'npm'
cache-dependency-path: frontend_server/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run Vitest unit tests
run: npm test
1 change: 1 addition & 0 deletions .github/workflows/runSuperLinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
VALIDATE_DOCKERFILE: true
VALIDATE_TSX: true
VALIDATE_TYPESCRIPT_ES: true
VALIDATE_JAVASCRIPT_ES: true
PYTHON_BLACK_CONFIG_FILE: black.ini
VALIDATE_PYTHON_BLACK: true
VALIDATE_PYTHON_PYLINT: true
Expand Down
4 changes: 2 additions & 2 deletions frontend_server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DISABLE_BASIC_AUTH=true
# This can be the url of your personal GCP project data server, or it can be
# localhost if you're running the data server locally with docker, or it can
# be the url of the data server in the staging environment. Please do not use
# the url of the data server in the production environment. Note that in
# the url of the data server in the production environment. Note that in
# staging and prod environments this environment variable is set through the
# terraform configuration.
DATA_SERVER_URL=https://your-data-server-url
DATA_SERVER_URL=https://your-data-server-url
1 change: 1 addition & 0 deletions frontend_server/.env.prod
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NODE_ENV=production
DEPLOY_CONTEXT=prod
DISABLE_BASIC_AUTH=true
METADATA_SERVER_TOKEN_URL=http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience=
1 change: 1 addition & 0 deletions frontend_server/.env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ NODE_ENV=production
DEPLOY_CONTEXT=staging
# set to false to password product dev.healthequitytracker.org
DISABLE_BASIC_AUTH=true
METADATA_SERVER_TOKEN_URL=http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience=
7 changes: 7 additions & 0 deletions frontend_server/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
NODE_ENV=production
DEPLOY_CONTEXT=prod
DISABLE_BASIC_AUTH=true
# for testing, this will hit mocky.io instead of the HET data_server
METADATA_SERVER_TOKEN_URL=NULL
DATA_SERVER_URL=https://run.mocky.io/v3/09b9fb81-e3f8-4a57-bac5-fd868bbd6fba
BUILD_DIR=../frontend

0 comments on commit 15fac75

Please sign in to comment.