Skip to content
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

fix tests #7703

Merged
merged 6 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions packages/-ember-data/tests/integration/store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ module('integration/store - destroy', function (hooks) {

let store = this.owner.lookup('service:store');
let next;
let nextPromise = new Promise((resolve) => (next = resolve));
let nextPromise;
let TestAdapter = DS.Adapter.extend({
findRecord() {
next();
nextPromise = new Promise((resolve) => {
next = resolve;
}).then(() => {
Expand All @@ -165,7 +164,8 @@ module('integration/store - destroy', function (hooks) {

throw new Error("We shouldn't be pushing data into the store when it is destroyed");
};
let requestPromise = store.findRecord('car', '1');

store.findRecord('car', '1');

await nextPromise;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I was reading this right but now I'm questioning myself. I wouldn't think we would advance from this line because we have yet to resolve the promise. I thought it would just hang here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gets resolved on line 143 no?

Copy link
Contributor Author

@snewcomer snewcomer Sep 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a plan TS example. We haven't resolved yet as of our await nextPromise. Clearly a gap in my knowledge somewhere 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that store.findRecord would batch multiple if necessary. As a result, nextPromise is undefined here.


Expand All @@ -175,14 +175,12 @@ module('integration/store - destroy', function (hooks) {

next();

await nextPromise;
const result = await nextPromise;

// ensure we allow the internal store promises
// to flush, potentially pushing data into the store
await settled();
assert.ok(true, 'we made it to the end');
await requestPromise;
assert.ok(false, 'we should never make it here');
assert.equal(result.data.type, 'car', 'we made it to the end');
});
Copy link
Contributor Author

@snewcomer snewcomer Sep 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is now failing on the main branch (see here where tests never finish). I rewrote it a little bit but the main issue was await requestPromise. On first glance, I can't tell what is going wrong here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this was failing on 3.20 (last 3.20 release was https://github.com/emberjs/ember.js/tree/v3.20.7) something has "changed" since the last PRs a week ago. In any case, I distilled the test down a bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, interesting, it seems like we are asserting that the promise never finishes, it makes sense it would hang the test. We can rewrite this as .then and not hang on it, or just rely on the store.push

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with .then! Thank you!


test('destroying the store correctly cleans everything up', async function (assert) {
Expand Down
2 changes: 0 additions & 2 deletions packages/canary-features/addon/default-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,8 @@ export default {
SAMPLE_FEATURE_FLAG: null,
RECORD_DATA_ERRORS: true,
RECORD_DATA_STATE: true,
IDENTIFIERS: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might want to keep these, in case someone was reading them and branching code off of it, removing them would break. Do you think there is a downside in not GCing them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only thought to commit these for clarity of the codebase. Certainly if someone was relying on a forked version of e-d, but is it something we expect users to read? And if they do, then it is expected they could be removed at any point? As long as we get the tests passing, I'm ok to do whatever you think is best 👍

REQUEST_SERVICE: true,
CUSTOM_MODEL_CLASS: true,
FULL_LINKS_ON_RELATIONSHIPS: true,
RECORD_ARRAY_MANAGER_IDENTIFIERS: true,
REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT: true,
};
2 changes: 0 additions & 2 deletions packages/canary-features/addon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ export const SAMPLE_FEATURE_FLAG = featureValue(FEATURES.SAMPLE_FEATURE_FLAG);
export const RECORD_DATA_ERRORS = featureValue(FEATURES.RECORD_DATA_ERRORS);
export const RECORD_DATA_STATE = featureValue(FEATURES.RECORD_DATA_STATE);
export const REQUEST_SERVICE = featureValue(FEATURES.REQUEST_SERVICE);
export const IDENTIFIERS = featureValue(FEATURES.IDENTIFIERS);
export const CUSTOM_MODEL_CLASS = featureValue(FEATURES.CUSTOM_MODEL_CLASS);
export const FULL_LINKS_ON_RELATIONSHIPS = featureValue(FEATURES.FULL_LINKS_ON_RELATIONSHIPS);
export const RECORD_ARRAY_MANAGER_IDENTIFIERS = featureValue(FEATURES.RECORD_ARRAY_MANAGER_IDENTIFIERS);
export const REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT = featureValue(
FEATURES.REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT
Expand Down