Unification of executeAction between ActionContext and MockActionContext#374
Unification of executeAction between ActionContext and MockActionContext#374
Conversation
… mimick real executeAction
|
By analyzing the blame information on this pull request, we identified @localnerve, @cesarandreu and @Vijar to be potential reviewers |
|
CLA is valid! |
|
I'd be fine with option 1, but IMHO, if you really don't want to introduce an unexpected breaking change then you have to go with 2 (or 3). |
|
I have published a new version under the If you see a |
|
Dropped in 1.0.4-rc1 in two of my example projects, flux-react-example (156 tests) and flux-react-example-sw (344 tests). Test suites ran perfectly with no changes required. Double checked that the fluxible package.json actually reflected 1.0.4-rc1 in both. Please note that the code delivered with 1.0.4-rc1 was not the same as the commit with this PR. For example, line 33, fluxible/utils/MockActionContext.js: return callAction.callActionNoImmediate(this, action, payload, callback); |
|
Good catch. Forgot that I had an experimental branch checked out. I published 1.0.4-rc2 with the code from this PR. |
|
Yep, now I have the right code, 1.0.4-rc2. Worked on both example projects as drop-in replacement, no change required. |
|
Alright, so since this change seems to have limited impact and only when the tests are written to expect parallel |
|
Created https://gist.github.com/mridgway/4d66eb1d3277d8b442f2 as an overview for the changes and possible impacts. |
Unification of executeAction between ActionContext and MockActionContext
This is a potentially breaking change that I want to be careful about.
Problem
Given the example:
MockActionContext.executeActioncurrently returns the return value of the action:'foo' == mockActionContext.executeAction(fooAction).FluxibleContext.executeActionreturns aPromisethat would be resolved with the value 'foo'.The problem with this is that if there are nested
executeActioncalls, then the parent action will not receive aPromiseas it would expect:This causes significant problems in testing a code base that is mixed with actions that use Promises and callbacks, which is supported by FluxibleContext, but not MockActionContext.
Solution
The solution is to ensure that they are using the same implementation. In this PR I have made both contexts use the same implementation.
Breaking Change or Bug?
I could easily mark this as a bug, since it presents an inconsistency which makes it impossible to test certain cases. The issue however, is that there will be many tests out there that may be affected by this change:
executeActionto match the action's return value.executeAction.setImmediate. Any tests that rely on the order of parallel actions (which you could argue is unsafe) could be broken.We found a few tests (5 out of 301 tests) in one internal package that were affected due to the second item. We never relied on the first, but others in the community may be.
Options
MockActionContextAPI (what would we even name it?) and release as minor version or a separate package. Current MockActionContext would be deprecated in 2.x. This minimizes the breakage but would still eventually require a migration when 2.x is released.Request for Input
I would love to get the community's input on this. I'm also curious how many people are affected by these issues.
Please try installing
fluxible@testin your project and run your test suite. Please report any breakages that you see.Assuming the impact is minimal, we will go ahead with releasing this as a bug fix that gets released as
1.0.4.