-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix Find/Replace unit tests and clean up event handling for animations #5213
Conversation
…r use in unit tests
…really UI integration tests (and rely on the real Brackets CSS)
Oops, I left some comments on the last commit instead of in the Files tab. |
self._removeInlineWidgetInternal(inlineWidget); | ||
deferred.resolve(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the number of times this pattern of code is repeated (and number of times I imagine that it will be repeated in the future), it seems like it deserves a utility function. Parameters would be:
- current element (
e.target
) - target element (
inlineWidget.$htmlContent
) - class to remove (
animating
) - deferred to resolve (
deferred
) - catchall callback:
self._codeMirror.removeLineWidget(inlineWidget.info);
self._removeInlineWidgetInternal(inlineWidget);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I didn't end up passing all these things in--instead, I just had the utility function return its own promise, and then did the custom processing for each case in the done()
handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Done with review. |
@@ -1264,9 +1262,15 @@ define(function (require, exports, module) { | |||
} | |||
|
|||
function setOuterHeight() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I didn't use AnimationUtils.animateUsingClass()
here since in this case the class is being handled separately. It didn't seem worth generalizing that function to handle this case as well.
Ready for re-review. |
Merging. |
Fix Find/Replace unit tests and clean up event handling for animations
For #5094. See my last comment in that bug for more background on why the unit tests were only intermittently failing.
It might be worth reviewing each commit separately since they're all semantically independent (except for the last one, which requires the first three), although I think they're all worth fixing in the course of dealing with the unit tests. Here's a summary of each one:
webkitAnimationEnd
, we weren't checking that the target of the event was actually the item we're listening to (because I didn't know that that event bubbles). This commit fixes that. (It unfortunately means we can't just use$.one()
anymore because we only want to disconnect the event handler when we get the right target.) By itself, this would make it so that the existing Find/Replace tests would consistently fail (as they should have been, see (4) below), instead of only intermittently failing.FILE_CLOSE
so that we can force a document to close even if it has dirty changes. This is useful for unit tests in a test window where we want to be able to manipulate a document but discard any changes we make before the next test.Note that the new tests basically create a single window, and then repeatedly create new untitled documents to run the tests in. That's why I wanted to make the fixes in (2) and (3), and also changed one of the tests (which was assuming the file was color-coded). For that last issue, I could have just saved a JS file and tested against that, but it actually seemed cleaner to me to not have the tests depend on a particular color-coding.