-
Notifications
You must be signed in to change notification settings - Fork 42
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
Failing test for remoteId on unloaded relationship with data #403
base: main
Are you sure you want to change the base?
Conversation
In orbitjs#400 @dgeb suggested that even unloaded records should have a type, id, and (if configured) remoteId key when accessed via a relationship that loaded with a `data` property. These tests demonstrate that that works when the related record is already loaded, but fails when it is not.
}, | ||
relationships: { | ||
planet: { | ||
data: t.$normalizeRecordIdentity({ |
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.
I'm not 100% sure this correctly simulates what happens in a real app that's using a jsonapi source that gets back a server generated id here, but it does reproduce the same behavior I'm seeing in a real app.
@@ -680,4 +680,71 @@ module('Integration - Model', function (hooks) { | |||
assert.strictEqual(jupiter.name, 'Jupiter'); | |||
assert.strictEqual(jupiter.hasName, true); | |||
}); | |||
|
|||
test('hasOne contains type, id, and remoteId for loaded record', async function (assert) { |
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.
This test passes
assert.strictEqual(phobos.planet?.remoteId, '3', 'has expected remoteId'); | ||
}); | ||
|
||
test('hasOne contains type, id, and remoteId for unloaded record', async function (assert) { |
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.
This test fails
In #400 @dgeb suggested that even unloaded records should have a type, id, and (if configured) remoteId key when accessed via a relationship that loaded with a
data
property.These tests demonstrate that that works when the related record is already loaded, but fails when it is not.