test: [M3-8395] - Fix Linode delete test flake by fixing deletion assertion#10999
Conversation
There was a problem hiding this comment.
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 👍 |
abailly-akamai
left a comment
There was a problem hiding this comment.
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.tsdeleting 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