-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Test]: fix for DataWrapper refactor in emberjs #7435
Changes from all commits
7707e3a
8ce9e6d
3be4841
f67e48f
852dc57
de68a6d
03a2594
c5e20ee
73e2f89
6cfb36f
809c2b6
1efd480
6a97cd9
f7e9e77
1b75f2e
1437f6b
051b1a7
b38e71b
186df14
633fbe2
bd93053
2981e7f
4b74236
24c1a96
ee8efc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { settled } from '@ember/test-helpers'; | |
|
||
import { module, test } from 'qunit'; | ||
|
||
import { gte } from 'ember-compatibility-helpers'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
import Adapter from '@ember-data/adapter'; | ||
|
@@ -65,7 +66,7 @@ module('integration/debug-adapter - DS.DebugAdapter', function(hooks) { | |
test('Watching Records', async function(assert) { | ||
let { owner } = this; | ||
let debugAdapter = owner.lookup('data-adapter:main'); | ||
let addedRecords, updatedRecords, removedIndex, removedCount; | ||
let addedRecords, updatedRecords, removedRecords; | ||
|
||
this.owner.register( | ||
'adapter:application', | ||
|
@@ -86,15 +87,17 @@ module('integration/debug-adapter - DS.DebugAdapter', function(hooks) { | |
}, | ||
}); | ||
|
||
var recordsAdded = function(wrappedRecords) { | ||
let recordsAdded = function(wrappedRecords) { | ||
addedRecords = wrappedRecords; | ||
}; | ||
var recordsUpdated = function(wrappedRecords) { | ||
let recordsUpdated = function(wrappedRecords) { | ||
updatedRecords = wrappedRecords; | ||
}; | ||
var recordsRemoved = function(index, count) { | ||
removedIndex = index; | ||
removedCount = count; | ||
let recordsRemoved = function(...args) { | ||
// in 3.26 there is only 1 argument - the record removed | ||
// below 3.26, it is 2 arguments - the index and count removed | ||
// https://github.com/emberjs/ember.js/pull/19379 | ||
removedRecords = args; | ||
}; | ||
|
||
debugAdapter.watchRecords('post', recordsAdded, recordsUpdated, recordsRemoved); | ||
|
@@ -114,6 +117,9 @@ module('integration/debug-adapter - DS.DebugAdapter', function(hooks) { | |
|
||
post.set('title', 'Modified Post'); | ||
|
||
// await updated callback | ||
await settled(); | ||
|
||
assert.equal(get(updatedRecords, 'length'), 1, 'We updated 1 post'); | ||
record = updatedRecords[0]; | ||
assert.deepEqual( | ||
|
@@ -131,7 +137,6 @@ module('integration/debug-adapter - DS.DebugAdapter', function(hooks) { | |
|
||
// reset | ||
addedRecords = updatedRecords = []; | ||
removedCount = removedIndex = null; | ||
|
||
post = store.createRecord('post', { id: '2', title: 'New Post' }); | ||
|
||
|
@@ -159,14 +164,18 @@ module('integration/debug-adapter - DS.DebugAdapter', function(hooks) { | |
|
||
// reset | ||
addedRecords = updatedRecords = []; | ||
removedCount = removedIndex = null; | ||
|
||
post.unloadRecord(); | ||
|
||
await settled(); | ||
|
||
assert.equal(removedIndex, 1, 'We are notified of the start index of a removal when we remove posts'); | ||
assert.equal(removedCount, 1, 'We are notified of the total posts removed'); | ||
if (gte('3.26.0')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably add a comment about why we expect these to differ for 3.26+ |
||
assert.equal(removedRecords.length, 1, 'We are notified of the total posts removed'); | ||
assert.equal(removedRecords[0][0].object, post, 'The removed post is correct'); | ||
} else { | ||
assert.equal(removedRecords[0], 1, 'We are notified of the start index of a removal when we remove posts'); | ||
assert.equal(removedRecords[1], 1, 'We are notified of the total posts removed'); | ||
} | ||
}); | ||
|
||
test('Column names', function(assert) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ module('integration/store/creation-recursion', function(hooks) { | |
let storeFactory = this.owner.factoryFor('service:store'); | ||
|
||
this.owner.unregister('service:store'); | ||
this.owner.register('service:store', storeFactory); | ||
this.owner.register('service:store', storeFactory.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What caused this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ember asserts if you pass the factoryFor result directly to register now |
||
|
||
let test = this; | ||
test.dateTransformCreated = false; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
*/ | ||
import { assert, inspect, warn } from '@ember/debug'; | ||
import { assign } from '@ember/polyfills'; | ||
import { run } from '@ember/runloop'; | ||
import { _backburner as emberBackburner } from '@ember/runloop'; | ||
import { isEqual } from '@ember/utils'; | ||
import { DEBUG } from '@glimmer/env'; | ||
|
||
|
@@ -437,7 +437,7 @@ export default class RecordDataDefault implements RelationshipRecordData { | |
this._destroyRelationships(); | ||
this.reset(); | ||
if (!this._scheduledDestroy) { | ||
this._scheduledDestroy = run.backburner.schedule('destroy', this, '_cleanupOrphanedRecordDatas'); | ||
this._scheduledDestroy = emberBackburner.schedule('destroy', this, '_cleanupOrphanedRecordDatas'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does run complain now when you access backburner on it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { registerWaiter } from '@ember/test'; | |
import { DEBUG } from '@glimmer/env'; | ||
import Ember from 'ember'; | ||
|
||
// TODO: expose Ember._Backburner as `import { _Backburner } from '@ember/runloop'` in ember-rfc176-data + emberjs/ember.js | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please clarify this a bit, not quite sure what the future work required is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ember doesn't expose the constructor for Backburner in a modules API |
||
const backburner = new Ember._Backburner(['normalizeRelationships', 'syncRelationships', 'finished']); | ||
|
||
if (DEBUG) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we have to add this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.