Custom tooltip assertion on disabled elements && GREATLY improve assertion times#643
Open
Custom tooltip assertion on disabled elements && GREATLY improve assertion times#643
Conversation
…improve assertion time
aprentout
approved these changes
Feb 16, 2026
Elodie-DeMatteis-Upf
approved these changes
Feb 16, 2026
Contributor
Elodie-DeMatteis-Upf
left a comment
There was a problem hiding this comment.
LGTM: so nice!
Comment on lines
10
to
18
| const element = document.querySelector(selector) as HTMLElement; | ||
| const clock = sinon.useFakeTimers(); | ||
|
|
||
| if (element?.hasAttribute('disabled')) { | ||
| element.dispatchEvent(new Event(trigger || 'mouseover', { bubbles: true })); | ||
| } else { | ||
| await triggerEvent(selector, trigger || 'mouseover'); | ||
| } | ||
|
|
There was a problem hiding this comment.
suggestion:
- You might want to wrap this block in a try / catch because if
dispatchEventortriggerEventfails, you might get a memory leak from sinon's fake timer (same with L. 57). - Typecasting might be "dangerous". If the element is
null, what should we do? Try to trigger an event (triggerEvent) with a selector we know is not found?
Member
Author
There was a problem hiding this comment.
1- wrapped in try/finally
2- IMO we don't need anything specific here ; these are to be used within tests - if something breaks during tests, then the developer needs to adjust their code to pass :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Introduces a couple of updates to the custom tooltip assertions:
It is now possible to use the custom tooltip assertions (
await asser.tooltip('selector').exists()) on disabled elementsThe previous implementation was raising errors when we tried to do so, telling us that
triggerEventfrom ember TestHelpers cannot be triggered on a disabled element. To bypass this, in the logic, we now check if the target element has a disabled attribute. If it's the case, we now use a regular, JS based,element.dispatchEventto trigger the mouseover event. If not disabled, we keep usingtriggerEventfrom the test-helpers (mainly for safety, prevent breaking changes).ASSERTION TIMES HAVE !!!! GREATLY !!!! been improved :
Thanks to a suggestion from @aprentout to use Sinon's fake timers to bypass the animation & rendering delays.
Running a tooltip assertion is now divided by 7! From ~350ms to ~50ms per test.
Old test times:

Newt test times:

ℹ️
Tests have been added in the
enable-tooltipmodifier to check the "disabled" state for lack of a better place 😇Good PR checklist