Skip to content

Commit efcc50e

Browse files
author
James Fuqian
authored
Merge pull request #11 from CMSgov/jfuqian/BB2-941-Add-Tests-CI-Check-Sample-NodeJS-App
[BB2-941] Add Tests CI Check For Sample NodeJS App
2 parents 120d862 + 57c6e03 commit efcc50e

40 files changed

Lines changed: 976 additions & 15693 deletions

.github/pull_request_template.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!--
2+
You've got a Pull Request you want to submit? Awesome!
3+
This PR template is here to help ensure you're setup for success:
4+
please fill it out to help ensure that your PR is complete and ready for approval.
5+
-->
6+
7+
**JIRA Ticket:**
8+
[SOMEPROJECT-42](https://jira.cms.gov/browse/SOMEPROJECT-42)
9+
10+
**User Story or Bug Summary:**
11+
12+
<!-- Please copy-paste the brief user story or bug description that this PR is intended to address. -->
13+
14+
### What Does This PR Do?
15+
16+
<!--
17+
Add detailed description & discussion of changes here.
18+
The contents of this section should be used as your commit message (unless you merge the PR via a merge commit, of course).
19+
20+
Please follow standard Git commit message guidelines:
21+
* First line should be a capitalized, short (50 chars or less) summary.
22+
* The rest of the message should be in standard Markdown format, wrapped to 72 characters.
23+
* Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behavior.
24+
* List all relevant Jira issue keys, one per line at the end of the message, per: <https://confluence.atlassian.com/jirasoftwarecloud/processing-issues-with-smart-commits-788960027.html>.
25+
26+
Reference: <https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project>.
27+
-->
28+
29+
### What Should Reviewers Watch For?
30+
31+
<!--
32+
Add some items to the following list, or remove the entire section if it doesn't apply for some reason.
33+
34+
Common items include:
35+
* Is this likely to address the goals expressed in the user story?
36+
* Are any additional documentation updates needed?
37+
* Are there any unhandled and/or untested edge cases you can think of?
38+
* Is user input properly sanitized & handled?
39+
* Does this make any backwards-incompatible changes that might break end user clients?
40+
* Can you find any bugs if you run the code locally and test it manually?
41+
-->
42+
43+
If you're reviewing this PR, please check these things, in particular:
44+
45+
- TODO

.github/workflows/ci.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI for Node.js React Sample App
2+
on: [push]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v2
8+
9+
- uses: actions/setup-node@v2
10+
with:
11+
node-version: 14
12+
13+
- name: Install server
14+
run: yarn --cwd server install
15+
16+
- name: Install client
17+
run: yarn --cwd client install
18+
19+
- name: Lint server source
20+
run: yarn --cwd server lint
21+
22+
- name: Lint client source
23+
run: yarn --cwd client lint
24+
25+
- name: Copy config
26+
run: cp server/src/configs/sample.config.ts server/src/configs/config.ts
27+
28+
- name: Copy .env
29+
run: cp server/src/pre-start/env/sandbox.sample.env server/src/pre-start/env/development.env
30+
31+
- name: Run server tests
32+
run: yarn --cwd server test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ npm-debug.log*
1717
yarn-debug.log*
1818
yarn-error.log*
1919

20+
server/yarn.lock
21+
2022
.vscode
2123
.idea
2224

README.md

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
Create a Blue Button Sandbox Account
2-
---------------
3-
Create an account at the link below, and register your test application, to get your Blue Button Sandbox Credentials which will allow you to
4-
access the Blue Button synthetic data. These credentials will be necessary to run this sample application as well as
5-
utilize the Blue Button data within your own applcation. See the section below 'Running the Back-end & Front-end'.
1+
## Create a Blue Button Sandbox Account
2+
3+
Create an account at the link below, and register your test application, to get your Blue Button Sandbox Credentials which will allow you to
4+
access the Blue Button synthetic data. These credentials will be necessary to run this sample application as well as
5+
utilize the Blue Button data within your own applcation. See the section below 'Running the Back-end & Front-end'.
66

77
https://sandbox.bluebutton.cms.gov/v1/accounts/create
88

9-
To ensure this sample application will work properly, make sure that when you register your application you add
9+
To ensure this sample application will work properly, make sure that when you register your application you add
1010
the following url (see below) under the 'Callback URLS/Redirect Uris' section:
1111

1212
http://localhost:3001/api/bluebutton/callback/
1313

1414
When you are ready to run your own application, you can change this value to the url that you need.
1515
Just log into your Blue Button Sandbox account and select 'View/Edit App->'.
1616

17-
Setup Docker & Node-js
18-
---------------
17+
## Setup Docker & Node-js
1918

20-
Install and setup Docker. Go to https://docs.docker.com/get-started/ and follow the directions.
19+
Install and setup Docker. Go to https://docs.docker.com/get-started/ and follow the directions.
2120

22-
Download and install node. Go to https://nodejs.org/en/download/ and follow the directions.
21+
Download and install node. Go to https://nodejs.org/en/download/ and follow the directions.
2322

24-
Running the Back-end & Front-end
25-
---------------
23+
## Running the Back-end & Front-end
2624

2725
Once you have Docker and Node installed and setup then do the following:
2826

@@ -31,12 +29,11 @@ Once you have Docker and Node installed and setup then do the following:
3129
Make sure to replace the clientId and clientSecret variables within the config file with
3230
the ones you were provided, for your application, when you created your Blue Button Sandbox account.
3331

34-
3532
copy server/src/pre-start/env/sandbox.sample.env -> server/src/pre-start/env/development.env
3633

3734
docker-compose up -d
3835

39-
This single command will create the docker container with all the necessary packages, configuration, and code to
36+
This single command will create the docker container with all the necessary packages, configuration, and code to
4037
run both the front and back ends of this sample application.
4138

4239
To see the application in action open your browser and enter the following URL:
@@ -45,20 +42,19 @@ http://localhost:3000
4542

4643
To see the process of authenticating with Blue Button via Medicare.gov and retrieve EoB data just click on the 'Authorize' button.
4744

48-
BB2 Sandbox User
49-
-----------
50-
To ensure data displays properly in the sample application please use a
51-
Blue Button Sandbox user that has PDE (Part-D Events) EoBs (Explanation of Benefits). An example of a user with this
52-
data would be: BBUser29999 (PWD: PW29999!) or BBUser29998 (PWD: PW29998!)
45+
## BB2 Sandbox User
46+
47+
To ensure data displays properly in the sample application please use a
48+
Blue Button Sandbox user that has PDE (Part-D Events) EoBs (Explanation of Benefits). An example of a user with this
49+
data would be: BBUser29999 (PWD: PW29999!) or BBUser29998 (PWD: PW29998!)
50+
51+
## Development
5352

54-
Development
55-
-----------
5653
Read the DEVELOPER NOTES found in the code to understand the application
57-
and where you will need to make adjustments/changes as well as some
54+
and where you will need to make adjustments/changes as well as some
5855
suggestions for best practices.
5956

60-
Usage Examples
61-
-----------
57+
## Usage Examples
6258

6359
To start the sample in Docker :
6460

@@ -70,7 +66,7 @@ To start the sample in native OS (e.g. Linux) with server and client components
7066
1. go to the base directory of the repo
7167
2. run below to start the server:
7268
1. yarn --cwd server install
73-
2. yarn --cwd server start:dev
69+
2. yarn --cwd server start:dev
7470
3. run below to start the client:
7571
1. yarn --cwd client install
7672
2. yarn --cwd client start-native
@@ -81,6 +77,15 @@ Both ways of starting the sample are running the sample in foreground, logging a
8177

8278
For client and server started separately in their command window, type Ctrl C respectively
8379

84-
Error Responses and handling:
85-
-----------------------------
80+
## Run tests
81+
82+
Go to local repo base directory:
83+
84+
copy server/src/configs/sample.config.ts -> server/src/configs/config.ts
85+
86+
yarn --cwd server install
87+
yarn --cwd server test
88+
89+
## Error Responses and handling:
90+
8691
[See ErrorResponses.md](./ErrorResponses.md)

client/.eslintignore

Whitespace-only changes.

client/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
24+
25+
client/yarn.lock

client/eslintrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:react/recommended",
9+
"plugin:@typescript-eslint/recommended"
10+
],
11+
"parser": "@typescript-eslint/parser",
12+
"parserOptions": {
13+
"ecmaFeatures": {
14+
"jsx": true
15+
},
16+
"ecmaVersion": 12
17+
},
18+
"plugins": [
19+
"react",
20+
"@typescript-eslint"
21+
],
22+
"rules": {
23+
"@typescript-eslint/no-explicit-any": "off"
24+
}
25+
}

