Skip to content

Commit

Permalink
[TE] upgraded all tests syntax
Browse files Browse the repository at this point in the history
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
  • Loading branch information
justYves authored and npawar committed Apr 6, 2018
1 parent b9c6008 commit 445a2db
Show file tree
Hide file tree
Showing 38 changed files with 673 additions and 672 deletions.
100 changes: 52 additions & 48 deletions 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');
});
});
18 changes: 0 additions & 18 deletions thirdeye/thirdeye-frontend/tests/acceptance/example-test.js

This file was deleted.

228 changes: 116 additions & 112 deletions 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';
Expand All @@ -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());
});
});

0 comments on commit 445a2db

Please sign in to comment.