diff --git a/package.json b/package.json index 3ff5d8a1..f9017dea 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "openhim-core", "description": "The OpenHIM core application that provides logging and routing of http requests", - "version": "8.3.0", + "version": "8.3.1", "main": "./lib/server.js", "bin": { "openhim-core": "./bin/openhim-core.js" diff --git a/src/model/apps.js b/src/model/apps.js index bd1104b9..e5d9c509 100644 --- a/src/model/apps.js +++ b/src/model/apps.js @@ -11,9 +11,10 @@ const AppSchema = new Schema({ required: true }, description: String, - icon: { - data: Buffer, - contentType: String + icon: String, + type: { + type: String, + enum: ['link', 'embedded'] }, category: String, access_roles: [String], diff --git a/test/integration/appsAPITests.js b/test/integration/appsAPITests.js index 7f448cb7..e58dbbfe 100644 --- a/test/integration/appsAPITests.js +++ b/test/integration/appsAPITests.js @@ -20,7 +20,7 @@ describe('API Integration Tests', () => { name: 'Test app', description: 'An app for testing the app framework', icon: 'data:image/png;base64, ', - type: 'link|embedded', + type: 'link', category: 'Operations', access_roles: ['test-app-user'], url: 'http://test-app.org/app', diff --git a/test/unit/appsTest.js b/test/unit/appsTest.js new file mode 100644 index 00000000..dd04e819 --- /dev/null +++ b/test/unit/appsTest.js @@ -0,0 +1,56 @@ +'use strict' + +/* eslint-env mocha */ +import should from 'should' + +import {getApps, updateApp} from '../../src/api/apps' +import {AppModelAPI} from '../../src/model/apps' + +describe('Apps', () => { + afterEach(async () => { + await AppModelAPI.deleteMany({}) + }) + + describe('getApps', () => { + it('should fail when retrieving from mongo fails', async () => { + const ctx = { + request: { + query: {} + } + } + + await getApps(ctx) + + ctx.status.should.equal(500) + should.exist(ctx.body.error) + }) + }) + + describe('updateApps', () => { + it('should fail when updating in mongo fails', async () => { + const app = AppModelAPI({ + name: 'Test app1', + description: 'An app for testing the app framework', + icon: 'data:image/png;base64, ', + type: 'link', + category: 'Operations', + access_roles: ['test-app-user'], + url: 'http://test-app.org/app1', + showInPortal: true, + showInSideBar: true + }) + await app.save() + + const ctx = { + request: { + body: {} + }, + status: 200 + } + + await updateApp(ctx, app._id) + + should.exist(ctx.body.error) + }) + }) +})