Conversation
| initial_count = all('.module-card').count | ||
|
|
||
| fill_in 'module_search', with: 'gcc' | ||
| sleep TOGGLE_WAIT |
There was a problem hiding this comment.
Instead of sleeping explicitly here, we should prefer searching for an element with assert_selector and passing the maximum wait time. That way if the actual wait time is less than TOGGLE_WAIT, the test continues as quickly as possible
There was a problem hiding this comment.
The way the search is implemented, it would be a bit tricky to use assert_selector here. The cards are hidden/shown dynamically and the only reason we have to sleep is because of the 300ms debounce.
I'm thinking it would be easier to either shorten the sleep to 0.3, or completely get rid of the debouncing since it's a bit redundant. Let me know what you think.
There was a problem hiding this comment.
That makes sense. As a rule, I think we should absolutely try to make the wait as short as we can while still having the tests pass.
IIRC another approach I have seen around here is to have filterModules produce a hidden element when it finishes, specifically so that we have something to set an assert_selector looking for. Of course that would require us to put off merging until 4.1 is released, but could be the best long term approach.
I wouldn't be opposed to removing the debounce, but would be a bit concerned about possible performance implications. If you have a massive number of modules to search through, and execute a search on every letter inputted, I could see how that could back up and run more slowly than if you debounce and get most/all of the search query after only two or three passes. I'd also be interested to hear @johrstrom's thoughts before we try removing it.
|
I was looking into this today, and realized that we can use the button classes to detect the opening/closing, and generated the following diff (which I can push if you like, instead of manually doing it). But this shaved off around 5s from testing the whole file (before your last commit). I will look to do something similar for the searching, though as I mentioned before I may have to modify the javascript to produce trigger elements. Of course you are welcome to take that if you prefer, but I am happy to finish this up since I have a good idea of what I want them to look like. |
Sounds good. Feel free to finish it up. |
Fixes #4971
Added test cases for the mod browser's core functionality, as well as a 'TOGGLE_WAIT' constant which will be used more thoroughly for #4929