diff --git a/packages/-ember-data/tests/acceptance/relationships/belongs-to-test.js b/packages/-ember-data/tests/acceptance/relationships/belongs-to-test.js index 05dfc4f15ba..758cf703c39 100644 --- a/packages/-ember-data/tests/acceptance/relationships/belongs-to-test.js +++ b/packages/-ember-data/tests/acceptance/relationships/belongs-to-test.js @@ -1,4 +1,4 @@ -import { module, test, skip } from 'qunit'; +import { module, test, todo } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import JSONAPIAdapter from '@ember-data/adapter/json-api'; import Model from '@ember-data/model'; @@ -374,7 +374,7 @@ module('async belongs-to rendering tests', function(hooks) { assert.equal(this.element.textContent.trim(), 'Kevin has two children and one parent'); }); - skip('Rendering an async belongs-to whose fetch fails does not trigger a new request', async function(assert) { + todo('Rendering an async belongs-to whose fetch fails does not trigger a new request', async function(assert) { assert.expect(15); let people = makePeopleWithRelationshipData(); let sedona = store.push({ diff --git a/packages/-ember-data/tests/acceptance/relationships/has-many-test.js b/packages/-ember-data/tests/acceptance/relationships/has-many-test.js index 0dccfe1cbb0..22109bced6e 100644 --- a/packages/-ember-data/tests/acceptance/relationships/has-many-test.js +++ b/packages/-ember-data/tests/acceptance/relationships/has-many-test.js @@ -1,4 +1,4 @@ -import { module, test, skip } from 'qunit'; +import { module, test, todo } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import JSONAPIAdapter from '@ember-data/adapter/json-api'; import Model from '@ember-data/model'; @@ -287,7 +287,7 @@ module('async has-many rendering tests', function(hooks) { ); }); - skip('Rendering an async hasMany whose fetch fails does not trigger a new request', async function(assert) { + todo('Rendering an async hasMany whose fetch fails does not trigger a new request', async function(assert) { assert.expect(12); let people = makePeopleWithRelationshipData(); let parent = store.push({ @@ -444,7 +444,7 @@ module('async has-many rendering tests', function(hooks) { ); }); - skip('Rendering an async hasMany with a link whose fetch fails does not trigger a new request', async function(assert) { + todo('Rendering an async hasMany with a link whose fetch fails does not trigger a new request', async function(assert) { assert.expect(12); let people = makePeopleWithRelationshipLinks(true); let parent = store.push({ diff --git a/packages/-ember-data/tests/helpers/todo.js b/packages/-ember-data/tests/helpers/todo.js deleted file mode 100644 index 41a570184cd..00000000000 --- a/packages/-ember-data/tests/helpers/todo.js +++ /dev/null @@ -1,95 +0,0 @@ -/* global Proxy */ -import QUnit, { test } from 'qunit'; - -export default function todo(description, callback) { - test(`[TODO] ${description}`, async function todoTest(assert) { - let todos = []; - hijackAssert(assert, todos); - - await callback.call(this, assert); - - assertTestStatus(assert, todos); - }); -} - -function hijackAssert(assert, todos) { - const pushResult = assert.pushResult; - - assert.pushResult = function hijackedPushResult(assertion) { - let result = assertion.result; - if (!assertion.isTodo && result === false) { - assertion.message = `[REGRESSION ENCOUNTERED] ${assertion.message}`; - } - - return pushResult.call(assert, assertion); - }; - let handler = { - get(target, propKey /*, receiver*/) { - const origMethod = target[propKey]; - - if (typeof origMethod === 'function' && propKey === 'pushResult') { - return function captureResult(assertion) { - let result = assertion.result; - assertion.isTodo = true; - assertion.message = `[TODO ${result === true ? 'COMPLETED' : 'INCOMPLETE'}] ${ - assertion.message - }`; - - todos.push(assertion); - origMethod.call(target, assertion); - }; - } else { - return origMethod; - } - }, - }; - - assert.todo = new Proxy(assert, handler); -} - -function assertTestStatus(assert, todos) { - assert.todo = false; - const totalTodoFailures = todos.reduce((c, r) => { - return r.result === false ? c + 1 : c; - }, 0); - const results = QUnit.config.current.assertions; - const totalFailures = results.reduce((c, r) => { - return r.result === false ? c + 1 : c; - }, 0); - const hasNonTodoFailures = totalFailures > totalTodoFailures; - const hasSomeCompletedTodos = totalTodoFailures < todos.length; - const totalWasMet = assert.test.expected === null || assert.test.expected === results.length; - const todoIsComplete = totalWasMet && totalTodoFailures === 0; - - if (todoIsComplete) { - assert.pushResult({ - isTodo: true, - actual: true, - expected: false, - message: - '[TODO COMPLETED] This TODO is now complete (all "todo" assertions pass) and MUST be converted from todo() to test()', - result: false, - }); - } else if (hasNonTodoFailures) { - assert.pushResult({ - isTodo: true, - actual: false, - expected: true, - message: - '[REGRESSION MUST-FIX] This TODO is has regressed (a non "todo" assertion has failed) and MUST be fixed', - result: false, - }); - } else if (hasSomeCompletedTodos) { - assert.pushResult({ - isTodo: true, - actual: false, - expected: true, - message: - '[TODOS COMPLETED] Some assert.todos assertions have been completed and MUST now be converted from assert.todo to assert.', - result: false, - }); - } else { - assert.test.skip = true; - assert.test.testReport.skipped = true; - } -} diff --git a/packages/-ember-data/tests/integration/records/load-test.js b/packages/-ember-data/tests/integration/records/load-test.js index b4bc05572e4..1aa83b3cb7b 100644 --- a/packages/-ember-data/tests/integration/records/load-test.js +++ b/packages/-ember-data/tests/integration/records/load-test.js @@ -1,4 +1,4 @@ -import { module, test } from 'qunit'; +import { module, test, todo } from 'qunit'; import { setupTest } from 'ember-qunit'; import { reject, resolve } from 'rsvp'; import Store from '@ember-data/store'; @@ -6,7 +6,6 @@ import Model from '@ember-data/model'; import JSONAPIAdapter from '@ember-data/adapter/json-api'; import JSONAPISerializer from '@ember-data/serializer/json-api'; import { run } from '@ember/runloop'; -import todo from '../../helpers/todo'; import { attr, belongsTo } from '@ember-data/model'; class Person extends Model { diff --git a/packages/-ember-data/tests/integration/relationships/has-many-test.js b/packages/-ember-data/tests/integration/relationships/has-many-test.js index 2f53987f264..443a67a13e6 100644 --- a/packages/-ember-data/tests/integration/relationships/has-many-test.js +++ b/packages/-ember-data/tests/integration/relationships/has-many-test.js @@ -6,7 +6,7 @@ import { get } from '@ember/object'; import { run } from '@ember/runloop'; import setupStore from 'dummy/tests/helpers/store'; import testInDebug from 'dummy/tests/helpers/test-in-debug'; -import { module, test, skip } from 'qunit'; +import { module, test, todo } from 'qunit'; import { relationshipStateFor, relationshipsFor } from 'ember-data/-private'; import DS from 'ember-data'; @@ -955,7 +955,7 @@ module('integration/relationships/has_many - Has-Many Relationships', function(h }); }); - skip('A hasMany relationship can be reloaded even if it failed at the first time', async function(assert) { + todo('A hasMany relationship can be reloaded even if it failed at the first time', async function(assert) { assert.expect(6); const { store, adapter } = env; @@ -2135,7 +2135,7 @@ module('integration/relationships/has_many - Has-Many Relationships', function(h ); }); - skip('A sync hasMany errors out if there are unloaded records in it', function(assert) { + todo('A sync hasMany errors out if there are unloaded records in it', function(assert) { let post = run(() => { env.store.push({ data: { diff --git a/packages/-ember-data/tests/integration/relationships/many-to-many-test.js b/packages/-ember-data/tests/integration/relationships/many-to-many-test.js index 41558c29156..1a3edebdb37 100644 --- a/packages/-ember-data/tests/integration/relationships/many-to-many-test.js +++ b/packages/-ember-data/tests/integration/relationships/many-to-many-test.js @@ -4,8 +4,7 @@ import { resolve, Promise as EmberPromise } from 'rsvp'; import { run } from '@ember/runloop'; import { get } from '@ember/object'; import setupStore from 'dummy/tests/helpers/store'; -import { module, test } from 'qunit'; -import todo from '../../helpers/todo'; +import { module, test, todo } from 'qunit'; import DS from 'ember-data'; const { attr, hasMany } = DS; diff --git a/packages/-ember-data/tests/unit/model/relationships/has-many-test.js b/packages/-ember-data/tests/unit/model/relationships/has-many-test.js index cf21a45ae7f..f6147e47e83 100644 --- a/packages/-ember-data/tests/unit/model/relationships/has-many-test.js +++ b/packages/-ember-data/tests/unit/model/relationships/has-many-test.js @@ -3,9 +3,8 @@ import { get, observer } from '@ember/object'; import { run } from '@ember/runloop'; import setupStore from 'dummy/tests/helpers/store'; import testInDebug from 'dummy/tests/helpers/test-in-debug'; -import { module, test } from 'qunit'; +import { module, test, todo } from 'qunit'; import DS from 'ember-data'; -import todo from '../../../helpers/todo'; let env;