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

Added integration tests for a few routes. #33

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
42198ec
added tsconfig for tests and jest config
May 16, 2021
11b20c1
added integration tests for /auth/register
May 16, 2021
4a9a520
formatting
May 16, 2021
4567e3b
add firebase emulator config
May 16, 2021
7ab0d40
added firebase-tools for emulators
May 16, 2021
7a2e32c
re-formatting
May 16, 2021
18eceff
send email verification link
May 16, 2021
e95295a
send veriification email
May 16, 2021
1a40510
formatting
May 16, 2021
8d31492
added env variables for tests
May 16, 2021
3dc7b30
[wip] adding tests
May 16, 2021
0be6fcc
formatting
May 16, 2021
935279a
added integration tests with firebase emulators
May 16, 2021
dd41bfb
updated routes and resolved merge conflicts
May 16, 2021
bbfd8c5
fixed integration tests and added lint-staged
May 17, 2021
50c52be
updated save-user-details test and lint-staged config
May 17, 2021
1d30f16
updated save-user-details test and lint-staged config
May 17, 2021
df387f9
updated save-user-details test and lint-staged config
May 17, 2021
9337978
Merge branch 'master' into add-tests
May 17, 2021
f3b1ede
update routes in integration tests
May 17, 2021
f190bdc
small change
May 17, 2021
fb8f5d4
use node-14 for workflow
May 17, 2021
83c492c
updated string in tests for medical_practitioner
May 17, 2021
f675563
re-formatted
May 17, 2021
53c5aeb
re-formatted
May 17, 2021
53d541d
testing firestore in integration tests
May 20, 2021
9d8a18c
run unit tests before deploy
May 20, 2021
767b7c9
Merge branch 'master' into add-tests
May 20, 2021
50bd1a1
Merge master into add-tests
May 20, 2021
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
13 changes: 8 additions & 5 deletions .github/workflows/core-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

strategy:
matrix:
node-version: [12.x]
node-version: [14.x]

outputs:
status: ${{ steps.early.conclusion }}
Expand All @@ -43,7 +43,7 @@ jobs:
# Check for package changes
- name: Check for package changes
id: early
run: ./ci/check-package.sh "core-api"
run: ./ci/check-package.sh "core-api"

build:
# The type of runner that the job will run on
Expand All @@ -54,7 +54,7 @@ jobs:

strategy:
matrix:
node-version: [12.x]
node-version: [14.x]

steps:
# Checkout the source code
Expand All @@ -69,8 +69,11 @@ jobs:
node-version: ${{ matrix.node-version }}

# Check for package changes
- name: Run test
run: echo "Running test"
- name: Run tests
uses: 'actions/setup-node@v1'
run:
- yarn install
- ./ci/test-unit.sh "core-api"

deploy:
# The type of runner that the job will run on
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn format
lerna run --concurrency 1 --stream precommit --since HEAD --exclude-dependents
12 changes: 6 additions & 6 deletions ci/check-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -o pipefail

source ./ci/setup.sh

pipeline_name=$1
pipeline_name="$1"

echo "telly.health..."

Expand Down Expand Up @@ -35,7 +35,7 @@ get_changes() {
if [[ "${GITHUB_REF}" == "refs/heads/master" ]] ; then
# get packages from last commit
changes_from_last_commit
elif [[ "${GITHUB_REF}" =~ ^v[0-9]+\.[0-9]+ ]]; then
elif [[ "${GITHUB_REF}" =~ ^v[0-9]+\.[0-9]+ ]]; then
# get packages from release artifacts
changes_on_tagged_release
else
Expand Down Expand Up @@ -88,18 +88,18 @@ main () {
local name
local location
local is_package_changed="false"

changes=$(get_changes | jq -c ".")

for package in $(json_arry_to_base64 "${changes}"); do
name="$(get_package_name "$(decode_base64 "${package}")")"
location="$(get_package_location "$(decode_base64 "${package}")")"
log_info "The package ${name} at ${location} has changed. A build with run id ${GITHUB_RUN_ID} will triggered for the project."
if [[ $pipeline_name == $name ]]; then
if [[ $pipeline_name == "${name}" ]]; then
is_package_changed="true"
fi
done

if [[ $is_package_changed == "true" ]]; then
log_info "The package ${pipeline_name} files has changed. Continue the pipeline."
echo ::set-output name=conclusion::success
Expand Down
9 changes: 9 additions & 0 deletions ci/test-integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# fail on first error
set -o errexit
set -o nounset
set -o pipefail

package_name="$1"
lerna exec yarn test:integration:ci --scope "${package_name}"
12 changes: 12 additions & 0 deletions ci/test-unit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# fail on first error
set -o errexit
set -o nounset
set -o pipefail

package_name="$1"

nohup yarn workspace core-api

lerna exec yarn test:unit --scope "${package_name}"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"packages/**"
],
"scripts": {
"setup": "lerna boostrap --no-ci",
"prepare": "husky install",
"format": "lerna exec yarn format"
}
}
}
3 changes: 3 additions & 0 deletions packages/service/core/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
infrastructure
node_modules
14 changes: 14 additions & 0 deletions packages/service/core/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": "standard-with-typescript",
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"project": "./tsconfig.json",
"tsConfigRootDir": "__dirname",
"ecmaVersion": 12
}
}
16 changes: 16 additions & 0 deletions packages/service/core/.eslintrc.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "standard-with-typescript",
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"parserOptions": {
"project": "./tsconfig.test.json",
"tsConfigRootDir": "__dirname",
"ecmaVersion": 12
},
"env": {
"node": true,
"es6": true
}
}
5 changes: 5 additions & 0 deletions packages/service/core/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "tellyhealth"
}
}
66 changes: 66 additions & 0 deletions packages/service/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*
firebase-debug.*.log*

# Firebase cache
.firebase/

# Firebase config

# Uncomment this if you'd like others to create their own Firebase project.
# For a team working on the same Firebase project(s), it is recommended to leave
# it commented so all members can deploy to the same project(s) in .firebaserc.
# .firebaserc

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
4 changes: 4 additions & 0 deletions packages/service/core/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"(src|test)/*.(ts|js|json)": ["yarn format", "yarn lint", "git add"],
"*.json": ["yarn format", "git add"]
}
5 changes: 4 additions & 1 deletion packages/service/core/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
dist/
node_modules/
node_modules/
.eslintignore
.eslintrc.test
infrastructure/
15 changes: 15 additions & 0 deletions packages/service/core/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"emulators": {
"auth": {
"host": "localhost",
"port": 9099
},
"firestore": {
"host": "localhost",
"port": 8080
},
"ui": {
"enabled": true
}
}
}
37 changes: 37 additions & 0 deletions packages/service/core/jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"projects": [
{
"displayName": "UnitTests",
"testEnvironment": "node",
"testMatch": ["<rootDir>/test/unit/**/*.test.ts"],
"testRunner": "jest-circus/runner",
"transform": {
"^.+\\.ts$": "ts-jest"
},
"moduleFileExtensions": ["ts", "js", "json"],
"setupFiles": ["dotenv-flow/config"],
"globals": {
"ts-jest": {
"tsconfig": "./tsconfig.test.json"
}
}
},
{
"displayName": "IntegrationTests",
"testEnvironment": "node",
"testMatch": ["<rootDir>/test/integration/**/*.test.ts"],
"testRunner": "jest-circus/runner",
"transform": {
"^.+\\.ts$": "ts-jest"
},
"moduleFileExtensions": ["ts", "js", "json"],
"setupFiles": ["dotenv-flow/config"],
"setupFilesAfterEnv": ["<rootDir>/test/setup.ts"],
"globals": {
"ts-jest": {
"tsconfig": "./tsconfig.test.json"
}
}
}
]
}
2 changes: 1 addition & 1 deletion packages/service/core/nodemon.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"watch": ["src", "openapi.yaml"],
"ext": "ts",
"ignore": [".git", "node_modules"],
"exec": "GOOGLE_APPLICATION_CREDENTIALS='./service-account.json' node --experimental-specifier-resolution=node --experimental-repl-await --experimental-json-modules --loader ts-node/esm -r dotenv/config src/index.ts"
"exec": "GOOGLE_APPLICATION_CREDENTIALS='./service-account.json' node --experimental-specifier-resolution=node --experimental-repl-await --experimental-json-modules --loader ts-node/esm -r dotenv-flow/config src/index.ts"
}
Loading