diff --git a/test/e2e/api/client/metrics.e2e.test.js b/test/e2e/api/client/metrics.e2e.test.js index a99999c7e8..8d535d2400 100644 --- a/test/e2e/api/client/metrics.e2e.test.js +++ b/test/e2e/api/client/metrics.e2e.test.js @@ -2,4 +2,27 @@ const { test } = require('ava'); -test.todo('e2e client metrics'); +const { setupApp } = require('./../../helpers/test-helper'); +const metricsExample = require('../../../examples/client-metrics.json'); + +test.serial('should be possble to send metrics', async t => { + t.plan(0); + const { request, destroy } = await setupApp('metrics_api_client'); + return request + .post('/api/client/metrics') + .send(metricsExample) + .expect(202) + .then(destroy); +}); + +test.serial('should require valid send metrics', async t => { + t.plan(0); + const { request, destroy } = await setupApp('metrics_api_client'); + return request + .post('/api/client/metrics') + .send({ + appName: 'test', + }) + .expect(400) + .then(destroy); +}); diff --git a/test/examples/client-metrics.json b/test/examples/client-metrics.json new file mode 100644 index 0000000000..327ea2b7e1 --- /dev/null +++ b/test/examples/client-metrics.json @@ -0,0 +1,18 @@ +{ + "appName": "appName", + "instanceId": "instanceId", + "bucket": { + "start": "2016-11-03T07:16:43.572Z", + "stop": "2016-11-03T07:16:53.572Z", + "toggles": { + "toggle-name-1": { + "yes": 123, + "no": 321 + }, + "toggle-name-2": { + "yes": 111, + "no": 0 + } + } + } +}