From db227ac0fd191d57665c1e732011c39c8f741983 Mon Sep 17 00:00:00 2001 From: cptran777 Date: Sun, 12 Aug 2018 22:44:01 -0700 Subject: [PATCH] Fix tests for dataset health and create health mirage api handler --- wherehows-web/mirage/config.ts | 3 +++ .../mirage/helpers/dataset-health.ts | 9 +++++++ .../containers/dataset-health-test.js | 27 ++++++++++++------- 3 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 wherehows-web/mirage/helpers/dataset-health.ts diff --git a/wherehows-web/mirage/config.ts b/wherehows-web/mirage/config.ts index 2596930e94..1a086ae044 100644 --- a/wherehows-web/mirage/config.ts +++ b/wherehows-web/mirage/config.ts @@ -25,6 +25,7 @@ import { aclAuth } from 'wherehows-web/mirage/helpers/aclauth'; import { getDatasetUpstreams } from 'wherehows-web/mirage/helpers/dataset-upstreams'; import { getDatasetRetention } from 'wherehows-web/mirage/helpers/dataset-retentions'; import { getDatasetFabrics } from 'wherehows-web/mirage/helpers/dataset-fabrics'; +import { getDatasetHealth } from 'wherehows-web/mirage/helpers/dataset-health'; export default function(this: IMirageServer) { this.get('/config', getConfig); @@ -57,6 +58,8 @@ export default function(this: IMirageServer) { this.get('/datasets/:dataset_id/fabrics', getDatasetFabrics); + this.get('/datasets/:dataset_id/health', getDatasetHealth); + this.namespace = '/api/v1'; this.get('/datasets/:dataset_id', getDataset); diff --git a/wherehows-web/mirage/helpers/dataset-health.ts b/wherehows-web/mirage/helpers/dataset-health.ts new file mode 100644 index 0000000000..4a4ab53908 --- /dev/null +++ b/wherehows-web/mirage/helpers/dataset-health.ts @@ -0,0 +1,9 @@ +import { IFunctionRouteHandler } from 'wherehows-web/typings/ember-cli-mirage'; + +export const getDatasetHealth = function(this: IFunctionRouteHandler, { health }: any, request: any) { + const { dataset_id } = request.params; + + return { + health: health.filter((score: any) => score.refDatasetUrn === dataset_id)[0] || null + }; +}; diff --git a/wherehows-web/tests/integration/components/datasets/containers/dataset-health-test.js b/wherehows-web/tests/integration/components/datasets/containers/dataset-health-test.js index 4222cf34f3..f796f8f8d6 100644 --- a/wherehows-web/tests/integration/components/datasets/containers/dataset-health-test.js +++ b/wherehows-web/tests/integration/components/datasets/containers/dataset-health-test.js @@ -1,13 +1,20 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; +import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +import { waitUntil, find } from 'ember-native-dom-helpers'; +import { urn } from 'wherehows-web/mirage/fixtures/urn'; +import sinon from 'sinon'; -module('Integration | Component | datasets/containers/dataset-health', function(hooks) { - setupRenderingTest(hooks); - // TODO: More meaningful tests as we continue with development - test('it renders', async function(assert) { - await render(hbs`{{datasets/containers/dataset-health}}`); - assert.ok(this.element, 'Renders without errors'); - }); +moduleForComponent( + 'datasets/containers/dataset-health', + 'Integration | Component | datasets/containers/dataset-health', + { + integration: true + } +); + +test('it renders', async function(assert) { + this.set('urn', urn); + this.render(hbs`{{datasets/containers/dataset-health urn=urn}}`); + + assert.ok(find('.dataset-health__score-table'), 'renders the health table component'); });