[TE] frontend - Updated test with await/async
import { test } from 'qunit';
+import { visit, click, find, fillIn } from 'ember-native-dom-helpers';
import moduleForAcceptance from 'thirdeye-frontend/tests/helpers/module-for-acceptance';
moduleForAcceptance('Acceptance | edit alert');
@@ -11,12 +12,10 @@ const EDIT_LINK = '/manage/alerts/edit';
const STATUS_TOGGLER = '.x-toggle-btn';
const SUBMIT_BUTTON = '.te-button--submit';
-// TODO: Update the syntax to use async/await http://rwjblue.com/2017/10/30/async-await-configuration-adventure/
test(`visiting ${EDIT_LINK} and checking that fields render correctly and edit is successful`, assert => {
const alert = server.create('alert');
- visit(`/manage/alerts/${alert.id}`);
+ await visit(`/manage/alerts/${alert.id}`);
- andThen(() => {
assert.equal(
currentURL(),
'/manage/alerts/1',
@@ -38,22 +37,19 @@ test(`visiting ${EDIT_LINK} and checking that fields render correctly and edit i
find(STATUS).get(0).innerText,
'Active',
'alert status is correct');
- });
- fillIn(ALERT_NAME, 'test_function_2');
- click(STATUS_TOGGLER);
- click(SUBMIT_BUTTON);
+ await fillIn(ALERT_NAME, 'test_function_2');
+ await click(STATUS_TOGGLER);
+ await click(SUBMIT_BUTTON);
- andThen(() => {
assert.equal(
currentURL(),
'/manage/alerts',
'correctly redirects to manage alerts page after edit'
);
- visit(`/manage/alerts/${alert.id}`);
- });
- andThen(() => {
+ await visit(`/manage/alerts/${alert.id}`);
+
assert.equal(
find(ALERT_NAME).get(0).value,
'test_function_2',
@@ -63,4 +59,3 @@ test(`visiting ${EDIT_LINK} and checking that fields render correctly and edit i
'Inactive',
'after edit, alert status is saved correctly');
});
-});