client/package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
"proxy": "http://localhost:3001",
66
"dependencies": {
77
"@cmsgov/design-system": "^2.7.3",
8-
"@testing-library/jest-dom": "^5.11.4",
9-
"@testing-library/react": "^11.1.0",
10-
"@testing-library/user-event": "^12.1.10",
11-
"@types/jest": "^26.0.15",
128
"@types/node": "^12.0.0",
139
"@types/react": "^17.0.0",
1410
"@types/react-dom": "^17.0.0",
@@ -25,6 +21,7 @@
2521
"scripts": {
2622
"start": "REACT_APP_CTX=docker react-scripts start",
2723
"start-native": "REACT_APP_CTX=native react-scripts start",
24+
"lint": "eslint --ext .ts --ext .js --ext .tsx .",
2825
"build": "react-scripts build",
2926
"test": "react-scripts test",
3027
"eject": "react-scripts eject"
@@ -48,6 +45,14 @@
4845
]
4946
},
5047
"devDependencies": {
51-
"@types/react-router-dom": "^5.1.7"
48+
"@testing-library/jest-dom": "^5.16.2",
49+
"@testing-library/react": "^12.1.3",
50+
"@testing-library/user-event": "^13.5.0",
51+
"@types/jest": "^27.4.0",
52+
"@types/react-router-dom": "^5.1.7",
53+
"@typescript-eslint/eslint-plugin": "^5.12.0",
54+
"@typescript-eslint/parser": "^5.12.0",
55+
"eslint-config-react-app": "^7.0.0",
56+
"eslint-plugin-react": "^7.28.0"
5257
}
5358
}

client/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react';
12
import Header from './components/header';
23
import Patient from './components/patient';
34
import PatientData from './components/patientData';

client/src/components/header.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Badge } from '@cmsgov/design-system';
22
import { Link as RouterLink } from 'react-router-dom';
3+
import React from 'react'
34

45
export default function Header() {
56
return (
@@ -16,4 +17,4 @@ export default function Header() {
1617
</div>
1718
</header>
1819
);
19-
};
20+
}

0 commit comments

Comments
 (0)