Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Disable known failure for 3.16.x" #7030

Merged
merged 1 commit into from Feb 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import { run } from '@ember/runloop';
import { module, test } from 'qunit';
import { resolve } from 'rsvp';

import { gte } from 'ember-compatibility-helpers';
import { setupTest } from 'ember-qunit';

import Adapter from '@ember-data/adapter';
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
import JSONAPISerializer from '@ember-data/serializer/json-api';
import todo from '@ember-data/unpublished-test-infra/test-support/todo';

module('integration/relationships/one_to_many_test - OneToMany relationships', function(hooks) {
setupTest(hooks);
Expand Down Expand Up @@ -1568,51 +1566,39 @@ module('integration/relationships/one_to_many_test - OneToMany relationships', f
assert.equal(account.get('user'), null, 'Account does not have the user anymore');
});

// This is the check we actually want, but compatibility-helpers doesn't give correct results for pre-release tags
// see https://github.com/pzuraq/ember-compatibility-helpers/pull/41
// if ((gte('3.16.0') && !gte('3.17.0')) /* 3.16.x */ || (gte('3.17.99') && !gte('3.18.0')) /* 3.18.0-canary */) {
//
if (gte('3.16.0')) {
// known failure in 3.16.x due to upstream glimmer VM issue
// https://github.com/glimmerjs/glimmer-vm/pull/1010
todo('createRecord updates inverse record array which has observers', function(assert) {
assert.todo.ok(false, 'known failure in ember-source@^3.16.0');
});
} else {
test('createRecord updates inverse record array which has observers', function(assert) {
let store = this.owner.lookup('service:store');
let adapter = store.adapterFor('application');

adapter.findAll = () => {
return {
data: [
{
id: '2',
type: 'user',
attributes: {
name: 'Stanley',
},
test('createRecord updates inverse record array which has observers', function(assert) {
let store = this.owner.lookup('service:store');
let adapter = store.adapterFor('application');

adapter.findAll = () => {
return {
data: [
{
id: '2',
type: 'user',
attributes: {
name: 'Stanley',
},
],
};
},
],
};
};

return store.findAll('user').then(users => {
assert.equal(users.get('length'), 1, 'Exactly 1 user');
return store.findAll('user').then(users => {
assert.equal(users.get('length'), 1, 'Exactly 1 user');

let user = users.get('firstObject');
assert.equal(user.get('messages.length'), 0, 'Record array is initially empty');
let user = users.get('firstObject');
assert.equal(user.get('messages.length'), 0, 'Record array is initially empty');

// set up an observer
user.addObserver('[email protected]', () => {});
user.get('messages.firstObject');
// set up an observer
user.addObserver('[email protected]', () => {});
user.get('messages.firstObject');

let message = store.createRecord('message', { user, title: 'EmberFest was great' });
assert.equal(user.get('messages.length'), 1, 'The message is added to the record array');
let message = store.createRecord('message', { user, title: 'EmberFest was great' });
assert.equal(user.get('messages.length'), 1, 'The message is added to the record array');

let messageFromArray = user.get('messages.firstObject');
assert.ok(message === messageFromArray, 'Only one message record instance should be created');
});
let messageFromArray = user.get('messages.firstObject');
assert.ok(message === messageFromArray, 'Only one message record instance should be created');
});
}
});
});