Skip to content

Commit

Permalink
Added fail cases
Browse files Browse the repository at this point in the history
  • Loading branch information
euanmillar committed Jun 17, 2019
2 parents 05a468a + c128faa commit 292e6b6
Show file tree
Hide file tree
Showing 33 changed files with 108 additions and 58 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ jobs:
- stage: integration tests on staging
if: branch = master AND type = push
install: skip
addons:
apt:
packages:
- libgconf-2-4
script: cd packages/e2e && yarn && yarn start --record false
env:
- CYPRESS_LOGIN_URL=https://login.opencrvs-staging.jembi.org/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ All hotfixes that are done for that release should be submitted in a PR against
1. Update all packages with the new version number according to [semver](https://semver.org/). All packages will have the same version for simplicity as they are all designed to be used together. Update all dependencies to point to the newly created versions. E.g. `register` depend on `components`, so update the dependency: Do a find and replace for `1.0.0-alpha.2` and replace with `1.0.0-alpha.3`
2. Run `yarn` to ensure there are no version errors.
3. Run `yarn test` and ensure all passed.
4. Run `git tag v<version_number>` e.g. `git tag v1.0.0-alpha.6`
4. Run `git tag v<version_number>` e.g. `git tag v1.0.0-alpha.1.0`
5. Run `git push origin v<version_number>`
6. Create a [new release on Github](https://github.com/jembi/OpenCRVS/releases) using the tag you just pushed and including any release notes.
7. Dockerhub should automatically build the images when a new release tag is created in Git. Howver Dockerhub can sometimes timeout and you may need to compose and push the release tagged images locally. To do that, run `yarn compose:push:release`
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/auth",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"description": "OpenCRVS authentication service",
"main": "src/index.js",
"license": "NONE",
Expand Down
2 changes: 1 addition & 1 deletion packages/commons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/commons",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"description": "OpenCRVS common modules and utils",
"main": "src/index.ts",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/components",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"private": true,
"dependencies": {
"@types/react-intl": "^2.3.17",
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "e2e",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/gateway/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/gateway",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"description": "OpenCRVS API Gateway with GraphQL",
"scripts": {
"start": "concurrently \"nodemon --exec ts-node -r tsconfig-paths/register src/index.ts\" \"yarn gen:types:watch\"",
Expand All @@ -15,7 +15,7 @@
"test:compilation": "tsc --noEmit"
},
"dependencies": {
"@opencrvs/commons": "^1.0.0-alpha.6",
"@opencrvs/commons": "^1.0.0-alpha.1.0",
"@types/glob": "^5.0.35",
"@types/hapi": "^17.0.12",
"@types/hapi-auth-jwt2": "8.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/integration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/integration",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"description": "A set of integration and performance tests for OpenCRVS",
"main": "index.js",
"license": "NONE",
Expand Down
4 changes: 2 additions & 2 deletions packages/login/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@opencrvs/login",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"private": true,
"dependencies": {
"@craco/craco": "^5.2.1",
"@opencrvs/components": "^1.0.0-alpha.6",
"@opencrvs/components": "^1.0.0-alpha.1.0",
"@sentry/browser": "^4.6.3",
"@types/history": "^4.6.2",
"@types/react-intl": "^2.3.8",
Expand Down
4 changes: 2 additions & 2 deletions packages/metrics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/metrics",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"description": "OpenCRVS metrics service",
"main": "src/index.js",
"license": "NONE",
Expand All @@ -15,7 +15,7 @@
"test:compilation": "tsc --noEmit"
},
"dependencies": {
"@opencrvs/commons": "^1.0.0-alpha.6",
"@opencrvs/commons": "^1.0.0-alpha.1.0",
"@types/boom": "^7.2.0",
"@types/fhir": "^0.0.30",
"@types/hapi": "^17.0.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/notification/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/notification",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"description": "OpenCRVS notification service",
"main": "src/index.js",
"license": "NONE",
Expand All @@ -15,7 +15,7 @@
"test:compilation": "tsc --noEmit"
},
"dependencies": {
"@opencrvs/commons": "^1.0.0-alpha.6",
"@opencrvs/commons": "^1.0.0-alpha.1.0",
"@types/hapi": "^17.0.12",
"@types/hapi-auth-jwt2": "8.0.1",
"@types/joi": "^14.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/performance/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@opencrvs/performance",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"private": true,
"dependencies": {
"@craco/craco": "^5.2.1",
"@opencrvs/commons": "^1.0.0-alpha.6",
"@opencrvs/components": "^1.0.0-alpha.6",
"@opencrvs/commons": "^1.0.0-alpha.1.0",
"@opencrvs/components": "^1.0.0-alpha.1.0",
"@sentry/browser": "^4.6.3",
"@types/redux-sentry-middleware": "^0.0.1",
"@typescript-eslint/eslint-plugin": "^1.9.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/register/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@opencrvs/register",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"private": true,
"dependencies": {
"@craco/craco": "^5.2.1",
"@opencrvs/components": "^1.0.0-alpha.6",
"@opencrvs/components": "^1.0.0-alpha.1.0",
"@sentry/browser": "^4.6.3",
"@types/bcryptjs": "^2.4.2",
"@types/history": "^4.6.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class HeaderComp extends React.Component<IProps, IState> {
const { userDetails, language, intl } = this.props

let name = ''
if (userDetails && userDetails.name && userDetails.name) {
if (userDetails && userDetails.name) {
const nameObj = userDetails.name.find(
(storedName: GQLHumanName | null) => {
const name = storedName as GQLHumanName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ describe('When calling getDeathQueryMappings', () => {
expect(query).not.toBe(null)
if (query && query.dataKey) {
expect(query.dataKey).toEqual('markDeathAsCertified')
} else {
jest.fail()
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ describe('When calling getDeathQueryMappings', () => {
expect(query).not.toBe(null)
if (query && query.query) {
expect(query.query).toEqual(GET_DEATH_REGISTRATION_FOR_CERTIFICATION)
} else {
jest.fail()
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ class NotificationToast extends React.Component<IFullProps> {

function mapStatetoProps(state: IStoreState) {
return {
application: [...state.applicationsState.applications]
application:
state.applicationsState && state.applicationsState.applications
? [...state.applicationsState.applications]
: []
}
}
export default connect(mapStatetoProps)(injectIntl(NotificationToast))
23 changes: 14 additions & 9 deletions packages/register/src/views/RegistrarHome/RegistrarHome.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ describe('RegistrarHome tests', () => {
).toContain('Sent for updates (5)')
})
it('renders all items returned from graphql query in ready for reivew', async () => {
const TIME_STAMP = '1544188309380'
Date.now = jest.fn(() => 1554055200000)
const graphqlMock = [
{
Expand Down Expand Up @@ -397,8 +398,8 @@ describe('RegistrarHome tests', () => {
registeredLocationId:
'308c35b4-04f8-4664-83f5-9790e790cde1',
duplicates: null,
createdAt: '2018-05-23T14:44:58+02:00',
modifiedAt: '2018-05-23T14:44:58+02:00'
createdAt: TIME_STAMP,
modifiedAt: TIME_STAMP
},
dateOfBirth: '2010-10-10',
childName: [
Expand All @@ -425,8 +426,8 @@ describe('RegistrarHome tests', () => {
duplicates: ['308c35b4-04f8-4664-83f5-9790e790cd33'],
registeredLocationId:
'308c35b4-04f8-4664-83f5-9790e790cde1',
createdAt: '2007-01-01',
modifiedAt: '2007-01-01'
createdAt: TIME_STAMP,
modifiedAt: TIME_STAMP
},
dateOfBirth: null,
childName: null,
Expand Down Expand Up @@ -465,19 +466,23 @@ describe('RegistrarHome tests', () => {
})
testComponent.component.update()
const data = testComponent.component.find(GridTable).prop('content')
const EXPECTED_DATE_OF_APPLICATION = moment(
moment(TIME_STAMP, 'x').format('YYYY-MM-DD HH:mm:ss'),
'YYYY-MM-DD HH:mm:ss'
).fromNow()

expect(data.length).toBe(2)
expect(data[0].id).toBe('e302f7c5-ad87-4117-91c1-35eaf2ea7be8')
expect(data[0].eventTimeElapsed).toBe('8 years ago')
expect(data[0].applicationTimeElapsed).toBe('10 months ago')
expect(data[0].applicationTimeElapsed).toBe(EXPECTED_DATE_OF_APPLICATION)
expect(data[0].trackingId).toBe('BW0UTHR')
expect(data[0].event).toBe('Birth')
expect(data[0].actions).toBeDefined()

testComponent.component.unmount()
})
it('renders all items returned from graphql query in rejected tab', async () => {
const TIME_STAMP = '2018-12-07T13:11:49.380Z'
const TIME_STAMP = '1544188309380'
const graphqlMock = [
{
request: {
Expand Down Expand Up @@ -569,14 +574,14 @@ describe('RegistrarHome tests', () => {

// wait for mocked data to load mockedProvider
await new Promise(resolve => {
setTimeout(resolve, 100)
setTimeout(resolve, 200)
})
testComponent.component.update()
console.log(testComponent.component.debug())
const data = testComponent.component.find(GridTable).prop('content')
const EXPECTED_DATE_OF_REJECTION = moment(
TIME_STAMP,
'YYYY-MM-DD'
moment(TIME_STAMP, 'x').format('YYYY-MM-DD HH:mm:ss'),
'YYYY-MM-DD HH:mm:ss'
).fromNow()

expect(data.length).toBe(2)
Expand Down
10 changes: 8 additions & 2 deletions packages/register/src/views/RegistrarHome/RegistrarHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ export class RegistrarHomeView extends React.Component<
'',
applicationTimeElapsed:
(reg.createdAt &&
moment(reg.createdAt.toString(), 'YYYY-MM-DD').fromNow()) ||
moment(
moment(reg.createdAt, 'x').format('YYYY-MM-DD HH:mm:ss'),
'YYYY-MM-DD HH:mm:ss'
).fromNow()) ||
'',
actions
}
Expand Down Expand Up @@ -369,7 +372,10 @@ export class RegistrarHomeView extends React.Component<
...reg,
dateOfRejection:
(reg.modifiedAt &&
moment(reg.modifiedAt.toString(), 'YYYY-MM-DD').fromNow()) ||
moment(
moment(reg.modifiedAt, 'x').format('YYYY-MM-DD HH:mm:ss'),
'YYYY-MM-DD HH:mm:ss'
).fromNow()) ||
'',
actions
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const ErrorText = styled.div`
color: ${({ theme }) => theme.colors.error};
${({ theme }) => theme.fonts.bodyStyle};
text-align: center;
margin-top: 100px;
margin: 25px;
`

function LabelValue({ label, value }: { label: string; value: string }) {
Expand Down
4 changes: 2 additions & 2 deletions packages/resources/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/resources",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"description": "OpenCRVS resources for reference data",
"scripts": {
"test:watch": "jest --watch",
Expand Down Expand Up @@ -57,7 +57,7 @@
"typestyle": "^1.3.7"
},
"dependencies": {
"@opencrvs/commons": "^1.0.0-alpha.6",
"@opencrvs/commons": "^1.0.0-alpha.1.0",
"@types/chalk": "^2.2.0",
"@types/hapi": "^17.8.2",
"@types/hapi-auth-jwt2": "8.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/search/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/search",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.1.0",
"description": "OpenCRVS search service",
"main": "src/index.js",
"license": "NONE",
Expand All @@ -15,7 +15,7 @@
"test:compilation": "tsc --noEmit"
},
"dependencies": {
"@opencrvs/commons": "^1.0.0-alpha.6",
"@opencrvs/commons": "^1.0.0-alpha.1.0",
"@types/boom": "^7.2.0",
"@types/elasticsearch": "^5.0.30",
"@types/fhir": "^0.0.30",
Expand Down
2 changes: 2 additions & 0 deletions packages/search/src/elasticsearch/dbhelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ describe('elasticsearch db helper', async () => {
searchSpy.mock.calls[0][0]
) {
expect(searchSpy.mock.calls[0][0].body.query).toBeDefined()
} else {
jest.fail()
}
expect(searchSpy).toBeCalled()
})
Expand Down
33 changes: 18 additions & 15 deletions packages/search/src/elasticsearch/dbhelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,35 @@ export const updateComposition = async (id: string, body: ICompositionBody) => {
}

export const searchComposition = async (body: ICompositionBody) => {
let response: any
try {
response = client.search({
const response = client.search({
index: 'ocrvs',
type: 'compositions',
body: {
query: buildQuery(body)
}
})
} catch (e) {
logger.error(`searchComposition: error: ${e}`)
return response
} catch (err) {
return null
}
return response
}

export const searchByCompositionId = async (compositionId: string) => {
const response = await client.search({
index: 'ocrvs',
type: 'compositions',
body: {
query: {
match: {
_id: compositionId
try {
const response = await client.search({
index: 'ocrvs',
type: 'compositions',
body: {
query: {
match: {
_id: compositionId
}
}
}
}
})
return response
})
return response
} catch (err) {
return null
}
}
Loading

0 comments on commit 292e6b6

Please sign in to comment.