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 430, support ember-source 3.13 #460

Closed
wants to merge 4 commits into from
Closed

fix 430, support ember-source 3.13 #460

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 15, 2019

This PR fixes #430 and adds support for ember-source@3.13.x.
See #450 for the background conversation and root cause analysis (thanks to @simonihmig 😄 ).

I do a couple things here.

  1. add a failing case for Setting same properties name causing tests fail #430, (Try to recreate problem with properties in unit tests #431)
  2. refactored the state removal logic to be more explict and only clean up keys that a user has set. While debugging I found it somewhat confusing we were cleaning up all properties on the test context. e.g. set, get, and others. I changed it to only tear down user defined keys and owner.
  3. We need to change the main property clean up to this.set('someKey', null). This properly delegates the setter behavior for the tracked property logic of ember-source >= 3.13

Change 2 is optional so I can rebase with only 1 and 3 if is preferred.

Fix 430.
We need to explicitly delete user set keys on the `this` context.
The prior approach tried to rebuild the entire `this` object. That
caused problems with Ember 3.13 and up because of some changes for
tracked properties. This approach infers user defined keys and deletes those and a known list.
Using this.set('myKey', null) instead of delete this['myKey'] properly delegates setter logic so we keep tests isolated.
@kevinansfield
Copy link

👍 tested and confirmed working for me 🎉 Looks like the only tests still failing in our test suite now are more directly related to 3.13

@Turbo87
Copy link
Member

Turbo87 commented Oct 16, 2019

that's good news. thanks for testing @kevinansfield!

@ghost
Copy link
Author

ghost commented Oct 17, 2019

I found this actually breaks when you use this.name = 'something' in subsequent tests. @kobsy's work in #461 accounts for that but takes a slightly different approach to establish an entirely new testing context.

@kevinansfield
Copy link

Hmm, I think I was too quick to assume our remaining failing tests were 3.13 related. It appears the problem is properties set on this persisting to the next test. Code that's failing...

it('triggers multiple uploads', async function () {
    await render(hbs`{{#gh-uploader files=files}}{{/gh-uploader}}`);
    this.set('files', [createFile(), createFile(), createFile()]);
    await settled();

    expect(server.handledRequests.length).to.equal(3);

});

it('triggers onStart when upload starts', async function () {
    this.set('uploadStarted', sinon.spy());
    await render(hbs`{{#gh-uploader files=files onStart=(action uploadStarted)}}{{/gh-uploader}}`);
    this.set('files', [createFile(), createFile()]);
    await settled();

    expect(this.get('uploadStarted').calledOnce).to.be.true;
});

The second test is failing because didReceiveAttrs is firing twice on the component as expected but the first time it's called the files value on the component is the same as the first test.

Re-checked 3.12 to make sure and files is undefined the first time didReceiveAttrs is called.

@kevinansfield
Copy link

Tested against #462 and that one is fully working 👍

@ghost
Copy link
Author

ghost commented Oct 21, 2019

Closing this PR as well because it doesn't fully resolve the issue. #462 does so because it uses the corresponding teardown method from Ember's tracked properties. There are questions to address there and feedback on a possible public API to do this.

@ghost ghost closed this Oct 21, 2019
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting same properties name causing tests fail
3 participants