Repository navigation
Stabilise List E2E tests - #17482
Stabilise List E2E tests#17482
Conversation
| MARK_AUTOMATIC_CHANGE( action, store ) { | ||
| const { | ||
| setTimeout, | ||
| requestIdleCallback = ( callback ) => setTimeout( callback, 100 ), |
|
Thanks for the review, @epiqueras! |
| if ( state !== 'final' ) { | ||
| return state; | ||
| } | ||
| } |
There was a problem hiding this comment.
- The function signature should be updated so the
@returntype moves from bool to string. The name should also be changed from thedid*boolean form. - When action type is
SELECTION_CHANGEbutstateis'final', the reducer will implicitly returnundefined. That value might be fine (though we might prefernull? no strong opinion here), but let's make it explicit by adding a fallback return statement.
There was a problem hiding this comment.
@mcsf What name would you suggest for the reducer? For any other action we also explicitly return undefined. Personally I like it to be undefined. I'm fine with adding an explicit return statement for the action we're handling.
There was a problem hiding this comment.
The name could be as plain as automaticChangeStatus, since that's a reflection of what it contains.
For any other action we also explicitly return
undefined.
undefined is fine with me, as long as explicit.
Meanwhile, this reducer is a bit particular. For most reducers, the default behaviour is to keep state unchanged. That is, unless the reducer receives a particular action that matters, we always return state in the end. This isn't the case with didAutomaticChange, though, because the default behaviour is now to reset to undefined. So I would add that as something explicit too:
switch ( … ) {
…
}
// Once we're no longer marking changes or changing selection, reset state.
return undefined;There was a problem hiding this comment.
To me, that was the beauty of of it. By default, a reducer resets any state to undefined, which we make use of here. Returning undefined explicitly here seems a bit strange to me (null sounds better then). A return statement returns undefined by default, so it could be omitted. A function returns undefined by default, so it could be omitted (returning nothing at the end of a function seems strange as well).
There was a problem hiding this comment.
We could still comment in the reducer though, that by default, we reset state instead of keeping state.
There was a problem hiding this comment.
As long as there's something that reveals intention, even if just a comment, that's what matters to me.
Description
This is an attempt to stabilise list E2E tests and improves marking automatic changes, which enables undo through
BackspaceandEscape.Looking back, it doesn't seem like a good idea to request an idle callback through
RichText, as the component will be unmounted after an automatic change. Instead, it's now an effect ofMARK_AUTOMATIC_CHANGEto make the marking "final". A problem with marking automatic changes is that there will be async selection changes from other effects, which should be ignored. They were ignored by usingrequestIdleCallback, so a change was only marked after everything had been completed. Instead of this, an automatic change will immediately be marked, but marked as "pending", during which time selection changes will not unmark it. During the first idle period, the change will be marked as "final", after which any selection changes will unmark the automatic change.How has this been tested?
Screenshots
Types of changes
Checklist: