From 445a2db4a6fc247fd524e2689557426ef59a73e9 Mon Sep 17 00:00:00 2001 From: Yves Yuen Date: Mon, 19 Mar 2018 16:53:19 -0700 Subject: [PATCH] [TE] upgraded all tests syntax What's new: updating the old moduleFor syntax to the newer syntax (used in Ember 3.0) as proposed in emberjs/rfcs#232 Tests: All tests still passing 268/268 --- .../tests/acceptance/edit-alert-test.js | 100 ++++---- .../tests/acceptance/example-test.js | 18 -- .../tests/acceptance/rootcause-test.js | 228 +++++++++--------- .../helpers/calculate-direction-test.js | 40 +-- .../components/anomaly-id/component-test.js | 100 ++++---- .../anomaly-container/component-test.js | 34 +-- .../metrics-container/component-test.js | 34 +-- .../filter-bar-input/component-test.js | 20 +- .../components/filter-bar/component-test.js | 45 ++-- .../filter-select/component-test.js | 20 +- .../rootcause-metrics/component-test.js | 50 ++-- .../rootcause-placeholder/component-test.js | 36 +-- .../components/stats-cards/component-test.js | 116 ++++----- .../components/te-navbar/component-test.js | 85 +++---- .../tests/unit/helpers/compute-color-test.js | 14 +- .../unit/helpers/compute-text-color-test.js | 14 +- .../tests/unit/helpers/format-number-test.js | 14 +- .../tests/unit/helpers/set-has-test.js | 27 +-- .../unit/pods/application/controller-test.js | 18 +- .../tests/unit/pods/home/controller-test.js | 18 +- .../tests/unit/pods/home/route-test.js | 14 +- .../tests/unit/pods/index/route-test.js | 16 +- .../tests/unit/pods/login/route-test.js | 16 +- .../pods/manage/alerts/controller-test.js | 18 +- .../unit/pods/manage/alerts/route-test.js | 16 +- .../tests/unit/pods/manage/route-test.js | 16 +- .../rca/details/metrics/controller-test.js | 20 +- .../pods/rca/details/metrics/route-test.js | 16 +- .../unit/pods/screenshot/controller-test.js | 18 +- .../tests/unit/pods/screenshot/route-test.js | 16 +- .../create-alert/controller-test.js | 18 +- .../self-serve/create-alert/route-test.js | 16 +- .../import-metric/controller-test.js | 18 +- .../tests/unit/pods/self-serve/route-test.js | 16 +- .../tests/unit/utils/anomaly-test.js | 16 +- .../tests/unit/utils/build-tooltip-test.js | 28 +-- .../tests/unit/utils/float-to-percent-test.js | 12 +- .../tests/unit/utils/translate-test.js | 24 +- 38 files changed, 673 insertions(+), 672 deletions(-) delete mode 100644 thirdeye/thirdeye-frontend/tests/acceptance/example-test.js diff --git a/thirdeye/thirdeye-frontend/tests/acceptance/edit-alert-test.js b/thirdeye/thirdeye-frontend/tests/acceptance/edit-alert-test.js index 46ab0613b87..37e72176c90 100644 --- a/thirdeye/thirdeye-frontend/tests/acceptance/edit-alert-test.js +++ b/thirdeye/thirdeye-frontend/tests/acceptance/edit-alert-test.js @@ -1,56 +1,60 @@ -import { test } from 'qunit'; -import moduleForAcceptance from 'thirdeye-frontend/tests/helpers/module-for-acceptance'; +import { module, test } from 'qunit'; +import { setupApplicationTest } from 'ember-qunit'; +import { visit, fillIn, click, currentURL } from '@ember/test-helpers'; +import $ from 'jquery'; -moduleForAcceptance('Acceptance | edit alert'); +module('Acceptance | edit alert', function(hooks) { + setupApplicationTest(hooks); -const ALERT_NAME_INPUT = '#anomaly-form-function-name'; -const SUBSCRIPTION_GROUP = '#anomaly-form-app-name'; -const STATUS = '.te-toggle--form span'; -const STATUS_RESULT = '.te-search-results__tag'; -const EDIT_LINK = '/manage/alert/edit'; -const STATUS_TOGGLER = '.x-toggle-btn'; -const SUBMIT_BUTTON = '.te-button--submit'; -const NEW_FUNC_NAME = 'test_function_2'; -const NEW_FUNC_RESULT = '.te-search-results__title-name'; + const ALERT_NAME_INPUT = '#anomaly-form-function-name'; + const SUBSCRIPTION_GROUP = '#anomaly-form-app-name'; + const STATUS = '.te-toggle--form span'; + const STATUS_RESULT = '.te-search-results__tag'; + const EDIT_LINK = '/manage/alert/edit'; + const STATUS_TOGGLER = '.x-toggle-btn'; + const SUBMIT_BUTTON = '.te-button--submit'; + const NEW_FUNC_NAME = 'test_function_2'; + const NEW_FUNC_RESULT = '.te-search-results__title-name'; -test(`visiting ${EDIT_LINK} and checking that fields render correctly and edit is successful`, async (assert) => { - const alert = server.create('alert'); - await visit(`/manage/alert/${alert.id}/edit`); + test(`visiting ${EDIT_LINK} and checking that fields render correctly and edit is successful`, async (assert) => { + const alert = server.create('alert'); + await visit(`/manage/alert/${alert.id}/edit`); - assert.equal( - currentURL(), - '/manage/alert/1/edit', - 'correctly redirects to edit alerts page' - ); - assert.equal( - find(ALERT_NAME_INPUT).get(0).value, - 'test_function_1', - 'alert name is correct'); - assert.equal( - find(SUBSCRIPTION_GROUP).get(0).innerText, - 'beauty-and-the-beast', - 'subscription group name is correct'); - assert.equal( - find(STATUS).get(0).innerText, - 'Active', - 'alert status is correct'); + assert.equal( + currentURL(), + '/manage/alert/1/edit', + 'correctly redirects to edit alerts page' + ); + assert.equal( + $(ALERT_NAME_INPUT).get(0).value, + 'test_function_1', + 'alert name is correct'); + assert.equal( + $(SUBSCRIPTION_GROUP).get(0).innerText, + 'beauty-and-the-beast', + 'subscription group name is correct'); + assert.equal( + $(STATUS).get(0).innerText, + 'Active', + 'alert status is correct'); - await fillIn(ALERT_NAME_INPUT, NEW_FUNC_NAME); - await click(STATUS_TOGGLER); - await click(SUBMIT_BUTTON); + await fillIn(ALERT_NAME_INPUT, NEW_FUNC_NAME); + await click(STATUS_TOGGLER); + await click(SUBMIT_BUTTON); - assert.equal( - currentURL(), - '/manage/alerts', - 'correctly redirects to manage alerts page after edit' - ); + assert.equal( + currentURL(), + '/manage/alerts', + 'correctly redirects to manage alerts page after edit' + ); - assert.equal( - find(`${NEW_FUNC_RESULT}[title='${NEW_FUNC_NAME}']`).get(0).innerText, - NEW_FUNC_NAME, - 'after edit, alert name is saved correctly'); - assert.equal( - find(STATUS_RESULT).get(0).innerText, - 'Inactive', - 'after edit, alert status is saved correctly'); + assert.equal( + $(`${NEW_FUNC_RESULT}[title='${NEW_FUNC_NAME}']`).get(0).innerText, + NEW_FUNC_NAME, + 'after edit, alert name is saved correctly'); + assert.equal( + $(STATUS_RESULT).get(0).innerText, + 'Inactive', + 'after edit, alert status is saved correctly'); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/acceptance/example-test.js b/thirdeye/thirdeye-frontend/tests/acceptance/example-test.js deleted file mode 100644 index 444b8eaf703..00000000000 --- a/thirdeye/thirdeye-frontend/tests/acceptance/example-test.js +++ /dev/null @@ -1,18 +0,0 @@ -// TODO: [THIRDEYE-1796] Fix failing tests -// import { test } from 'qunit'; -// import moduleForAcceptance from 'thirdeye-frontend/tests/helpers/module-for-acceptance'; -// import { faker } from 'ember-cli-mirage'; - -// moduleForAcceptance('Acceptance | example'); - -// test('visiting /example', (assert) =>{ -// server.createList('anomaly', 1) -// const id = faker.random.number(); - -// visit(`/example/${id}`); - -// andThen(() => { -// assert.equal(currentURL(), `/example/${id}`); -// assert.ok(find('.anomaly-graph').length, 'should see the graph component'); -// }); -// }); diff --git a/thirdeye/thirdeye-frontend/tests/acceptance/rootcause-test.js b/thirdeye/thirdeye-frontend/tests/acceptance/rootcause-test.js index 5b144b2214c..39890a3f418 100644 --- a/thirdeye/thirdeye-frontend/tests/acceptance/rootcause-test.js +++ b/thirdeye/thirdeye-frontend/tests/acceptance/rootcause-test.js @@ -1,5 +1,7 @@ -import { test } from 'qunit'; -import moduleForAcceptance from 'thirdeye-frontend/tests/helpers/module-for-acceptance'; +import { module, test } from 'qunit'; +import { setupApplicationTest } from 'ember-qunit'; +import { visit, fillIn, click, currentURL } from '@ember/test-helpers'; +import $ from 'jquery'; const PLACEHOLDER = '.rootcause-placeholder'; const TABS = '.rootcause-tabs'; @@ -22,135 +24,137 @@ const EVENTS_FILTER_BAR = '.filter-bar'; const EVENTS_TABLE = '.events-table'; const RCA_TOGGLE = '.rootcause-to-legacy-toggle'; -moduleForAcceptance('Acceptance | rootcause'); - -test('empty state of rootcause page should have a placeholder and no tabs', async (assert) => { - await visit('/rootcause'); - - assert.equal( - currentURL(), - '/rootcause', - 'link is correct'); - assert.ok( - find(PLACEHOLDER).get(0), - 'placeholder exists' - ); - assert.notOk( - find(TABS).get(0), - 'tabs do not exist' - ); -}); +module('Acceptance | rootcause', async function(hooks) { + setupApplicationTest(hooks); -test(`visiting /rootcause with only a metric provided should have correct metric name selected by default and displayed - in the legend`, async assert => { - await visit('/rootcause?metricId=1'); + test('empty state of rootcause page should have a placeholder and no tabs', async (assert) => { + await visit('/rootcause'); assert.equal( currentURL(), - '/rootcause?metricId=1', + '/rootcause', 'link is correct'); - assert.equal( - find(LABEL).get(0).innerText, - 'pageViews', - 'metric label is correct' + assert.ok( + $(PLACEHOLDER).get(0), + 'placeholder exists' ); - assert.equal( - find(SELECTED_METRIC).get(0).innerText, - 'pageViews', - 'selected metric is correct' + assert.notOk( + $(TABS).get(0), + 'tabs do not exist' ); }); -test('visiting rootcause page and making changes to the title and comment should create a session with saved changes', - async assert => { - const header = 'My Session'; - const comment = 'Cause of anomaly is unknown'; - - await visit('/rootcause'); - await fillIn(HEADER, header); - await fillIn(COMMENT_TEXT, comment); - await click(SAVE_BTN); + test(`visiting /rootcause with only a metric provided should have correct metric name selected by default and displayed + in the legend`, async assert => { + await visit('/rootcause?metricId=1'); + + assert.equal( + currentURL(), + '/rootcause?metricId=1', + 'link is correct'); + assert.equal( + $(LABEL).get(0).innerText, + 'pageViews', + 'metric label is correct' + ); + assert.equal( + $(SELECTED_METRIC).get(0).innerText, + 'pageViews', + 'selected metric is correct' + ); + }); + + test('visiting rootcause page and making changes to the title and comment should create a session with saved changes', + async assert => { + const header = 'My Session'; + const comment = 'Cause of anomaly is unknown'; + + await visit('/rootcause'); + await fillIn(HEADER, header); + await fillIn(COMMENT_TEXT, comment); + await click(SAVE_BTN); + + assert.equal( + currentURL(), + '/rootcause?sessionId=1', + 'link is correct'); + assert.equal( + $(HEADER).get(0).value, + 'My Session', + 'session name is correct'); + assert.ok( + $(LAST_SAVED).get(0).innerText.includes('Last saved by rootcauseuser'), + 'last saved information is correct'); + assert.equal( + $(COMMENT_TEXT).get(1).value, + 'Cause of anomaly is unknown', + 'comments are correct'); + assert.equal( + $(BASELINE).get(0).innerText, + 'WoW', + 'default baseline is correct'); + }); + + test('visiting rootcause page with an anomaly should have correct anomaly information', async assert => { + await visit('/rootcause?anomalyId=1'); + await click(EXPAND_ANOMALY_BTN); assert.equal( currentURL(), - '/rootcause?sessionId=1', + '/rootcause?anomalyId=1', 'link is correct'); assert.equal( - find(HEADER).get(0).value, - 'My Session', - 'session name is correct'); - assert.ok( - find(LAST_SAVED).get(0).innerText.includes('Last saved by rootcauseuser'), - 'last saved information is correct'); + $(ANOMALY_TITLE).get(0).innerText, + 'Anomaly #1 anomaly_label', + 'anomaly title is correct' + ); assert.equal( - find(COMMENT_TEXT).get(1).value, - 'Cause of anomaly is unknown', - 'comments are correct'); + $(ANOMALY_VALUE).get(0).innerText, + 'pageViews', + 'metric name in anomaly card is correct' + ); assert.equal( - find(BASELINE).get(0).innerText, - 'WoW', - 'default baseline is correct'); + $(ANOMALY_STATUS).get(0).innerText.trim(), + 'No (False Alarm)', + 'anomaly status is correct'); }); -test('visiting rootcause page with an anomaly should have correct anomaly information', async assert => { - await visit('/rootcause?anomalyId=1'); - await click(EXPAND_ANOMALY_BTN); - - assert.equal( - currentURL(), - '/rootcause?anomalyId=1', - 'link is correct'); - assert.equal( - find(ANOMALY_TITLE).get(0).innerText, - 'Anomaly #1 anomaly_label', - 'anomaly title is correct' - ); - assert.equal( - find(ANOMALY_VALUE).get(0).innerText, - 'pageViews', - 'metric name in anomaly card is correct' - ); - assert.equal( - find(ANOMALY_STATUS).get(0).innerText.trim(), - 'No (False Alarm)', - 'anomaly status is correct'); -}); + test('Metrics, Dimensions, and Events tabs exist and should have correct information', async (assert) => { + await visit('/rootcause?metricId=1'); -test('Metrics, Dimensions, and Events tabs exist and should have correct information', async assert => { - await visit('/rootcause?metricId=1'); - - assert.equal( - find(`${TABS} a`).get(0).innerText, - 'Metrics', - 'default tab is correct'); - assert.ok( - find(METRICS_TABLE).get(0), - 'metrics table exist'); - - // Click on Dimensions tab - await click(find(`${TABS} a`).get(1)); - - assert.ok( - find(HEATMAP_DROPDOWN).get(0), - 'heatmap dropdown exists'); - assert.equal( - find(SELECTED_HEATMAP_MODE).get(4).innerText, - 'Change in Contribution', - 'default heatmap mode is correct'); - - // Click on Events tab - await click(find(`${TABS} a`).get(2)); - assert.ok( - find(EVENTS_FILTER_BAR).get(0), - 'filter bar exists in events tab'); - assert.ok( - find(EVENTS_TABLE).get(0), - 'events table exists in events tab'); -}); + assert.equal( + $(`${TABS} a`).get(0).innerText, + 'Metrics', + 'default tab is correct'); + assert.ok( + $(METRICS_TABLE).get(0), + 'metrics table exist'); + + // Click on Dimensions tab + await click($(`${TABS} a`).get(1)); + + assert.ok( + $(HEATMAP_DROPDOWN).get(0), + 'heatmap dropdown exists'); + assert.equal( + $(SELECTED_HEATMAP_MODE).get(4).innerText, + 'Change in Contribution', + 'default heatmap mode is correct'); -test('links to legacy rca should work', async (assert) => { - await visit('/rootcause'); - await click(RCA_TOGGLE); + // Click on Events tab + await click($(`${TABS} a`).get(2)); + assert.ok( + $(EVENTS_FILTER_BAR).get(0), + 'filter bar exists in events tab'); + assert.ok( + $(EVENTS_TABLE).get(0), + 'events table exists in events tab'); + }); - assert.ok(currentURL().includes('rca'), currentURL()); + test('links to legacy rca should work', async (assert) => { + await visit('/rootcause'); + await click(RCA_TOGGLE); + + assert.ok(currentURL().includes('rca'), currentURL()); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/integration/helpers/calculate-direction-test.js b/thirdeye/thirdeye-frontend/tests/integration/helpers/calculate-direction-test.js index e1afc1e621e..7f6e9b0893b 100644 --- a/thirdeye/thirdeye-frontend/tests/integration/helpers/calculate-direction-test.js +++ b/thirdeye/thirdeye-frontend/tests/integration/helpers/calculate-direction-test.js @@ -1,25 +1,25 @@ - -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -moduleForComponent('calculate-direction', 'helper:calculate-direction', { - integration: true -}); +module('helper:calculate-direction', function(hooks) { + setupRenderingTest(hooks); -test('when input is positive, calculate direction should return "up"', function(assert) { - this.set('inputValue', '1234'); - this.render(hbs`{{calculate-direction inputValue}}`); - assert.equal( - this.$().text().trim(), - 'up', - 'calculate-direction returns "up" correctly when input is positive'); -}); + test('when input is positive, calculate direction should return "up"', async function(assert) { + this.set('inputValue', '1234'); + await render(hbs`{{calculate-direction inputValue}}`); + assert.equal( + this.$().text().trim(), + 'up', + 'calculate-direction returns "up" correctly when input is positive'); + }); -test('when input is negative, calculate direction should return "down"', function(assert) { - this.set('inputValue', '-1000'); - this.render(hbs`{{calculate-direction inputValue}}`); - assert.equal(this.$().text().trim(), - 'down', - 'calculate-direction returns "down" correctly when input is negative'); + test('when input is negative, calculate direction should return "down"', async function(assert) { + this.set('inputValue', '-1000'); + await render(hbs`{{calculate-direction inputValue}}`); + assert.equal(this.$().text().trim(), + 'down', + 'calculate-direction returns "down" correctly when input is negative'); + }); }); - diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/anomaly-id/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/anomaly-id/component-test.js index 717c35ea350..2916e7e7780 100644 --- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/anomaly-id/component-test.js +++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/anomaly-id/component-test.js @@ -1,53 +1,55 @@ -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import floatToPercent from 'thirdeye-frontend/utils/float-to-percent'; -moduleForComponent('anomaly-id', 'Integration | Component | anomaly id', { - integration: true -}); - -const idSelector = '.anomaly-id__id'; -const nameSelector = '.anomaly-id__name'; -const currentValueSelector = '.anomaly-id__total'; -const changeRateSelector = '.anomaly-id__percent'; -const anomalyId = 20475; -const anomalyCurrentValue = 10; -const anomalyBaselineValue = 2; -const anomaly = { - anomalyIds: anomalyId, - current: anomalyCurrentValue, - baseline: anomalyBaselineValue, - anomalyFunctionName: 'some-function-name' -}; -const calculateChangeRate = (current, baseline) => { - return (baseline === 0) ? 0 : floatToPercent((current - baseline) / baseline); -}; - -// Test for proper rendering of all Anomaly ID Block data -test('Anomaly ID block: all meta properties render', function(assert) { - let changeRate = calculateChangeRate(anomaly.current, anomaly.baseline); - - // this.set('anomaly', anomaly); - // this.set('anomalyChangeRate', changeRate); - this.setProperties({ 'anomaly': anomaly, 'anomalyChangeRate': changeRate }); - this.render(hbs`{{anomaly-id anomaly=anomaly}}`); - - assert.equal(this.$(idSelector).text().trim(), anomalyId, 'The anomaly id is correct and renders'); - assert.equal(this.$(nameSelector).text().trim(), anomaly.anomalyFunctionName, 'The anomaly name is correct and renders'); - assert.equal(this.$(currentValueSelector).text().trim(), anomaly.current, 'The current value is correct and renders'); - assert.equal(this.$(changeRateSelector).text().trim(), '(' + changeRate + '%)', 'The change rate is correct and renders'); -}); - -// Now test for proper handling of a zero-value for baseline. In this case, percent change -// cannot be calculated - we should return and display '0' -test('Anomaly ID block: render correct change rate for zero baseline', function(assert) { - anomaly.baseline = 0; - let changeRate = calculateChangeRate(anomaly.current, anomaly.baseline); - - // this.set('anomaly', anomaly); - // this.set('anomalyChangeRate', changeRate); - this.setProperties({ 'anomaly': anomaly, 'anomalyChangeRate': changeRate }); - this.render(hbs`{{anomaly-id anomaly=anomaly}}`); - - assert.equal(this.$(changeRateSelector).text().trim(), '(' + changeRate + '%)', 'The change rate handles a zero baseline correctly'); +module('Integration | Component | anomaly id', function(hooks) { + setupRenderingTest(hooks); + + const idSelector = '.anomaly-id__id'; + const nameSelector = '.anomaly-id__name'; + const currentValueSelector = '.anomaly-id__total'; + const changeRateSelector = '.anomaly-id__percent'; + const anomalyId = 20475; + const anomalyCurrentValue = 10; + const anomalyBaselineValue = 2; + const anomaly = { + anomalyIds: anomalyId, + current: anomalyCurrentValue, + baseline: anomalyBaselineValue, + anomalyFunctionName: 'some-function-name' + }; + const calculateChangeRate = (current, baseline) => { + return (baseline === 0) ? 0 : floatToPercent((current - baseline) / baseline); + }; + + // Test for proper rendering of all Anomaly ID Block data + test('Anomaly ID block: all meta properties render', async function(assert) { + let changeRate = calculateChangeRate(anomaly.current, anomaly.baseline); + + // this.set('anomaly', anomaly); + // this.set('anomalyChangeRate', changeRate); + this.setProperties({ 'anomaly': anomaly, 'anomalyChangeRate': changeRate }); + await render(hbs`{{anomaly-id anomaly=anomaly}}`); + + assert.equal(this.$(idSelector).text().trim(), anomalyId, 'The anomaly id is correct and renders'); + assert.equal(this.$(nameSelector).text().trim(), anomaly.anomalyFunctionName, 'The anomaly name is correct and renders'); + assert.equal(this.$(currentValueSelector).text().trim(), anomaly.current, 'The current value is correct and renders'); + assert.equal(this.$(changeRateSelector).text().trim(), '(' + changeRate + '%)', 'The change rate is correct and renders'); + }); + + // Now test for proper handling of a zero-value for baseline. In this case, percent change + // cannot be calculated - we should return and display '0' + test('Anomaly ID block: render correct change rate for zero baseline', async function(assert) { + anomaly.baseline = 0; + let changeRate = calculateChangeRate(anomaly.current, anomaly.baseline); + + // this.set('anomaly', anomaly); + // this.set('anomalyChangeRate', changeRate); + this.setProperties({ 'anomaly': anomaly, 'anomalyChangeRate': changeRate }); + await render(hbs`{{anomaly-id anomaly=anomaly}}`); + + assert.equal(this.$(changeRateSelector).text().trim(), '(' + changeRate + '%)', 'The change rate handles a zero baseline correctly'); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/containers/anomaly-container/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/containers/anomaly-container/component-test.js index f8c54db5d55..1e3d32b5450 100644 --- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/containers/anomaly-container/component-test.js +++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/containers/anomaly-container/component-test.js @@ -1,25 +1,27 @@ -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -moduleForComponent('containers/anomaly-container', 'Integration | Component | containers/anomaly container', { - integration: true -}); +module('Integration | Component | containers/anomaly container', function(hooks) { + setupRenderingTest(hooks); -test('it renders', function(assert) { + test('it renders', async function(assert) { - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.on('myAction', function(val) { ... }); + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); - this.render(hbs`{{containers/anomaly-container}}`); + await render(hbs`{{containers/anomaly-container}}`); - assert.equal(this.$().text().trim(), ''); + assert.equal(this.$().text().trim(), ''); - // Template block usage: - this.render(hbs` - {{#containers/anomaly-container}} - template block text - {{/containers/anomaly-container}} - `); + // Template block usage: + await render(hbs` + {{#containers/anomaly-container}} + template block text + {{/containers/anomaly-container}} + `); - assert.equal(this.$().text().trim(), 'template block text'); + assert.equal(this.$().text().trim(), 'template block text'); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/containers/metrics-container/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/containers/metrics-container/component-test.js index 17b613ef610..35f9267cde7 100644 --- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/containers/metrics-container/component-test.js +++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/containers/metrics-container/component-test.js @@ -1,25 +1,27 @@ -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -moduleForComponent('containers/metrics-container', 'Integration | Component | containers/metrics container', { - integration: true -}); +module('Integration | Component | containers/metrics container', function(hooks) { + setupRenderingTest(hooks); -test('it renders', function(assert) { + test('it renders', async function(assert) { - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.on('myAction', function(val) { ... }); + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); - this.render(hbs`{{containers/metrics-container}}`); + await render(hbs`{{containers/metrics-container}}`); - assert.equal(this.$().text().trim(), ''); + assert.equal(this.$().text().trim(), ''); - // Template block usage: - this.render(hbs` - {{#containers/metrics-container}} - template block text - {{/containers/metrics-container}} - `); + // Template block usage: + await render(hbs` + {{#containers/metrics-container}} + template block text + {{/containers/metrics-container}} + `); - assert.equal(this.$().text().trim(), 'template block text'); + assert.equal(this.$().text().trim(), 'template block text'); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-bar-input/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-bar-input/component-test.js index 5a52863a4e9..efbee3f9dd3 100644 --- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-bar-input/component-test.js +++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-bar-input/component-test.js @@ -1,16 +1,18 @@ -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -moduleForComponent('filter-bar-input', 'Integration | Component | filter bar input', { - integration: true -}); +module('Integration | Component | filter bar input', function(hooks) { + setupRenderingTest(hooks); -test('it renders', function(assert) { + test('it renders', async function(assert) { - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.on('myAction', function(val) { ... }); + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); - this.render(hbs`{{filter-bar-input}}`); + await render(hbs`{{filter-bar-input}}`); - assert.equal(this.$().text().trim(), ''); + assert.equal(this.$().text().trim(), ''); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-bar/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-bar/component-test.js index cbd56654e6a..e7a98361950 100644 --- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-bar/component-test.js +++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-bar/component-test.js @@ -1,30 +1,31 @@ -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import config from 'thirdeye-frontend/shared/filterBarConfig'; -moduleForComponent('filter-bar', 'Integration | Component | filter bar', { - integration: true -}); +module('Integration | Component | filter bar', function(hooks) { + setupRenderingTest(hooks); -test('it renders well', function(assert) { - const headers = config.map((category) => category.header); - this.setProperties({ - entities: {}, - config, - onFilterSelection: () => {} - }); + test('it renders well', async function(assert) { + const headers = config.map((category) => category.header); + this.setProperties({ + entities: {}, + config, + onFilterSelection: () => {} + }); - this.render(hbs` - {{filter-bar - entities=entities - onFilter=(action onFilterSelection) - config=config - }} - `); + await render(hbs` + {{filter-bar + entities=entities + onFilter=(action onFilterSelection) + config=config + }} + `); - const filterBarText = this.$().text().trim(); - headers.forEach((header) => { - assert.ok(filterBarText.includes(header), `filter bar should display ${header}`); + const filterBarText = this.$().text().trim(); + headers.forEach((header) => { + assert.ok(filterBarText.includes(header), `filter bar should display ${header}`); + }); }); }); - diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-select/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-select/component-test.js index 3ac116af030..a603d36708b 100644 --- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-select/component-test.js +++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/filter-select/component-test.js @@ -1,16 +1,18 @@ -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -moduleForComponent('filter-select', 'Integration | Component | filter select', { - integration: true -}); +module('Integration | Component | filter select', function(hooks) { + setupRenderingTest(hooks); -test('it renders', function(assert) { + test('it renders', async function(assert) { - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.on('myAction', function(val) { ... }); + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); - this.render(hbs`{{filter-select}}`); + await render(hbs`{{filter-select}}`); - assert.equal(this.$().text().trim(), ''); + assert.equal(this.$().text().trim(), ''); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-metrics/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-metrics/component-test.js index d3211338ca0..212529df34d 100644 --- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-metrics/component-test.js +++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-metrics/component-test.js @@ -1,30 +1,32 @@ -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -moduleForComponent('rootcause-metrics', 'Integration | Component | rootcause metrics', { - integration: true -}); +module('Integration | Component | rootcause metrics', function(hooks) { + setupRenderingTest(hooks); -test('it renders', function(assert) { - this.setProperties({ - entities: {}, - aggregates: {}, - scores: {}, - selectedUrns: {}, - onSelection: () => {} - }); + test('it renders', async function(assert) { + this.setProperties({ + entities: {}, + aggregates: {}, + scores: {}, + selectedUrns: {}, + onSelection: () => {} + }); - this.render(hbs` - {{rootcause-metrics - entities=entities - aggregates=aggregates - scores=scores - selectedUrns=selectedUrns - onSelection=(action onSelection) - }} - `); + await render(hbs` + {{rootcause-metrics + entities=entities + aggregates=aggregates + scores=scores + selectedUrns=selectedUrns + onSelection=(action onSelection) + }} + `); - const table = this.$('.rootcause-metrics'); - assert.ok(table.length, 'It should render properly'); - assert.ok(table.find('.table-header').length, 'It should have headers'); + const table = this.$('.rootcause-metrics'); + assert.ok(table.length, 'It should render properly'); + assert.ok(table.find('.table-header').length, 'It should have headers'); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-placeholder/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-placeholder/component-test.js index 4aad604def0..2d7014e59e8 100644 --- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-placeholder/component-test.js +++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-placeholder/component-test.js @@ -1,23 +1,25 @@ -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -moduleForComponent('rootcause-placeholder', 'Integration | Component | rootcause placeholder', { - integration: true -}); +module('Integration | Component | rootcause placeholder', function(hooks) { + setupRenderingTest(hooks); -test('it renders', function(assert) { - const testMessage = 'Hey There!'; - this.set('message', testMessage); + test('it renders', async function(assert) { + const testMessage = 'Hey There!'; + this.set('message', testMessage); - this.render(hbs` - {{rootcause-placeholder - message=message}} - `); - const message = this.$().find('p').text(); + await render(hbs` + {{rootcause-placeholder + message=message}} + `); + const message = this.$().find('p').text(); - assert.equal( - message, - testMessage, - 'Message should be displayed correctly.' - ); + assert.equal( + message, + testMessage, + 'Message should be displayed correctly.' + ); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/stats-cards/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/stats-cards/component-test.js index 513d07fadb2..a58d4bbf5d9 100644 --- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/stats-cards/component-test.js +++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/stats-cards/component-test.js @@ -1,67 +1,67 @@ -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -moduleForComponent('stats-cards', 'Integration | Component | stats cards', { - integration: true -}); +module('Integration | Component | stats cards', function(hooks) { + setupRenderingTest(hooks); -const CARD = '.te-horizontal-cards__card'; + const CARD = '.te-horizontal-cards__card'; -test('it renders', function(assert) { - const stats = [ - ['Number of anomalies', 'total anomalies', 10], - ['Response Rate', 'description of response', 0.9], - ['Precision', 'description of precision', 1] - ]; - this.setProperties({ stats }); + test('it renders', async function(assert) { + const stats = [ + ['Number of anomalies', 'total anomalies', 10], + ['Response Rate', 'description of response', 0.9], + ['Precision', 'description of precision', 1] + ]; + this.setProperties({ stats }); - this.render( - hbs`{{stats-cards - stats=stats}}` - ); - const $title = this.$(`${CARD}-title`); - const $description = this.$(`${CARD}-text`); - const $number = this.$(`${CARD}-number`); + await render(hbs`{{stats-cards + stats=stats}}`); + const $title = this.$(`${CARD}-title`); + const $description = this.$(`${CARD}-text`); + const $number = this.$(`${CARD}-number`); - // Testing titles of all cards - assert.equal( - $title.get(0).innerText, - stats[0][0], - 'title of 1st card is correct'); - assert.equal( - $title.get(1).innerText, - stats[1][0], - 'title of 2nd card is correct'); - assert.equal( - $title.get(2).innerText, - stats[2][0], - 'title of 3rd card is correct'); + // Testing titles of all cards + assert.equal( + $title.get(0).innerText, + stats[0][0], + 'title of 1st card is correct'); + assert.equal( + $title.get(1).innerText, + stats[1][0], + 'title of 2nd card is correct'); + assert.equal( + $title.get(2).innerText, + stats[2][0], + 'title of 3rd card is correct'); - // Testing descriptions of all cards - assert.equal( - $description.get(0).innerText, - stats[0][1], - 'description of 1st card is correct'); - assert.equal( - $description.get(1).innerText, - stats[1][1], - 'description of 2nd card is correct'); - assert.equal( - $description.get(2).innerText, - stats[2][1], - 'description of 3rd card is correct'); + // Testing descriptions of all cards + assert.equal( + $description.get(0).innerText, + stats[0][1], + 'description of 1st card is correct'); + assert.equal( + $description.get(1).innerText, + stats[1][1], + 'description of 2nd card is correct'); + assert.equal( + $description.get(2).innerText, + stats[2][1], + 'description of 3rd card is correct'); - // Testing values of all cards - assert.equal( - $number.get(0).innerText, - stats[0][2], - 'value of 1st card is correct'); - assert.equal( - $number.get(1).innerText, - stats[1][2], - 'value of 2nd card is correct'); - assert.equal( - $number.get(2).innerText, - stats[2][2], - 'value of 3rd card is correct'); + // Testing values of all cards + assert.equal( + $number.get(0).innerText, + stats[0][2], + 'value of 1st card is correct'); + assert.equal( + $number.get(1).innerText, + stats[1][2], + 'value of 2nd card is correct'); + assert.equal( + $number.get(2).innerText, + stats[2][2], + 'value of 3rd card is correct'); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/te-navbar/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/te-navbar/component-test.js index 7821c6ad690..66d28cb3e1e 100644 --- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/te-navbar/component-test.js +++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/te-navbar/component-test.js @@ -1,49 +1,50 @@ -import { moduleForComponent, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -moduleForComponent('te-navbar', 'Integration | Component | te navbar', { - integration: true -}); +module('Integration | Component | te navbar', function(hooks) { + setupRenderingTest(hooks); -const testItems = [ - { - className: 'home', - link: 'index', - title: 'Home' - }, - { - className: 'linkedin', - link: 'http://www.linkedin.com/', - isCustomLink: true, - title: 'LI Home' - } -]; + const testItems = [ + { + className: 'home', + link: 'index', + title: 'Home' + }, + { + className: 'linkedin', + link: 'http://www.linkedin.com/', + isCustomLink: true, + title: 'LI Home' + } + ]; -const navSelector = 'nav.te-nav'; -const navListSelector = 'li.te-nav__item'; -const globalNavClass = 'te-nav--global'; -const subNavClass = 'te-nav--sub'; -const logoSelector = '.te-nav__logo'; -const homeLinkAnchorSelector = '.te-nav__item--home a'; -const extLinkAnchorSelecotr = '.te-nav__item--linkedin a'; + const navSelector = 'nav.te-nav'; + const navListSelector = 'li.te-nav__item'; + const globalNavClass = 'te-nav--global'; + const subNavClass = 'te-nav--sub'; + const logoSelector = '.te-nav__logo'; + const homeLinkAnchorSelector = '.te-nav__item--home a'; + const extLinkAnchorSelecotr = '.te-nav__item--linkedin a'; -// Test for proper rendering of global navigation bar component -test('Nav bar renders new items of type = global', function(assert) { - this.setProperties({ 'testItems': testItems }); - this.render(hbs`{{te-navbar navItems=testItems isGlobalNav=true navClass='te-nav--global'}}`); - assert.equal(this.$(navListSelector).length, 2, 'Global nav renders ' + testItems.length + ' items'); - assert.equal(this.$(navSelector)[0].classList[1], globalNavClass, 'Global nav renders with correct class name'); - assert.equal(this.$(logoSelector).length, 1, 'Global nav renders logo'); - assert.equal(this.$(homeLinkAnchorSelector).text().trim(), 'Home', 'Nav renders link text'); - assert.equal(this.$(extLinkAnchorSelecotr)[0].href, testItems[1].link, 'Nav renders external link'); -}); + // Test for proper rendering of global navigation bar component + test('Nav bar renders new items of type = global', async function(assert) { + this.setProperties({ 'testItems': testItems }); + await render(hbs`{{te-navbar navItems=testItems isGlobalNav=true navClass='te-nav--global'}}`); + assert.equal(this.$(navListSelector).length, 2, 'Global nav renders ' + testItems.length + ' items'); + assert.equal(this.$(navSelector)[0].classList[1], globalNavClass, 'Global nav renders with correct class name'); + assert.equal(this.$(logoSelector).length, 1, 'Global nav renders logo'); + assert.equal(this.$(homeLinkAnchorSelector).text().trim(), 'Home', 'Nav renders link text'); + assert.equal(this.$(extLinkAnchorSelecotr)[0].href, testItems[1].link, 'Nav renders external link'); + }); -// Test for proper rendering of sub navigation bar component -test('Nav bar renders new items of type = subnav', function(assert) { - this.setProperties({ 'testItems': testItems }); - this.render(hbs`{{te-navbar navItems=testItems navClass='te-nav--sub'}}`); - assert.equal(this.$(navListSelector).length, 2, 'Sub nav renders ' + testItems.length + ' items'); - assert.equal(this.$(navSelector)[0].classList[1], subNavClass, 'Sub nav renders with correct class name'); - assert.equal(this.$(logoSelector).length, 0, 'Sub nav does not render logo'); + // Test for proper rendering of sub navigation bar component + test('Nav bar renders new items of type = subnav', async function(assert) { + this.setProperties({ 'testItems': testItems }); + await render(hbs`{{te-navbar navItems=testItems navClass='te-nav--sub'}}`); + assert.equal(this.$(navListSelector).length, 2, 'Sub nav renders ' + testItems.length + ' items'); + assert.equal(this.$(navSelector)[0].classList[1], subNavClass, 'Sub nav renders with correct class name'); + assert.equal(this.$(logoSelector).length, 0, 'Sub nav does not render logo'); + }); }); - diff --git a/thirdeye/thirdeye-frontend/tests/unit/helpers/compute-color-test.js b/thirdeye/thirdeye-frontend/tests/unit/helpers/compute-color-test.js index 7a5718e8404..4065af23c5d 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/helpers/compute-color-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/helpers/compute-color-test.js @@ -1,12 +1,10 @@ - import { computeColor } from 'thirdeye-frontend/helpers/compute-color'; import { module, test } from 'qunit'; -module('Unit | Helper | compute color'); - -// Replace this with your real tests. -test('it works', function(assert) { - let result = computeColor([42]); - assert.ok(result); +module('Unit | Helper | compute color', function() { + // Replace this with your real tests. + test('it works', function(assert) { + let result = computeColor([42]); + assert.ok(result); + }); }); - diff --git a/thirdeye/thirdeye-frontend/tests/unit/helpers/compute-text-color-test.js b/thirdeye/thirdeye-frontend/tests/unit/helpers/compute-text-color-test.js index ab962f44e76..8b04c803cab 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/helpers/compute-text-color-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/helpers/compute-text-color-test.js @@ -1,12 +1,10 @@ - import { computeTextColor } from 'thirdeye-frontend/helpers/compute-text-color'; import { module, test } from 'qunit'; -module('Unit | Helper | compute text color'); - -// Replace this with your real tests. -test('it works', function(assert) { - let result = computeTextColor([42]); - assert.ok(result); +module('Unit | Helper | compute text color', function() { + // Replace this with your real tests. + test('it works', function(assert) { + let result = computeTextColor([42]); + assert.ok(result); + }); }); - diff --git a/thirdeye/thirdeye-frontend/tests/unit/helpers/format-number-test.js b/thirdeye/thirdeye-frontend/tests/unit/helpers/format-number-test.js index a874d0cbf89..53a2c8969c3 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/helpers/format-number-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/helpers/format-number-test.js @@ -1,12 +1,10 @@ - import { formatNumber } from 'thirdeye-frontend/helpers/format-number'; import { module, test } from 'qunit'; -module('Unit | Helper | format number'); - -// Replace this with your real tests. -test('it works', function(assert) { - let result = formatNumber([42]); - assert.ok(result); +module('Unit | Helper | format number', function() { + // Replace this with your real tests. + test('it works', function(assert) { + let result = formatNumber([42]); + assert.ok(result); + }); }); - diff --git a/thirdeye/thirdeye-frontend/tests/unit/helpers/set-has-test.js b/thirdeye/thirdeye-frontend/tests/unit/helpers/set-has-test.js index 4fdd68e95bf..d9d2954a81f 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/helpers/set-has-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/helpers/set-has-test.js @@ -1,21 +1,20 @@ - import { setHas } from 'thirdeye-frontend/helpers/set-has'; import { module, test } from 'qunit'; -module('Unit | Helper | set has'); - -const testCases = ['alex', 'yves', 'thao']; -const testSet = new Set(testCases); +module('Unit | Helper | set has', function() { + const testCases = ['alex', 'yves', 'thao']; + const testSet = new Set(testCases); -test('it works', function(assert) { - const result = setHas([testSet, 'alex']); - assert.ok(result); -}); + test('it works', function(assert) { + const result = setHas([testSet, 'alex']); + assert.ok(result); + }); -test('it rejects', function(assert) { - let result = setHas([testSet, 'Santa Claus']); - assert.notOk(result); + test('it rejects', function(assert) { + let result = setHas([testSet, 'Santa Claus']); + assert.notOk(result); - result = setHas([null, 'yves']); - assert.notOk(result, 'passed argument must be a set'); + result = setHas([null, 'yves']); + assert.notOk(result, 'passed argument must be a set'); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/application/controller-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/application/controller-test.js index d8d2be31133..93d19cebe1c 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/application/controller-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/application/controller-test.js @@ -1,12 +1,12 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('controller:application', 'Unit | Controller | application', { - // Specify the other units that are required for this test. - needs: ['service:session'] -}); +module('Unit | Controller | application', function(hooks) { + setupTest(hooks); -// Replace this with your real tests. -test('it exists', function(assert) { - let controller = this.subject(); - assert.ok(controller); + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:application'); + assert.ok(controller); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/home/controller-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/home/controller-test.js index 6087109a295..452dd25c0e2 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/home/controller-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/home/controller-test.js @@ -1,12 +1,12 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('controller:home', 'Unit | Controller | home', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); +module('Unit | Controller | home', function(hooks) { + setupTest(hooks); -// Replace this with your real tests. -test('it exists', function(assert) { - let controller = this.subject(); - assert.ok(controller); + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:home'); + assert.ok(controller); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/home/route-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/home/route-test.js index 1377bbb2701..cd12f0664a4 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/home/route-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/home/route-test.js @@ -1,9 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('route:home', 'Unit | Route | home', { -}); +module('Unit | Route | home', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let route = this.subject(); - assert.ok(route); + test('it exists', function(assert) { + let route = this.owner.lookup('route:home'); + assert.ok(route); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/index/route-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/index/route-test.js index 5d0f50da6ac..eaaac17bc2b 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/index/route-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/index/route-test.js @@ -1,11 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('route:index', 'Unit | Route | index', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); +module('Unit | Route | index', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let route = this.subject(); - assert.ok(route); + test('it exists', function(assert) { + let route = this.owner.lookup('route:index'); + assert.ok(route); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/login/route-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/login/route-test.js index 561f5e9e0c6..21569926e65 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/login/route-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/login/route-test.js @@ -1,11 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('route:login', 'Unit | Route | login', { - // Specify the other units that are required for this test. - needs: ['service:session'] -}); +module('Unit | Route | login', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let route = this.subject(); - assert.ok(route); + test('it exists', function(assert) { + let route = this.owner.lookup('route:login'); + assert.ok(route); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/manage/alerts/controller-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/manage/alerts/controller-test.js index 2903df2e5c3..d3a741f7910 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/manage/alerts/controller-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/manage/alerts/controller-test.js @@ -1,12 +1,12 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('controller:manage/alerts/index', 'Unit | Controller | manage/alerts/index', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); +module('Unit | Controller | manage/alerts/index', function(hooks) { + setupTest(hooks); -// Replace this with your real tests. -test('it exists', function(assert) { - let controller = this.subject(); - assert.ok(controller); + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:manage/alerts/index'); + assert.ok(controller); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/manage/alerts/route-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/manage/alerts/route-test.js index 79c37731ae1..ccede92be73 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/manage/alerts/route-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/manage/alerts/route-test.js @@ -1,11 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('route:manage/alerts', 'Unit | Route | manage/alerts', { - // Specify the other units that are required for this test. - needs: ['service:session'] -}); +module('Unit | Route | manage/alerts', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let route = this.subject(); - assert.ok(route); + test('it exists', function(assert) { + let route = this.owner.lookup('route:manage/alerts'); + assert.ok(route); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/manage/route-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/manage/route-test.js index f269ad8fb21..475dee6fa61 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/manage/route-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/manage/route-test.js @@ -1,11 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('route:manage', 'Unit | Route | manage', { - // Specify the other units that are required for this test. - needs: ['service:session'] -}); +module('Unit | Route | manage', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let route = this.subject(); - assert.ok(route); + test('it exists', function(assert) { + let route = this.owner.lookup('route:manage'); + assert.ok(route); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/rca/details/metrics/controller-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/rca/details/metrics/controller-test.js index c5f9dc30262..632bb764b17 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/rca/details/metrics/controller-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/rca/details/metrics/controller-test.js @@ -1,12 +1,12 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('controller:rca/details/metrics', 'Unit | Controller | rca/details/metrics', { - // Specify the other units that are required for this test. - needs: ['controller:rca/details'] -}); +module('Unit | Controller | rca/details/metrics', function(hooks) { + setupTest(hooks); -// Replace this with your real tests. -test('it exists', function(assert) { - let controller = this.subject(); - assert.ok(controller); -}); + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:rca/details/metrics'); + assert.ok(controller); + }); +}); \ No newline at end of file diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/rca/details/metrics/route-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/rca/details/metrics/route-test.js index c212d955037..12872e12a74 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/rca/details/metrics/route-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/rca/details/metrics/route-test.js @@ -1,11 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('route:rca/details/metrics', 'Unit | Route | rca/details/metrics', { - // Specify the other units that are required for this test. - needs: ['service:redux'] -}); +module('Unit | Route | rca/details/metrics', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let route = this.subject(); - assert.ok(route); + test('it exists', function(assert) { + let route = this.owner.lookup('route:rca/details/metrics'); + assert.ok(route); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/screenshot/controller-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/screenshot/controller-test.js index 11c333b76a3..eb94de594be 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/screenshot/controller-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/screenshot/controller-test.js @@ -1,12 +1,12 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('controller:screenshot', 'Unit | Controller | screenshot', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); +module('Unit | Controller | screenshot', function(hooks) { + setupTest(hooks); -// Replace this with your real tests. -test('it exists', function(assert) { - let controller = this.subject(); - assert.ok(controller); + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:screenshot'); + assert.ok(controller); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/screenshot/route-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/screenshot/route-test.js index 3f777d85ec4..200d4a6ea60 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/screenshot/route-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/screenshot/route-test.js @@ -1,11 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('route:screenshot', 'Unit | Route | screenshot', { - // Specify the other units that are required for this test. - needs: ['service:session'] -}); +module('Unit | Route | screenshot', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let route = this.subject(); - assert.ok(route); + test('it exists', function(assert) { + let route = this.owner.lookup('route:screenshot'); + assert.ok(route); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/create-alert/controller-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/create-alert/controller-test.js index 750e0c62552..fc7d6246a4f 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/create-alert/controller-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/create-alert/controller-test.js @@ -1,12 +1,12 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('controller:self-serve/create-alert', 'Unit | Controller | self serve/create alert', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); +module('Unit | Controller | self serve/create alert', function(hooks) { + setupTest(hooks); -// Replace this with your real tests. -test('it exists', function(assert) { - let controller = this.subject(); - assert.ok(controller); + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:self-serve/create-alert'); + assert.ok(controller); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/create-alert/route-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/create-alert/route-test.js index 86d9453c5a7..062e1c5c09a 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/create-alert/route-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/create-alert/route-test.js @@ -1,11 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('route:self-serve/create-alert', 'Unit | Route | self serve/create alert', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); +module('Unit | Route | self serve/create alert', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let route = this.subject(); - assert.ok(route); + test('it exists', function(assert) { + let route = this.owner.lookup('route:self-serve/create-alert'); + assert.ok(route); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/import-metric/controller-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/import-metric/controller-test.js index 5d0bf77570c..7cf651edb47 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/import-metric/controller-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/import-metric/controller-test.js @@ -1,12 +1,12 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('controller:self-serve/import-metric', 'Unit | Controller | self serve/import metric', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); +module('Unit | Controller | self serve/import metric', function(hooks) { + setupTest(hooks); -// Replace this with your real tests. -test('it exists', function(assert) { - let controller = this.subject(); - assert.ok(controller); + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:self-serve/import-metric'); + assert.ok(controller); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/route-test.js b/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/route-test.js index 479fecb0fa9..6fa05175499 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/route-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/pods/self-serve/route-test.js @@ -1,11 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('route:self-serve', 'Unit | Route | self serve', { - // Specify the other units that are required for this test. - needs: ['service:session'] -}); +module('Unit | Route | self serve', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let route = this.subject(); - assert.ok(route); + test('it exists', function(assert) { + let route = this.owner.lookup('route:self-serve'); + assert.ok(route); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/utils/anomaly-test.js b/thirdeye/thirdeye-frontend/tests/unit/utils/anomaly-test.js index 43386917544..587f8da6cba 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/utils/anomaly-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/utils/anomaly-test.js @@ -1,13 +1,13 @@ import { module, test } from 'qunit'; import { getFormatedDuration } from 'thirdeye-frontend/utils/anomaly'; -module('Unit | Utility | anomaly'); +module('Unit | Utility | anomaly', function() { + test('it returns a formated duration time correctly', function(assert) { + assert.equal(getFormatedDuration(1491804013000, 1491890413000), '1 day', 'it returns correct duration ok'); + }); -test('it returns a formated duration time correctly', function(assert) { - assert.equal(getFormatedDuration(1491804013000, 1491890413000), '1 day', 'it returns correct duration ok'); -}); - -test('it returns a non-zero duration time correctly', function(assert) { - //We want to display only non-zero duration values in our table - assert.equal(getFormatedDuration(1491804013000, 1491804013000), '', 'it filters out non-zero duration ok'); + test('it returns a non-zero duration time correctly', function(assert) { + //We want to display only non-zero duration values in our table + assert.equal(getFormatedDuration(1491804013000, 1491804013000), '', 'it filters out non-zero duration ok'); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/utils/build-tooltip-test.js b/thirdeye/thirdeye-frontend/tests/unit/utils/build-tooltip-test.js index 56553c5d521..f20d24f43e7 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/utils/build-tooltip-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/utils/build-tooltip-test.js @@ -1,20 +1,20 @@ import BuildTooltip from 'thirdeye-frontend/utils/build-tooltip'; import { module, test } from 'qunit'; -module('Unit | Utility | build-tooltip'); +module('Unit | Utility | build-tooltip', function() { + test('it builds', function(assert) { + const hash = { + entities: {}, + timeseries: {}, + hoverUrns: [''], + hoverTimeStamp: {} + }; -test('it builds', function(assert) { - const hash = { - entities: {}, - timeseries: {}, - hoverUrns: [''], - hoverTimeStamp: {} - }; + const tooltip = new BuildTooltip(); + const tooltipTemplate = tooltip.compute(hash).toString(); - const tooltip = new BuildTooltip(); - const tooltipTemplate = tooltip.compute(hash).toString(); - - assert.ok( - tooltipTemplate.includes('
'), - 'The tooltip should be created correctly'); + assert.ok( + tooltipTemplate.includes('
'), + 'The tooltip should be created correctly'); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/utils/float-to-percent-test.js b/thirdeye/thirdeye-frontend/tests/unit/utils/float-to-percent-test.js index 8f90588141e..b54be0b3493 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/utils/float-to-percent-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/utils/float-to-percent-test.js @@ -1,10 +1,10 @@ import floatToPercent from 'thirdeye-frontend/utils/float-to-percent'; import { module, test } from 'qunit'; -module('Unit | Utility | float to percent'); - -test('it works', function(assert) { - assert.equal(floatToPercent(0), 0.0); - assert.equal(floatToPercent(0.55), 55.0); - assert.equal(floatToPercent(0.123456), 12.35); +module('Unit | Utility | float to percent', function() { + test('it works', function(assert) { + assert.equal(floatToPercent(0), 0.0); + assert.equal(floatToPercent(0.55), 55.0); + assert.equal(floatToPercent(0.123456), 12.35); + }); }); diff --git a/thirdeye/thirdeye-frontend/tests/unit/utils/translate-test.js b/thirdeye/thirdeye-frontend/tests/unit/utils/translate-test.js index deaf037b815..e89742f3d26 100644 --- a/thirdeye/thirdeye-frontend/tests/unit/utils/translate-test.js +++ b/thirdeye/thirdeye-frontend/tests/unit/utils/translate-test.js @@ -1,17 +1,17 @@ import translate from 'thirdeye-frontend/utils/translate'; import { module, test } from 'qunit'; -module('Unit | Utility | translate'); +module('Unit | Utility | translate', function() { + test('translate function translates a value given a dictionary', function(assert) { + const dictionary = { + '1 hour': '1_HOURS', + '1 day': '1_DAYS', + '4 days': '4_DAYS' + }; -test('translate function translates a value given a dictionary', function(assert) { - const dictionary = { - '1 hour': '1_HOURS', - '1 day': '1_DAYS', - '4 days': '4_DAYS' - }; - - assert.equal(translate(dictionary, '1_DAYS'), '1 day'); - assert.equal(translate(dictionary, '1_HOURS'), '1 hour'); - assert.equal(translate(dictionary, '4_DAYS'), '4 days'); - assert.equal(translate(dictionary, 'Not in the dictionary'), undefined); + assert.equal(translate(dictionary, '1_DAYS'), '1 day'); + assert.equal(translate(dictionary, '1_HOURS'), '1 hour'); + assert.equal(translate(dictionary, '4_DAYS'), '4 days'); + assert.equal(translate(dictionary, 'Not in the dictionary'), undefined); + }); });