You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#6497 introduced test infrastructure for testing ember-data without the @ember-data/adapter package being present at all while #6643 introduces the MinimumAdapterInterface. In this repository we want to add integration tests covering the minimum APIs.
if findMany is not defined we call findRecord for each request and do not call groupRecordsForFindMany
we call groupRecordsForFindMany with the right args if multiple findRecords are triggered
we call findMany with the right args
we do not call findRecord
if coalesceFindRequests is false or undefined, multiple calls to store.findRecord are not coalesced
if a belongsTo relationship has a link but no data
if findBelongsTo is defined we call it and not findRecord
if findBelongsTo is not defined we throw a clear error
if a belongsTo relationship has data but not a link
if findBelongsTo is defined we call findRecord not findBelongsTo
if findBelongsTo is undefined we still call findRecord not findBelongsTo (no error)
if a belongsTo relationship has a link and data
if findBelongsTo is defined we call it and not findRecord
if findBelongsTo is not defined we call findRecord (no error)
if a hasMany relationship has a link but no data
if findHasMany is defined we call it and not findRecord OR findMany
if findHasMany is not defined we throw a clear error
if a hasMany relationship has data but not a link
if findHasMany is defined and coalescing is off we call findRecord for each record
if findHasMany is defined and coalescing is on we call findMany
if findHasMany is undefined and coalescing is off we call findRecord for each record (no error)
if findHasMany is undefined and coalescing is on we call findMany (no error)
if a hasMany relationship has a link and data
if findHasMany is defined we call it and not findRecord or findMany
if findHasMany is not defined and coalescing is off we call findRecord for each record (no error)
if findHasMany is not defined and coalescing is on we call findMany
Mutations
store.deleteRecord calls adapter.deleteRecord if a record is deleted and then saved
store.deleteRecord calls adapter.deleteRecord if a newly created record is persisted, then deleted and then saved
store.deleteRecord does not call adapter.deleteRecord if a newly created, unpersisted record is deleted and then saved
record.save() calls adapter.createRecord if a newly created record unpersisted record is saved
record.save() calls adapter.createRecord then adapter.updateRecord if a newly created record record is saved, then saved again
record.save() calls adapter.updateRecord if an existing persisted record is saved
Reloading
The reload tests should be in one test file specifically for reloading and each section below should be a nested module within that test file.
I might suggest creating a utility to set the state of the various flags and hooks for each test. While DRY is generally to be avoided, a few well
crafted helpers here would improve the legibility of the combinations of flags, helping us to see the nuances of various combos.
For when these methods are undefined there may be fixes required in the current logic in core-store.ts.
adapter.shouldReloadAll (adapter.shouldBackgroundReloadAll should return false for all of these)
adapter.shouldReloadAll is not called when store.findAll is called with a reload: false flag (and we do not make a request)
adapter.shouldReloadAll is not called when store.findAll is called with a reload: true flag (and we make a request).
store.findAll does not error if adapter.shouldReloadAll is not defined
if adapter.shouldReloadAll is undefined we default to false if records are present (and we do not make a request)
if adapter.shouldReloadAll is undefined we default to true if records are not present (and we make a request)
adapter.shouldReloadAll is called when store.findAll is called without a reload flag.
if adapter.shouldReloadAll returns true we make a request
if adapter.shouldReloadAll returns false we do not make a request
adapter.shouldBackgroundReloadAll
adapter.shouldBackgroundReloadAll is not called called when store.findAll is called with reload: true flag (but we do make request)
adapter.shouldBackgroundReloadAll is not called called when store.findAll is called and shouldReloadAll returns true (but we do make request)
When reload: false or no reload flag and adapter.shouldReloadAll returns false
adapter.shouldBackgroundReloadAll is not called when store.findAll is called with backroundReload as an option.
if backgroundReload is true we make a request
if backgroundReload is false we do not make a request
store.findAll does not error if adapter.shouldBackgroundReloadAll is undefined and backgroundReload is not present.
if adapter.shouldBackgroundReloadAll is undefined we default to true and we make a request
adapter.shouldBackgroundReloadAll is called when store.findAll is called and there is no backgroundReload flag
if adapter.shouldBackgroundReloadAll returns true we make a request
if adapter.shouldBackgroundReloadAll returns false we do not make a request
adapter.shouldReloadRecord
adapter.shouldReloadRecord is not called when store.findRecord is called for an unloaded record (but we do make request)
adapter.shouldReloadRecord is not called when store.findRecord is called for a never loaded record (but we do make request)
adapter.shouldReloadRecord is not called when store.findRecord is called with a reload flag (but we do make request if reload is true)
adapter.shouldReloadRecord is not called when store.findRecord is called with a reload flag (and we do not make request if reload is false)
store.findRecord should not error if adapter.shouldReloadRecord is undefined
if adapter.shouldReloadRecord is undefined, we default to false and do not make a request
adapter.shouldReloadRecord is called when store.findRecord is called without a reload flag.
if adapter.shouldReloadRecord returns true we make a request
if adapter.shouldReloadRecord returns false we do not make a request
adapter.shouldBackgroundReloadRecord
adapter.shouldBackgroundReloadRecord is not called when store.findRecord is called for an unloaded record (but we do make request)
adapter.shouldBackgroundReloadRecord is not called when store.findRecord is called for a never loaded record (but we do make request)
adapter.shouldBackgroundReloadRecord is not called called when store.findRecord is called with reload: true flag (but we do make request)
adapter.shouldBackgroundReloadRecord is not called called when store.findRecord is called and shouldReloadRecord returns true (but we do make request)
When reload: false or no reload flag and adapter.shouldReloadRecord returns false
adapter.shouldBackgroundReloadRecord is not called when store.findRecord is called with backroundReload as an option.
if backgroundReload is true we make a request
if backgroundReload is false we do not make a request
store.findRecord does not error if adapter.shouldBackgroundReloadRecord is undefined and backgroundReload is not present.
if adapter.shouldBackgroundReloadRecord is undefined we default to true and we make a request
adapter.shouldBackgroundReloadRecord is called when store.findRecord is called and there is no backgroundReload flag
if adapter.shouldBackgroundReloadRecord returns true we make a request
if adapter.shouldBackgroundReloadRecord returns false we do not make a request
Other
store.createRecord calls adapter.generateIdForRecord if defined and we use this ID for the record
we can peekRecord a newly created record for which we generated an ID in the adapter
store.createRecord does not error if adapter.generateIdForRecord is undefined.
The text was updated successfully, but these errors were encountered:
A Side-Quest for Project Trim!
Side Quests?!?! How fun!
Mission
#6497 introduced test infrastructure for testing ember-data without the
@ember-data/adapter
package being present at all while #6643 introduces the MinimumAdapterInterface. In this repository we want to add integration tests covering the minimum APIs.The following requests should be tested:
Queries
store.findRecord calls adapter.findRecord w/correct args
store.findAll calls adapter.findAll w/correct args
store.query calls adapter.query w/correct args
store.queryRecord calls adapter.queryRecord w/correct args
if coalesceFindRequests is true
if coalesceFindRequests is false or undefined, multiple calls to
store.findRecord
are not coalescedif a belongsTo relationship has a link but no data
if a belongsTo relationship has data but not a link
if a belongsTo relationship has a link and data
if a hasMany relationship has a link but no data
if a hasMany relationship has data but not a link
if a hasMany relationship has a link and data
Mutations
store.deleteRecord
callsadapter.deleteRecord
if a record is deleted and then savedstore.deleteRecord
callsadapter.deleteRecord
if a newly created record is persisted, then deleted and then savedstore.deleteRecord
does not calladapter.deleteRecord
if a newly created, unpersisted record is deleted and then savedrecord.save()
callsadapter.createRecord
if a newly created record unpersisted record is savedrecord.save()
callsadapter.createRecord
thenadapter.updateRecord
if a newly created record record is saved, then saved againrecord.save()
callsadapter.updateRecord
if an existing persisted record is savedReloading
The reload tests should be in one test file specifically for reloading and each section below should be a nested module within that test file.
I might suggest creating a utility to set the state of the various flags and hooks for each test. While DRY is generally to be avoided, a few well
crafted helpers here would improve the legibility of the combinations of flags, helping us to see the nuances of various combos.
For when these methods are
undefined
there may be fixes required in the current logic incore-store.ts
.adapter.shouldReloadAll (
adapter.shouldBackgroundReloadAll
should returnfalse
for all of these)adapter.shouldReloadAll
is not called whenstore.findAll
is called with areload: false
flag (and we do not make a request)adapter.shouldReloadAll
is not called whenstore.findAll
is called with areload: true
flag (and we make a request).store.findAll
does not error ifadapter.shouldReloadAll
is not definedadapter.shouldReloadAll
isundefined
we default tofalse
if records are present (and we do not make a request)adapter.shouldReloadAll
isundefined
we default totrue
if records are not present (and we make a request)adapter.shouldReloadAll
is called whenstore.findAll
is called without areload
flag.adapter.shouldReloadAll
returnstrue
we make a requestadapter.shouldReloadAll
returnsfalse
we do not make a requestadapter.shouldBackgroundReloadAll
adapter.shouldBackgroundReloadAll
is not called called whenstore.findAll
is called withreload: true
flag (but we do make request)adapter.shouldBackgroundReloadAll
is not called called whenstore.findAll
is called andshouldReloadAll
returnstrue
(but we do make request)reload: false
or no reload flag andadapter.shouldReloadAll
returns falseadapter.shouldBackgroundReloadAll
is not called whenstore.findAll
is called withbackroundReload
as an option.true
we make a requestfalse
we do not make a requeststore.findAll
does not error ifadapter.shouldBackgroundReloadAll
is undefined andbackgroundReload
is not present.adapter.shouldBackgroundReloadAll
is undefined we default totrue
and we make a requestadapter.shouldBackgroundReloadAll
is called whenstore.findAll
is called and there is nobackgroundReload
flagadapter.shouldBackgroundReloadAll
returnstrue
we make a requestadapter.shouldBackgroundReloadAll
returnsfalse
we do not make a requestadapter.shouldReloadRecord
adapter.shouldReloadRecord
is not called whenstore.findRecord
is called for an unloaded record (but we do make request)adapter.shouldReloadRecord
is not called whenstore.findRecord
is called for a never loaded record (but we do make request)adapter.shouldReloadRecord
is not called whenstore.findRecord
is called with areload
flag (but we do make request if reload is true)adapter.shouldReloadRecord
is not called whenstore.findRecord
is called with areload
flag (and we do not make request if reload is false)store.findRecord
should not error ifadapter.shouldReloadRecord
is undefinedadapter.shouldReloadRecord
is undefined, we default tofalse
and do not make a requestadapter.shouldReloadRecord
is called whenstore.findRecord
is called without areload
flag.adapter.shouldReloadRecord
returnstrue
we make a requestadapter.shouldReloadRecord
returnsfalse
we do not make a requestadapter.shouldBackgroundReloadRecord
adapter.shouldBackgroundReloadRecord
is not called whenstore.findRecord
is called for an unloaded record (but we do make request)adapter.shouldBackgroundReloadRecord
is not called whenstore.findRecord
is called for a never loaded record (but we do make request)adapter.shouldBackgroundReloadRecord
is not called called whenstore.findRecord
is called withreload: true
flag (but we do make request)adapter.shouldBackgroundReloadRecord
is not called called whenstore.findRecord
is called andshouldReloadRecord
returnstrue
(but we do make request)reload: false
or no reload flag andadapter.shouldReloadRecord
returns falseadapter.shouldBackgroundReloadRecord
is not called whenstore.findRecord
is called withbackroundReload
as an option.true
we make a requestfalse
we do not make a requeststore.findRecord
does not error ifadapter.shouldBackgroundReloadRecord
is undefined andbackgroundReload
is not present.adapter.shouldBackgroundReloadRecord
is undefined we default totrue
and we make a requestadapter.shouldBackgroundReloadRecord
is called whenstore.findRecord
is called and there is nobackgroundReload
flagadapter.shouldBackgroundReloadRecord
returnstrue
we make a requestadapter.shouldBackgroundReloadRecord
returnsfalse
we do not make a requestOther
store.createRecord
callsadapter.generateIdForRecord
if defined and we use this ID for the recordstore.createRecord
does not error ifadapter.generateIdForRecord
is undefined.The text was updated successfully, but these errors were encountered: