diff --git a/tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-immediately-test.js b/tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-immediately-test.js index 8beb992a7..8907205fa 100644 --- a/tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-immediately-test.js +++ b/tests/acceptance/components/flexberry-objectlistview/folv-delete-before-recoed-data-immediately-test.js @@ -6,84 +6,74 @@ import FilterOperator from 'ember-flexberry-data/query/filter-operator'; import { click } from '@ember/test-helpers'; import $ from 'jquery'; -executeTest('check delete before record data immediately test', (store, assert, app) => { +executeTest('check delete before record data immediately test', async (store, assert, app) => { assert.expect(5); - let path = 'components-examples/flexberry-objectlistview/before-delete-record/folv-for-before-delete-record-data-immediately'; - let modelName = 'ember-flexberry-dummy-suggestion-type'; - let howAddRec = 1; - let uuid = '0' + generateUniqueId(); + const path = 'components-examples/flexberry-objectlistview/before-delete-record/folv-for-before-delete-record-data-immediately'; + const modelName = 'ember-flexberry-dummy-suggestion-type'; + const howAddRec = 1; + const uuid = '0' + generateUniqueId(); // Add record for deleting. - run(() => { + await run(async() => { let newRecord = store.createRecord(modelName, { name: uuid }); - let done1 = assert.async(); - newRecord.save().then(() => { - addDataForDestroy(newRecord); - let builder = new Builder(store).from(modelName).count(); - let done = assert.async(); - store.query(modelName, builder.build()).then((result) => { - visit(path + '?perPage=' + result.meta.count); - andThen(() => { - assert.equal(currentPath(), path); + await newRecord.save(); + addDataForDestroy(newRecord); + let builder = new Builder(store).from(modelName).count(); + let result = await store.query(modelName, builder.build()); + + await visit(path + '?perPage=' + result.meta.count); + assert.equal(currentPath(), path); - let olvContainerClass = '.object-list-view-container'; - let trTableClass = 'table.object-list-view tbody tr'; + let olvContainerClass = '.object-list-view-container'; + let trTableClass = 'table.object-list-view tbody tr'; - let $folvContainer = $(olvContainerClass); - let $rows = () => { return $(trTableClass, $folvContainer).toArray(); }; + let $folvContainer = $(olvContainerClass); + let $rows = () => { return $(trTableClass, $folvContainer).toArray(); }; - // Check that the record have been added. - let recordIsForDeleting = $rows().reduce((sum, element) => { - let nameRecord = $.trim(element.children[1].innerText); - let flag = nameRecord.indexOf(uuid) >= 0; - return sum + flag; - }, 0); + // Check that the record have been added. + let recordIsForDeleting = $rows().reduce((sum, element) => { + let nameRecord = $.trim(element.children[1].innerText); + let flag = nameRecord.indexOf(uuid) >= 0; + return sum + flag; + }, 0); - assert.equal(recordIsForDeleting > 0, true, howAddRec + ' record added'); + assert.equal(recordIsForDeleting > 0, true, howAddRec + ' record added'); - /* eslint-disable no-unused-vars */ - let clickPromises = []; - $rows().forEach(function(element, i, arr) { - let nameRecord = $.trim(element.children[1].innerText); - if (nameRecord.indexOf(uuid) >= 0) { - let $deleteBtnInRow = $('.object-list-view-row-delete-button', element)[0]; - clickPromises.push(click($deleteBtnInRow)); - } - }); - /* eslint-enable no-unused-vars */ + /* eslint-disable no-unused-vars */ + let clickPromises = []; + $rows().forEach(function(element, i, arr) { + let nameRecord = $.trim(element.children[1].innerText); + if (nameRecord.indexOf(uuid) >= 0) { + let $deleteBtnInRow = $('.object-list-view-row-delete-button', element)[0]; + clickPromises.push(click($deleteBtnInRow)); + } + }); + /* eslint-enable no-unused-vars */ - Promise.all(clickPromises).then(() => { - let done2 = assert.async(); + await Promise.all(clickPromises); - // Check that the records wasn't removed in beforeDeleteRecord. - let controller = app.__container__.lookup('controller:' + currentRouteName()); - assert.ok(controller.recordWasNotDelete, 'Records wasn\'t remove in beforeDeleteRecord'); + // Check that the records wasn't removed in beforeDeleteRecord. + let controller = app.__container__.lookup('controller:' + currentRouteName()); + assert.ok(controller.recordWasNotDelete, 'Records wasn\'t remove in beforeDeleteRecord'); - // Check if the records haven't been removed. - let recordsIsDeleteBtnInRow = $rows().every((element) => { - let nameRecord = $.trim(element.children[1].innerText); - return nameRecord.indexOf(uuid) < 0; - }); + // Check if the records haven't been removed. + let recordsIsDeleteBtnInRow = $rows().every((element) => { + let nameRecord = $.trim(element.children[1].innerText); + return nameRecord.indexOf(uuid) < 0; + }); - assert.ok(recordsIsDeleteBtnInRow, 'Each entry begins with \'' + uuid + '\' was deleted with button in row'); + assert.ok(recordsIsDeleteBtnInRow, 'Each entry begins with \'' + uuid + '\' was deleted with button in row'); - // Check that the records have been removed from store. - let builder2 = new Builder(store, modelName).where('name', FilterOperator.Eq, uuid).count(); - let timeout = 500; - later((function() { - store.query(modelName, builder2.build()).then((result) => { - assert.ok(result.meta.count, 'record \'' + uuid + '\'not found in store'); - done2(); - }).finally(() => { - newRecord.destroyRecord(); - }); - }), timeout); - }); - }); - done(); - }); - done1(); - }); + // Check that the records have been removed from store. + let builder2 = new Builder(store, modelName).where('name', FilterOperator.Eq, uuid).count(); + let timeout = 500; + await new Promise(resolve => + later(async() => { + let result = await store.query(modelName, builder2.build()); + assert.ok(result.meta.count, 'record \'' + uuid + '\'not found in store'); + resolve(); + await newRecord.destroyRecord(); + }, timeout)); }); -}); +}); \ No newline at end of file