Merge remote-tracking branch 'origin/dev' into patient-info-form

This commit is contained in:
Meghan McLaughlin committed 2020-04-08 11:35:31 -05:00
commit ec06da4ac4
30 files changed
+2076 -202

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
---
name: Issue Template
about: A template for new ZenHub stories
title: ''
labels: ''
assignees: ''
---
As a <!-- [developer / logged-in-user] -->
I want to <!-- Ex: be able to visit the /login page -->
So that <!-- Ex: I can login to my account -->
### Acceptance Criteria:
The following needs to be completed for this story to be "done":
- [ ] ...
### Notes:
Helpful information to complete the task, suggestions on how to do so:
- ...
+13
View File
@@ -0,0 +1,13 @@
### Description:
Closes issue # ...
### Notes:
### Screenshots (Optional):
### Checklist:
- [ ] 90% Test Coverage
-25
View File
@@ -1,25 +0,0 @@
name: Build project and Run Lighthouse CI
on: [push]
jobs:
lhci:
name: Lighthouse CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 10.x
uses: actions/setup-node@v1
with:
node-version: 10.x
- name: npm install, build
run: |
pushd pwa && npm install
npm run build && popd
- name: run Lighthouse CI
run: |
npm install -g @lhci/cli@0.3.x
lhci autorun || echo "LHCI failed!"
- name: Upload lighthouse report
uses: actions/upload-artifact@v1
with:
name: lighthouse
path: ./.lighthouseci
+5 -3
View File
@@ -16,8 +16,10 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: pushd pwa && npm install && popd
- run: pushd pwa && npm run build && popd
- run: pushd pwa && npm test && popd
- run: docker-compose -f dev-docker-compose.yml up --detach
- run: docker exec haiti_pwa npm run test:cov
- run: docker exec haiti_pwa npm run cy:run
- run: docker exec haiti_pwa npm run build
- run: docker-compose -f dev-docker-compose.yml down
env:
CI: true
+3
View File
@@ -1 +1,4 @@
**/.lighthouseci/**
# postgres persisted data
pgdata/
-11
View File
@@ -1,11 +0,0 @@
{
"ci": {
"collect": {
"staticDistDir": "./pwa/build",
"numberOfRuns": 3
},
"upload": {
"target": "temporary-public-storage"
}
}
}
+2 -2
View File
@@ -13,7 +13,7 @@
The application runs on docker, which can be installed [here](https://docs.docker.com/install/).
If you're a linux user, you'll also need to install [docker-compose](https://docs.docker.com/compose/install/) separately. Otherwise, it's included in the Mac and PC versions of "Docker Desktop"
- The PWA and accompanying database can be started by running the command `docker-compose -f dev-docker-compose.yml up` from the root directory.
- `docker-compose -f dev-docker-compose.yml up` will then stop the docker processes from running in the background.
- The PWA, API, Database, and Swagger documentation can be started by running the command `docker-compose -f dev-docker-compose.yml up` from the root directory.
- `docker-compose -f dev-docker-compose.yml down` will then stop the docker processes from running in the background.
- Once the images have been built and the processes started, the PWA can be seen at your localhost, at the port specified in [dev-docker-compose.yml](https://github.com/Haiti-Distributed-Healthcare-System/hdhs/blob/dev/dev-docker-compose.yml).
- More tips to troubleshoot docker are available [here](https://github.com/Haiti-Distributed-Healthcare-System/hdhs/wiki/Using-Docker).
+46 -9
View File
@@ -1,22 +1,59 @@
version: '3'
services:
pwa:
build:
context: ./pwa
volumes:
- ./pwa/:/app
# These dirs can be changed outside of the conatiner, and reflected within.
# All other files require a rebuild:
# docker-compose -f dev-docker-compose.yml up --build
- ./pwa/src:/data/src
- ./pwa/cypress:/data/cypress
- ./pwa/public:/data/public
- ./pwa/coverage:/data/coverage
ports:
- "3000:3000"
container_name: haiti_pwa
environment:
environment: "docker"
database:
image: "postgres" # use latest official postgres version
env_file:
- database.env # configure postgres
volumes:
- database-data:/var/lib/postgresql/data/ # persist data even if container shuts down
- "./pgdata:/var/lib/postgresql/data" # persist data even if container shuts down
ports:
- "5432:5432"
volumes:
database-data: # named volumes can be managed easier using docker-compose
- "5432:5432"
expose:
- "5422"
environment:
POSTGRES_DB: app_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: HaitiCHI
environment: "docker"
api:
image: postgrest/postgrest
ports:
- "4000:4000"
expose:
- "4000"
links:
- database:database
environment:
PGRST_DB_URI: postgres://postgres:HaitiCHI@database:5432/app_db
PGRST_DB_SCHEMA: public
PGRST_DB_ANON_ROLE: postgres
PGRST_SERVER_PORT: 4000
environment: "docker"
depends_on:
- database
swagger:
image: swaggerapi/swagger-ui
ports:
- "4001:8080"
expose:
- "8080"
environment:
API_URL: http://localhost:4000
environment: "docker"
+1
View File
@@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true
+4 -5
View File
@@ -1,15 +1,14 @@
FROM node:12.10.0
COPY package*.json ./data/
FROM cypress/base:12.16.0
WORKDIR /data
COPY package*.json ./
RUN npm install
ENV PATH /data/node_modules/.bin:$PATH
COPY . /data/app
WORKDIR /data/app
COPY . ./
EXPOSE 3000
+1
View File
@@ -0,0 +1 @@
{"video": false}
+22
View File
@@ -0,0 +1,22 @@
# Cypress.io end-to-end tests
[Cypress.io](https://www.cypress.io) is an open source, MIT licensed end-to-end test runner
## Folder structure
These folders hold end-to-end tests and supporting files for the Cypress Test Runner.
- [fixtures](fixtures) holds optional JSON data for mocking, [read more](https://on.cypress.io/fixture)
- [integration](integration) holds the actual test files, [read more](https://on.cypress.io/writing-and-organizing-tests)
- [plugins](plugins) allow you to customize how tests are loaded, [read more](https://on.cypress.io/plugins)
- [support](support) file runs before all tests and is a great place to write or load additional custom commands, [read more](https://on.cypress.io/writing-and-organizing-tests#Support-file)
## `cypress.json` file
You can configure project options in the [../cypress.json](../cypress.json) file, see [Cypress configuration doc](https://on.cypress.io/configuration).
## More information
- [https://github.com/cypress.io/cypress](https://github.com/cypress.io/cypress)
- [https://docs.cypress.io/](https://docs.cypress.io/)
- [Writing your first Cypress test](http://on.cypress.io/intro)
+5
View File
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
+12
View File
@@ -0,0 +1,12 @@
// enables intelligent code completion for Cypress commands
// https://on.cypress.io/intelligent-code-completion
/// <reference types="cypress" />
describe('Homepage', () => {
it('shows login button', function () {
cy.visit('http://localhost:3000')
cy.get('.am-button').contains('Login')
})
})
export {};
+50
View File
@@ -0,0 +1,50 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable @typescript-eslint/no-var-requires */
const webpack = require('@cypress/webpack-preprocessor');
const webpackOptions = {
mode: 'development',
// make sure the source maps work
devtool: 'eval-source-map',
// webpack will transpile TS and JS files
resolve: {
extensions: ['.ts', '.js', '.tsx', '.jsx'],
},
module: {
rules: [
{
test: /\.(js|jsx|mjs)$/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['@babel/plugin-proposal-class-properties'],
},
},
{
test: /\.(ts|tsx)$/,
loader: ['babel-loader', 'awesome-typescript-loader'],
},
{
test: /\.css$/,
exclude: [/node_modules/],
use: ['style-loader', 'css-loader'],
},
{
test: /\.svg$/,
exclude: [/node_modules/],
use: ['svg-url-loader'],
},
],
},
};
const options = {
webpackOptions,
watchOptions: {},
};
module.exports = (on, config) => {
on('file:preprocessor', webpack(options));
return config;
};
+14
View File
@@ -0,0 +1,14 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
+17
View File
@@ -0,0 +1,17 @@
{
"extends": "../tsconfig.json",
"include": [
"../node_modules/cypress",
"*/*.ts"
],
"compilerOptions": {
"strict": false,
"baseUrl": "../node_modules",
"target": "es5",
"lib": ["es7", "dom"],
"esModuleInterop": true,
"jsx": "react",
"inlineSourceMap": true,
"skipLibCheck": true
}
}
+1697 -140
View File
File diff suppressed because it is too large. Load diff
+26
View File
@@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@ant-design/icons": "^4.0.5",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
@@ -21,11 +22,24 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"cy:open": "cypress open",
"cy:run": "cypress run",
"test:cov": "react-scripts test --coverage --watchAll=false",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"jest": {
"coverageThreshold": {
"global": {
"statements": 90
}
},
"coverageReporters": [
"lcov"
]
},
"browserslist": {
"production": [
">0.2%",
@@ -37,5 +51,17 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@cypress/webpack-preprocessor": "^4.1.3",
"@testing-library/react-hooks": "^3.2.1",
"awesome-typescript-loader": "^5.2.1",
"babel-loader": "^8.1.0",
"babel-plugin-import": "^1.13.0",
"cypress": "^4.2.0",
"react-test-renderer": "^16.13.1",
"svg-url-loader": "^5.0.0",
"ts-loader": "^6.2.2",
"webpack": "^4.42.1"
}
}
+6 -6
View File
@@ -1,15 +1,15 @@
import React from 'react';
import './scss/App.scss';
import './antd-mobile.css';
import React from "react";
import "./scss/App.scss";
import "./antd-mobile.css";
import Login from './components/Login'
import Login from "./components/Login";
const App = () => {
return (
<>
<Login/>
<Login />
</>
);
}
};
export default App;
+11
View File
@@ -0,0 +1,11 @@
import React from "react";
import { render } from "@testing-library/react";
import LandingPage from "./LandingPage";
test("renders learn react link", () => {
const { getByText } = render(<LandingPage />);
const lookupButtonElement = getByText(/Patient Lookup/i);
const newPatientButtonElement = getByText(/New Patient/i);
expect(lookupButtonElement).toBeInTheDocument();
expect(newPatientButtonElement).toBeInTheDocument();
});
+34
View File
@@ -0,0 +1,34 @@
import React, { ReactElement } from "react";
import { WhiteSpace, Button } from "antd-mobile";
import Icon, { UserAddOutlined } from "@ant-design/icons";
import "../scss/LandingPage.scss";
export default function LandingPage(): ReactElement {
/* istanbul ignore next */
const patientLookup = () => {
console.log("Clicked Patient Lookup");
};
/* istanbul ignore next */
const newPatient = () => {
console.log("Clicked New Patient");
};
return (
<div id="landing-wrapper">
<div className="button-flex">
<Button onClick={patientLookup} icon="search">
Patient Lookup
</Button>
<WhiteSpace />
</div>
<br />
<div className="button-flex">
<Button icon={<UserAddOutlined />} onClick={newPatient}>
New Patient
</Button>
<WhiteSpace />
</div>
</div>
);
}
+7
View File
@@ -1,8 +1,11 @@
import React, { ReactElement } from 'react'
import useApi from '../hooks/useApi'
import {InputItem, Button} from 'antd-mobile'
import '../scss/Login.scss'
export default function Login(): ReactElement {
const {response, error, isLoading} = useApi("")
return (
<>
<div id="loginWrapper">
@@ -19,6 +22,10 @@ export default function Login(): ReactElement {
</div>
</div>
</div>
<p>Loading API Fetch: {isLoading.toString()}</p>
{response &&
<p>API Fetch Result: {JSON.stringify(response)}</p>
}
</>
)
}
+16
View File
@@ -0,0 +1,16 @@
import { renderHook } from '@testing-library/react-hooks'
import useApi from './useApi'
test('should return loading and then a response', async () => {
const { result, waitForNextUpdate } = renderHook(() => useApi(""))
expect(result.current.response).toBeNull()
expect(result.current.error).toBeNull()
expect(result.current.isLoading).toBeTruthy()
await waitForNextUpdate()
expect(result.current.response).toBeTruthy()
expect(result.current.error).toBeNull()
expect(result.current.isLoading).toBeFalsy()
})
+35
View File
@@ -0,0 +1,35 @@
import React from 'react'
const useApi = (route: string) => {
const [response, setResponse] = React.useState(null);
const [error, setError] = React.useState(null);
const [isLoading, setIsLoading] = React.useState(false);
/* istanbul ignore next */
const getUrl = () => {
if (process.env.environment === "docker"){
return "http://api:4000/"
}
else {
return "http://localhost:4000/"
}
}
React.useEffect(() => {
const fetchData = async () => {
setIsLoading(true);
try {
const res = await fetch(getUrl() + route);
const json = await res.json();
setResponse(json);
setIsLoading(false)
} catch (error) {
setError(error);
}
};
fetchData();
}, []);
return { response, error, isLoading };
};
export default useApi
+1
View File
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import React from 'react';
import ReactDOM from 'react-dom';
import './scss/index.scss';
+5 -1
View File
@@ -1,3 +1,7 @@
.am-button:hover {
cursor: pointer;
}
#root {
height: 100vh;
}
}
+21
View File
@@ -0,0 +1,21 @@
.button-flex {
animation-name: fade-in;
animation-duration: 2s;
display: flex;
justify-content: center;
margin: 2em 0;
.am-button {
background-color: #9bd7ff;
width: 40%;
&.am-button-active {
background-color: #ccebff;
}
}
}
#landing-wrapper {
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
}
+1
View File
@@ -1,3 +1,4 @@
/* istanbul ignore file */
// This optional code is used to register a service worker.
// register() is not called by default.
+1
View File
@@ -6,6 +6,7 @@
"dom.iterable",
"esnext"
],
"strictNullChecks": false,
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,