-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: [M3-8395] - Fix Linode delete test flake by fixing deletion assertion #10999
test: [M3-8395] - Fix Linode delete test flake by fixing deletion assertion #10999
Conversation
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.
Thank you @jdamore-linode for continuing to improve the reliability of our test suite! 🙌🏽
Tested and passed 50x locally:
I'm almost tempted not to ruin the perfect but should we add a changeset?
Coverage Report: ✅ |
Thanks for the interesting context! I wonder if it would be good to document this somewhere? |
Pushed the changeset! And the nice tidy +1/-1 diff can be forever memorialized in your comment 😀 Edit: And yes! This should definitely be documented, although it's not clear to me if this is a bug in Cypress or Testing Library of if it's the expected behavior. I can make sure that gets included in the docs improvements that I'm already working on 👍 |
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.
Thanks for the details explanation!
One less flaky test, confirmed things passing consistently on my end ✅
Description 📝
This PR attempts to address or improve the test flakiness we've been seeing in
smoke-delete-linode.spec.ts
deleting multiple linodes with action menu
.What initially caused this test to become flaky is still unclear, but the majority of the failures I've observed follow this sequence of events:
We had an assertion that was intended to make Cypress wait for the landing page to refresh before proceeding with the second deletion:
However, I was observing that frequently Cypress would proceed with the test even while the initial Linode was still present in the landing page. My understanding is that this is the result of a strange interaction between Testing Library (which provides the
findByText()
command and similar commands) and Cypress (which provides theshould('not.exist')
assertion and others).When calling
cy.findByText()
with an element that appears more than once on-screen, the command normally fails with an error explaining that multiple items were matched. When using theshould('not.exist')
assertion, however, Cypress appears to interpret this state (that multiple elements exist) as equivalent to there being no elements, causing the assertion to succeed before it's expected to -- perhaps this is a result of some naive logic whereshould('not.exist')
treats any command/element selection error as equivalent to being unable to find/select any element.Minimal reproduction:
In the case of this test, the Linode label being searched for appears twice on screen: once in the deletion modal dialog which is still present in the DOM when the assertion executes, and again in the landing page table itself.
This could have been fixed in a few ways (narrowing our selection to the Linode landing page table before asserting that the label doesn't exist would've been one alternative), but in this case I opted to fix it by using
cy.findAllByText(...)
instead ofcy.findByText(...)
.Changes 🔄
cy.findAllByText()
instead ofcy.findByText()
Target release date 🗓️
N/A
How to test 🧪
Check out this branch, run
yarn && yarn build && yarn start:manager:ci
, and then run the test a few times to gain confidence that it's stable:yarn cy:run -s "cypress/e2e/core/linodes/smoke-delete-linode.spec.ts"
(I ran the test locally in isolation and it passed 50/50 times, then I ran the entire spec and it passed 10/10 times)
As an Author I have considered 🤔
Check all that apply