fix(select): revisit select - #66
Conversation
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
|
In looking at our Select test failures I've noticed two things:
See: https://docs.cypress.io/guides/references/assertions.html#Should-callback |
|
Nice find with the |
3d00479 to
b7c8870
Compare
Yeah I agree. I've added some assertions to do that in the tests here, though I'm sure they could be expanded upon. |
HendrikThePendric
left a comment
There was a problem hiding this comment.
I like most things in this PR but I also have some concerns reg. the test changes.
I like these parts of this PR:
- Switching to
shouldso cypress waits - Removing the
waitForResizeObserverhelper, which was a bit of a desperate attempt - Adding some mechanism to prevent
setMenuWidthfrom being called too often when the user resizes the window.
I don't really get the comment above the definition of setMenuWidth in the Select. On the one hand you are suggesting a change to requestAnimationFrame, but you have clearly opted for using setTimeout instead. You mention "the added complexity of solving this in another manner does not seem worth it". Are you referring to the added complexity of solving this using requestAnimationFrame? If so, could you explain why this would be so complex?
Another thing I'm wondering about, is the removal of the getAnchorAndMenuRects and the general implications this might/should have for the rest of the codebase. Switching to synchronous code in a should callback seems like a good move when looking at the cypress docs. But does this mean we should move to .should everywhere? I think we are using .then all over the place... I think there is technically nothing wrong with using .then when we are asserting things that happen synchronously, should probably only gives an advantage for asynchronous stuff. However, mixing .then and .should all over our codebase might get confusing/ is inconsistent. What do you think our approach should be regard this?
Anyway, the two points above are just questions, the code looks good, so I've approved.
Yeah actually, I'm mixing two different concepts in this comment:
A complete solution would mix the debounce, and requestPostAnimationFrame, that would be the most performant solution. But, requestPostAnimationFrame is just a proposal, so at the moment there's just a polyfill. We could use the polyfill, and it's rather small, but since usually people don't resize their viewport I omitted it. Seems like it's not worth the added complexity. I'll update the comment to make this all a bit more clear.
Yeah I would prefer using simpler (or no) helpers everywhere else as well. I'm trying to follow the recommendations outlined here: https://mtlynch.io/good-developers-bad-tests
What I tried in this PR is to move any assertions that were wrapped in a then, to a should. This is what cypress recommends in the docs as well: As they note, we should be aware that the callback in a So I'd say:
|
9af8707 to
fbf68e4
Compare
|
🎉 This PR is included in version 5.0.0-alpha.17 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 5.0.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |


closes #64 (does not address the CI setup btw., that needs to be split out)
Todo:
the top of the menu is aligned with the bottom of the inputNotes:
allhelper. That allows executing multiple cypress commands. This executes multiplegetcommands. Speaking of, I think we have a bit too many and too specific test helpers. I find it difficult to understand what happens in the tests at times because of them. I've refactored the tests slightly for the Selects to demonstrate an approach that uses a very basic testhelper (getAll), but other than that duplicates code instead of relying on a higher level test helper.shouldinstead of then, so cypress keeps retrying for a while.waitForResizeObserveras it was no longer necessary with cypress now waiting automatically.This should resolve all the flakiness we've been seeing with the select. I couldn't find any other potential issues.
Follow up: