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

Updated Jest & Create React App #836

Merged
merged 58 commits into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
75abd64
Update Jest and attend to typescript issues in some packages
euanmillar May 28, 2019
3a49b5f
Fix search tests
euanmillar May 28, 2019
2e6b9d6
Fix typescript issues in user-mgnt package tests
euanmillar May 28, 2019
52dbc85
Resources tests were failing because of a jest-fetch-mock type issue
euanmillar May 29, 2019
ee7352e
Jest-fetch-mock has a breaking change with @types/jest >23.3.14 so th…
euanmillar May 29, 2019
1c0239f
Upgrade the clients to create-react-app 3.0.1
euanmillar May 30, 2019
819d1d8
Remove all relative paths from services
euanmillar May 30, 2019
9649153
Add absolute paths to register app
euanmillar May 31, 2019
6c86caa
Replace tslint with eslint
euanmillar Jun 3, 2019
283dba7
Remove patch-package and instead set up craco with eslint
euanmillar Jun 4, 2019
42b1d3d
Resolve typescript issues in register app
euanmillar Jun 4, 2019
d49d9a0
Fix more typescript issues
euanmillar Jun 4, 2019
e998bde
Fix more typescript issues
euanmillar Jun 4, 2019
79e5ebf
Install Craco and set absolute paths in login and performance app
euanmillar Jun 4, 2019
2b5e897
Resolve missing plugins to enable eslint to work
euanmillar Jun 5, 2019
1526ada
Fix react-intl locale data imports
rcrichton Jun 5, 2019
4500216
Fix createSentryMiddleware import
rcrichton Jun 5, 2019
2261c57
Fix Enzyme adapter import
rcrichton Jun 5, 2019
98e8873
Update eslint rules in package.json
euanmillar Jun 5, 2019
468ba0a
Fix nock import
rcrichton Jun 5, 2019
439c834
Dont run performance tests with lerna start
rcrichton Jun 5, 2019
08397df
Auto fix lint issues
rcrichton Jun 5, 2019
b59486b
Fix linting errors [part 1]
rcrichton Jun 5, 2019
2297d05
Fix linting errors [part 2]
rcrichton Jun 6, 2019
421ce15
Fix linting errors [part 3]
rcrichton Jun 6, 2019
05e97d7
Resolve 30 more Typescript issues
euanmillar Jun 6, 2019
477f30e
Fix or disable remaining Typescript issues in register app
euanmillar Jun 6, 2019
f74c111
Resolve typescript issues in login app
euanmillar Jun 6, 2019
36727b2
Fix typescript issues in performance app
euanmillar Jun 6, 2019
7987690
Test copying webpack from react-scripts-ts
euanmillar Jun 6, 2019
346cf9b
Complete the ejection of react-scripts-ts in components package
euanmillar Jun 6, 2019
6075d20
Patch react-scripts to remove warning breaking CI
euanmillar Jun 7, 2019
a0afeae
Deletes registerServiceWorker tests that fail with new Jest upgrade
euanmillar Jun 7, 2019
1da0c38
Fix issues in tests causing CI to fail on login app
euanmillar Jun 7, 2019
20cb284
Merge branch 'master' into updated-tests
euanmillar Jun 7, 2019
47bb8db
fixed imports
euanmillar Jun 7, 2019
59ba786
fixed more bad imports and type issues
euanmillar Jun 7, 2019
6302fa8
Fixed some more tests failing because of bad graphql
euanmillar Jun 10, 2019
68f66ce
Fix jest fecth mock types whne used for node-fetch
rcrichton Jun 10, 2019
abd279a
Fixed settigns and timeoutLink test
euanmillar Jun 10, 2019
bfea16e
merged master
euanmillar Jun 10, 2019
8e61ca3
Enforce absolute imports in services
euanmillar Jun 11, 2019
8978b34
Enforce absolute imports on clients
euanmillar Jun 11, 2019
d1bd9d8
Add comment markers where unnecessary graphql return objects had to b…
euanmillar Jun 11, 2019
e01f2d6
FieldAgentHome test cases fixed
mushrafulhoque-dsi Jun 11, 2019
fe2c5d6
merged master
euanmillar Jun 12, 2019
accb80e
merged master and resolved refernceApi and search tests
euanmillar Jun 12, 2019
4904062
replaced tslint lint-staged hook in search
euanmillar Jun 12, 2019
6952bbc
Merge branch 'master' into updated-tests
euanmillar Jun 13, 2019
a88a2ba
merged master to fix conflict in package.json
euanmillar Jun 13, 2019
9b3d190
Delete failing generatePDF.test
euanmillar Jun 13, 2019
551f477
Fixed getUser tests, commented out failing createUser error tests and…
euanmillar Jun 13, 2019
05a468a
Patch react-scripts so that warnings are not treated as errors in CI
euanmillar Jun 13, 2019
69bcab1
Fixes for usr-mgnt populate script, registrar home and settings page …
mushrafulhoque-dsi Jun 14, 2019
292e6b6
Added fail cases
euanmillar Jun 17, 2019
c48277d
Merge branch 'updated-tests' of github.com:jembi/OpenCRVS into update…
euanmillar Jun 17, 2019
fb08485
removed eject scripts
euanmillar Jun 17, 2019
dc11c44
Throw error instead of unsupported fail method uncaught by tslint
euanmillar Jun 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ build
.secrets/*
# But, keep the .gitignore so the folder is created
!.secrets/.gitignore
.vscode
.idea
data
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"editor.formatOnSave": true,
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
{ "language": "typescript", "autoFix": true },
{ "language": "typescriptreact", "autoFix": true }
],
"typescript.updateImportsOnFileMove.enabled": "always",
"eslint.workingDirectories": [
{ "directory": "./packages/performance", "changeProcessCWD": true },
{ "directory": "./packages/register", "changeProcessCWD": true },
{ "directory": "./packages/login", "changeProcessCWD": true }
]
}
Binary file modified infrastructure/backups/hearth-dev.gz
Binary file not shown.
Binary file modified infrastructure/backups/openhim-dev.gz
Binary file not shown.
Binary file modified infrastructure/backups/user-mgnt.gz
Binary file not shown.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
}
},
"scripts": {
"postinstall": "patch-package",
"start": "lerna run build --scope @opencrvs/components && lerna run --parallel --ignore e2e --ignore @opencrvs/integration $OTHER_LERNA_FLAGS start",
"start:prod": "lerna run build --scope @opencrvs/components && lerna run --parallel --ignore e2e --ignore @opencrvs/integration $OTHER_LERNA_FLAGS start:prod",
"dev": "yarn dev:secrets:gen && concurrently \"yarn run start\" \"yarn run compose\"",
"dev:secrets:gen": "openssl genrsa -out .secrets/private-key.pem 2048 && openssl rsa -pubout -in .secrets/private-key.pem -out .secrets/public-key.pem",
"dev:tmux": "tmuxinator start",
"dev:tmux:kill": "tmux kill-session -t opencrvs",
"open": "opener 'http://localhost:6060/' && opener 'http://localhost:3020/'",
"test": "lerna run test --stream --watchAll=false",
"test": "CI=true lerna run test --silent --noStackTrace --stream --watchAll=false",
"compose": "docker-compose -p opencrvs -f docker-compose.deps.yml -f docker-compose.dev.yml up",
"compose:down": "docker-compose -p opencrvs -f docker-compose.deps.yml -f docker-compose.dev.yml down",
"compose:build": "docker-compose build",
Expand All @@ -40,6 +41,8 @@
"prettier": "^1.15.2"
},
"dependencies": {
"opener": "^1.5.1"
"opener": "^1.5.1",
"patch-package": "^6.1.2",
"postinstall-postinstall": "^2.0.0"
}
}
29 changes: 19 additions & 10 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"license": "NONE",
"private": true,
"scripts": {
"start": "cross-env NODE_ENV=DEVELOPMENT nodemon --exec ts-node -- src/index.ts",
"start:prod": "ts-node src/index.ts",
"test": "jest --coverage && yarn test:compilation",
"start": "cross-env NODE_ENV=DEVELOPMENT nodemon --exec ts-node -r tsconfig-paths/register src/index.ts",
"start:prod": "ts-node -r tsconfig-paths/register src/index.ts",
"test": "jest --silent --noStackTrace && yarn test:compilation",
"test:watch": "jest --watch",
"precommit": "lint-staged",
"precommit": "tslint --project ./tsconfig.json && lint-staged",
"generate-test-token": "NODE_PATH=. ts-node resources/generate-test-token",
"request-token": "NODE_PATH=. ts-node resources/request-token",
"test:compilation": "tsc --noEmit"
Expand All @@ -20,7 +20,7 @@
"@types/hapi": "^17.0.12",
"@types/joi": "^14.0.0",
"@types/jsonwebtoken": "^7.2.7",
"@types/node-fetch": "^2.1.2",
"@types/node-fetch": "^2.3.4",
"@types/redis": "^2.8.6",
"@types/winston": "^2.3.9",
"app-module-path": "^2.2.0",
Expand All @@ -35,23 +35,29 @@
"io-ts": "^1.2.1",
"joi": "^14.0.6",
"jsonwebtoken": "^8.3.0",
"node-fetch": "^2.2.1",
"node-fetch": "^2.6.0",
"redis": "^2.8.0",
"typescript": "^3.0.1",
"lint-staged": "^7.1.0",
"winston": "^3.0.0"
},
"devDependencies": {
"@types/command-line-args": "^5.0.0",
"@types/command-line-usage": "^5.0.1",
"@types/jest": "^24.0.13",
"command-line-args": "^5.0.2",
"command-line-usage": "^5.0.5",
"cross-env": "^5.2.0",
"jest": "23.6.0",
"jest-fetch-mock": "^1.6.5",
"jest": "24.7.1",
"jest-fetch-mock": "^2.1.2",
"nodemon": "^1.17.5",
"prettier": "^1.15.2",
"ts-jest": "^22.4.6",
"ts-node": "^6.1.1"
"redis-mock": "^0.27.0",
"ts-jest": "^24.0.2",
"ts-node": "^6.1.1",
"tsconfig-paths": "^3.8.0",
"tslint": "^5.17.0",
"tslint-microsoft-contrib": "^6.2.0"
},
"lint-staged": {
"src/**/*.{ts,graphql}": [
Expand All @@ -72,6 +78,9 @@
"modulePaths": [
"<rootDir>"
],
"moduleNameMapper": {
"@auth/(.*)": "<rootDir>/src/$1"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"setupFiles": [
"./test/setupJest.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/database.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as redis from 'redis'
import { REDIS_HOST } from './constants'
import { REDIS_HOST } from '@auth/constants'
import { promisify } from 'util'

let redisClient: redis.RedisClient
Expand Down
7 changes: 4 additions & 3 deletions packages/auth/src/features/authenticate/handler.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as fetch from 'jest-fetch-mock'
import { createServerWithEnvironment } from 'src/tests/util'
import * as fetchAny from 'jest-fetch-mock'
import { createServerWithEnvironment } from '@auth/tests/util'
import { createServer } from '../..'
import * as codeService from 'src/features/verifyCode/service'
import * as codeService from '@auth/features/verifyCode/service'

const fetch = fetchAny as any
describe('authenticate handler receives a request', () => {
let server: any

Expand Down
11 changes: 7 additions & 4 deletions packages/auth/src/features/authenticate/handler.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import * as Hapi from 'hapi'
import * as Joi from 'joi'
import { authenticate, storeUserInformation } from './service'
import {
authenticate,
storeUserInformation
} from '@auth/features/authenticate/service'
import {
generateVerificationCode,
sendVerificationCode,
generateNonce,
storeVerificationCode
} from 'src/features/verifyCode/service'
import { logger } from 'src/logger'
} from '@auth/features/verifyCode/service'
import { logger } from '@auth/logger'
import { unauthorized } from 'boom'
import { PRODUCTION } from 'src/constants'
import { PRODUCTION } from '@auth/constants'

interface IAuthPayload {
mobile: string
Expand Down
5 changes: 4 additions & 1 deletion packages/auth/src/features/authenticate/service.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { verifyToken, getStoredUserInformation } from './service'
import {
verifyToken,
getStoredUserInformation
} from '@auth/features/authenticate/service'

describe('authenticate service errors', () => {
describe('verifyToken - token expired', () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/auth/src/features/authenticate/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
CERT_PRIVATE_KEY_PATH,
CERT_PUBLIC_KEY_PATH,
CONFIG_TOKEN_EXPIRY_SECONDS
} from 'src/constants'
} from '@auth/constants'
import { resolve } from 'url'
import { readFileSync } from 'fs'
import { promisify } from 'util'
import * as jwt from 'jsonwebtoken'
import { get, set } from 'src/database'
import { get, set } from '@auth/database'
import * as t from 'io-ts'
import { ThrowReporter } from 'io-ts/lib/ThrowReporter'

Expand Down Expand Up @@ -92,6 +92,7 @@ export async function getStoredUserInformation(nonce: string) {
return JSON.parse(record)
}

/* tslint:disable */
const TokenPayload = t.type({
sub: t.string,
scope: t.array(t.string),
Expand All @@ -111,3 +112,4 @@ export function verifyToken(token: string): ITokenPayload {
ThrowReporter.report(result)
return result.value as ITokenPayload
}
/* tslint:enable */
2 changes: 1 addition & 1 deletion packages/auth/src/features/invalidateToken/handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Hapi from 'hapi'
import * as Joi from 'joi'
import { internal } from 'boom'
import { invalidateToken } from './service'
import { invalidateToken } from '@auth/features/invalidateToken/service'

interface IInvalidateTokenPayload {
token: string
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/features/invalidateToken/service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { setex } from 'src/database'
import { setex } from '@auth/database'
import {
INVALID_TOKEN_NAMESPACE,
CONFIG_TOKEN_EXPIRY_SECONDS
} from 'src/constants'
} from '@auth/constants'

export async function invalidateToken(token: string) {
return setex(
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/features/refresh/handler.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createServerWithEnvironment } from 'src/tests/util'
import { createServerWithEnvironment } from '@auth/tests/util'

describe('authenticate handler receives a request', () => {
let server: any
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/features/refresh/handler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as Hapi from 'hapi'
import * as Joi from 'joi'
import { unauthorized } from 'boom'
import { verifyToken } from 'src/features/authenticate/service'
import { refreshToken } from './service'
import { verifyToken } from '@auth/features/authenticate/service'
import { refreshToken } from '@auth/features/refresh/service'

interface IRefreshPayload {
nonce: string
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/features/refresh/service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createToken, ITokenPayload } from '../authenticate/service'
import { WEB_USER_JWT_AUDIENCES, JWT_ISSUER } from 'src/constants'
import { createToken, ITokenPayload } from '@auth/features/authenticate/service'
import { WEB_USER_JWT_AUDIENCES, JWT_ISSUER } from '@auth/constants'

export async function refreshToken(payload: ITokenPayload): Promise<string> {
return createToken(
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/features/resend/handler.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createServerWithEnvironment } from 'src/tests/util'
import { createServerWithEnvironment } from '@auth/tests/util'
import { createServer } from '../..'

describe('resend handler receives a request', () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/auth/src/features/resend/handler.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as Hapi from 'hapi'
import * as Joi from 'joi'
import { unauthorized } from 'boom'
import { getStoredUserInformation } from 'src/features/authenticate/service'
import { getStoredUserInformation } from '@auth/features/authenticate/service'
import {
generateVerificationCode,
sendVerificationCode
} from 'src/features/verifyCode/service'
import { PRODUCTION } from 'src/constants'
import { logger } from 'src/logger'
} from '@auth/features/verifyCode/service'
import { PRODUCTION } from '@auth/constants'
import { logger } from '@auth/logger'

interface IRefreshPayload {
nonce: string
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/features/verifyCode/handler.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createServerWithEnvironment } from 'src/tests/util'
import { createServerWithEnvironment } from '@auth/tests/util'

describe('authenticate handler receives a request', () => {
let server: any
Expand Down
11 changes: 7 additions & 4 deletions packages/auth/src/features/verifyCode/handler.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import * as Hapi from 'hapi'
import * as Joi from 'joi'
import { unauthorized } from 'boom'
import { checkVerificationCode, deleteUsedVerificationCode } from './service'
import {
checkVerificationCode,
deleteUsedVerificationCode
} from '@auth/features/verifyCode/service'
import {
getStoredUserInformation,
createToken
} from 'src/features/authenticate/service'
import { logger } from 'src/logger'
import { WEB_USER_JWT_AUDIENCES, JWT_ISSUER } from 'src/constants'
} from '@auth/features/authenticate/service'
import { logger } from '@auth/logger'
import { WEB_USER_JWT_AUDIENCES, JWT_ISSUER } from '@auth/constants'

interface IVerifyPayload {
nonce: string
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/features/verifyCode/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
generateNonce,
checkVerificationCode,
deleteUsedVerificationCode
} from './service'
} from '@auth/features/verifyCode/service'

import { CONFIG_SMS_CODE_EXPIRY_SECONDS } from 'src/constants'
import { CONFIG_SMS_CODE_EXPIRY_SECONDS } from '@auth/constants'

const nonce = '12345'
const mobile = '+447111111111'
Expand Down
8 changes: 4 additions & 4 deletions packages/auth/src/features/verifyCode/service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import fetch from 'node-fetch'
import { set, get, del } from 'src/database'
import { set, get, del } from '@auth/database'
import {
NOTIFICATION_SERVICE_URL,
CONFIG_SMS_CODE_EXPIRY_SECONDS,
JWT_ISSUER
} from 'src/constants'
} from '@auth/constants'
import * as crypto from 'crypto'
import { resolve } from 'url'
import { createToken } from 'src/features/authenticate/service'
import { createToken } from '@auth/features/authenticate/service'

interface ICodeDetails {
code: string
Expand All @@ -29,7 +29,7 @@ export async function generateVerificationCode(
nonce: string,
mobile: string
): Promise<SixDigitVerificationCode> {
// TODO lets come back to how these are generated
// tslint:disable-next-line
const code = Math.floor(100000 + Math.random() * 900000).toString()

await storeVerificationCode(nonce, code)
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/features/verifyToken/handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Hapi from 'hapi'
import * as Joi from 'joi'
import { verifyToken } from './service'
import { verifyToken } from '@auth/features/verifyToken/service'
import { internal } from 'boom'

interface IVerifyTokenPayload {
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/features/verifyToken/service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { get } from 'src/database'
import { INVALID_TOKEN_NAMESPACE } from 'src/constants'
import { get } from '@auth/database'
import { INVALID_TOKEN_NAMESPACE } from '@auth/constants'

export async function verifyToken(token: string) {
const record = await get(`${INVALID_TOKEN_NAMESPACE}:${token}`)
Expand Down
Loading