diff --git a/tests/integration/mixins/loadable-store/load-records-test.js b/tests/integration/mixins/loadable-store/load-records-test.js index 26823116..ff43711e 100644 --- a/tests/integration/mixins/loadable-store/load-records-test.js +++ b/tests/integration/mixins/loadable-store/load-records-test.js @@ -4,6 +4,7 @@ import { waitUntil } from '@ember/test-helpers'; import MirageServer from 'dummy/tests/integration/helpers/mirage-server'; import { Model, hasMany, belongsTo } from 'ember-cli-mirage'; import LoadableStore from 'ember-data-storefront/mixins/loadable-store'; +import DSModel from 'ember-data/model'; module('Integration | Mixins | LoadableStore | loadRecords', function(hooks) { setupTest(hooks); @@ -14,11 +15,15 @@ module('Integration | Mixins | LoadableStore | loadRecords', function(hooks) { post: Model.extend({ comments: hasMany(), author: belongsTo(), - tags: hasMany() + tags: hasMany(), + + owner: belongsTo('author', { inverse: null }) }), comment: Model.extend({ post: belongsTo(), - author: belongsTo() + author: belongsTo(), + + owner: belongsTo('post', { inverse: null }) }), tag: Model.extend({ posts: hasMany() @@ -146,6 +151,28 @@ module('Integration | Mixins | LoadableStore | loadRecords', function(hooks) { assert.equal(posts.get('firstObject.comments.length'), 2); }); + test('it can load a polymorphic collection with model-specific includes', async function(assert) { + server.logging = true; + this.server.get('/items', schema => { + let posts = schema.posts.all(); + let comments = schema.comments.all(); + + return posts.mergeCollection(comments); + }); + let post = this.server.create('post', { + owner: this.server.create('author') + }); + let comment = this.server.create('comment', { + owner: post + }); + this.owner.register('model:item', DSModel.extend()); + + await this.store.loadRecords('item', { include: 'owner' }); + + assert.ok(this.store.peekRecord('post', post.id)); + assert.ok(this.store.peekRecord('comment', comment.id)); + }); + module('Tracking includes', function() { test('it will track an include', async function(assert) { let serverPost = this.server.create('post', { title: 'My post' });