Skip to content

Commit 5e6a793

Browse files
committed
Refatctor tests and add more cases to increase coverage
1 parent 833b798 commit 5e6a793

File tree

2 files changed

+102
-2
lines changed

2 files changed

+102
-2
lines changed

test/integration/metadataAPITests.js

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ const sampleMetadata = {
108108
{user: 'User 6', method: 'email', maxAlerts: '1 per day'}
109109
]
110110
}
111+
],
112+
Keystore: [
113+
{
114+
key: 'Key'
115+
}
111116
]
112117
}
113118

@@ -748,9 +753,99 @@ describe('API Integration Tests', () => {
748753
await testUtils.setupTestUsers()
749754
})
750755

751-
it('should validate metadata and return status 201', async () => {
752-
const im = await PassportModelAPI.find()
756+
const sampleMetadata = {
757+
Channels: [
758+
{
759+
name: 'TestChannel1',
760+
urlPattern: 'test/sample',
761+
allow: ['PoC', 'Test1', 'Test2'],
762+
routes: [
763+
{name: 'test route', host: 'localhost', port: 9876, primary: true}
764+
],
765+
txViewAcl: 'group1',
766+
updatedBy: {
767+
id: new ObjectId(),
768+
name: 'Test'
769+
}
770+
}
771+
],
772+
Clients: [
773+
{
774+
clientID: 'YUIAIIIICIIAIA',
775+
clientDomain: 'him.jembi.org',
776+
name: 'OpenMRS Ishmael instance',
777+
roles: ['OpenMRS_PoC', 'PoC'],
778+
passwordHash:
779+
'$2a$10$w8GyqInkl72LMIQNpMM/fenF6VsVukyya.c6fh/GRtrKq05C2.Zgy',
780+
certFingerprint:
781+
'23:37:6A:5E:A9:13:A4:8C:66:C5:BB:9F:0E:0D:68:9B:99:80:10:FC'
782+
}
783+
],
784+
Mediators: [
785+
{
786+
urn: 'urn:uuid:EEA84E13-1C92-467C-B0BD-7C480462D1ED',
787+
version: '1.0.0',
788+
name: 'Save Encounter Mediator',
789+
description: 'A mediator for testing',
790+
endpoints: [
791+
{
792+
name: 'Save Encounter',
793+
host: 'localhost',
794+
port: '8005',
795+
type: 'http'
796+
}
797+
],
798+
defaultChannelConfig: [
799+
{
800+
name: 'Save Encounter 1',
801+
urlPattern: '/encounters',
802+
type: 'http',
803+
allow: [],
804+
routes: [
805+
{
806+
name: 'Save Encounter 1',
807+
host: 'localhost',
808+
port: '8005',
809+
type: 'http'
810+
}
811+
]
812+
}
813+
]
814+
}
815+
],
816+
Users: [
817+
{
818+
firstname: 'Namey',
819+
surname: 'mcTestName',
820+
821+
passwordAlgorithm: 'sha512',
822+
passwordHash: '796a5a8e-4e44-4d9f-9e04-c27ec6374ffa',
823+
passwordSalt: 'bf93caba-6eec-4c0c-a1a3-d968a7533fd7',
824+
groups: ['admin', 'RHIE']
825+
}
826+
],
827+
Passports: [
828+
{
829+
830+
protocol: 'local'
831+
}
832+
],
833+
ContactGroups: [
834+
{
835+
group: 'Group 1',
836+
users: [
837+
{user: 'User 1', method: 'sms', maxAlerts: 'no max'},
838+
{user: 'User 2', method: 'email', maxAlerts: '1 per hour'},
839+
{user: 'User 3', method: 'sms', maxAlerts: '1 per day'},
840+
{user: 'User 4', method: 'email', maxAlerts: 'no max'},
841+
{user: 'User 5', method: 'sms', maxAlerts: '1 per hour'},
842+
{user: 'User 6', method: 'email', maxAlerts: '1 per day'}
843+
]
844+
}
845+
]
846+
}
753847

848+
it('should validate metadata and return status 201', async () => {
754849
const res = await request(BASE_URL)
755850
.post('/metadata/validate')
756851
.set('Cookie', rootCookie)

test/unit/metadataTest.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ describe('Metadata Functions', () => {
5858
groups: 'cgUID'
5959
})
6060
result.should.have.property('groups', 'cgUID')
61+
62+
result = metadata.getUniqueIdentifierForCollection('Invalid-collection', {
63+
id: '123333'
64+
})
65+
result.should.deepEqual({})
6166
return done()
6267
}))
6368

0 commit comments

Comments
 (0)