-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: backport various fixes to 5.3 (#9225)
* fix: JSONAPISerializer should not reify empty records (#8934) * fix: JSONAPISerializer should not reify empty records * fix lint * fix: url configuration should respect / for host and error more meaningfully when invalid (#9164) * fix: url configuration should respect / for host and error more meaningfully when invalid * fix prettier * fix: keep a backreference for previously merged identifiers (#9183) * fix: keep a backreference for previously merged identifiers * update tests
- Loading branch information
Showing
8 changed files
with
283 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"eslint.format.enable": true, | ||
"eslint.workingDirectories": [{ "mode": "auto" }, "packages/*", "tests/*"], | ||
"eslint.options": { "reportUnusedDisableDirectives": "error" }, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
}, | ||
"files.associations": { | ||
"turbo.json": "jsonc" | ||
}, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
}, | ||
"[handlebars]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
}, | ||
"[json]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
}, | ||
"[glimmer-js]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
}, | ||
"[glimmer-ts]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
}, | ||
"[markdown]": { | ||
"editor.detectIndentation": false, | ||
"editor.insertSpaces": false, | ||
"editor.tabSize": 4 | ||
}, | ||
"typescript.preferences.importModuleSpecifier": "project-relative" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
tests/main/tests/integration/records/polymorphic-find-record-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { settled } from '@ember/test-helpers'; | ||
|
||
import { module, test } from 'qunit'; | ||
|
||
import type Store from 'ember-data/store'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
import Model, { attr } from '@ember-data/model'; | ||
import { recordIdentifierFor } from '@ember-data/store'; | ||
|
||
class Person extends Model { | ||
@attr declare name: string; | ||
} | ||
class Employee extends Person {} | ||
|
||
module('integration/records/polymorphic-find-record - Polymorphic findRecord', function (hooks) { | ||
setupTest(hooks); | ||
|
||
test('when findRecord with abstract type returns concrete type', async function (assert) { | ||
this.owner.register('model:person', Person); | ||
this.owner.register('model:employee', Employee); | ||
|
||
const store = this.owner.lookup('service:store') as Store; | ||
const adapter = store.adapterFor('application'); | ||
|
||
adapter.findRecord = () => { | ||
return Promise.resolve({ | ||
data: { | ||
id: '1', | ||
type: 'employee', | ||
attributes: { | ||
name: 'Rey Skybarker', | ||
}, | ||
}, | ||
}); | ||
}; | ||
|
||
const person = (await store.findRecord('person', '1')) as Employee; | ||
assert.ok(person instanceof Employee, 'record is an instance of Employee'); | ||
assert.strictEqual(person.name, 'Rey Skybarker', 'name is correct'); | ||
assert.strictEqual(recordIdentifierFor(person).type, 'employee', 'identifier has the concrete type'); | ||
|
||
const employee = store.peekRecord('employee', '1'); | ||
const person2 = store.peekRecord('person', '1'); | ||
assert.strictEqual(employee, person, 'peekRecord returns the same instance for concrete type'); | ||
assert.strictEqual(person2, person, 'peekRecord returns the same instance for abstract type'); | ||
assert.strictEqual(store.identifierCache._cache.resources.size, 2, 'identifier cache contains backreferences'); | ||
|
||
person.unloadRecord(); | ||
await settled(); | ||
assert.strictEqual(store.identifierCache._cache.resources.size, 0, 'identifier cache is empty'); | ||
}); | ||
}); |
Oops, something went wrong.