Skip to content
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

Fix failing test #207

Merged
merged 3 commits into from
Feb 2, 2024
Merged

Fix failing test #207

merged 3 commits into from
Feb 2, 2024

Conversation

circlecube
Copy link
Member

This updates a failing test so that it will pass. Update selector in test so only the expected button is returned.

While this should fix the test, I see some improvements that can be made to make the test more robust and less likely to fail in the future. Currently, the selector is getting two buttons and checking if the text matches the first. The changes the selector to only get the first button so when it checks the button text it will find a match.

Ideally, we should add a unique id attribute (or better yet, a data-cy attribute) to the elements on the components so that we can select them easily in the test. Here's more on this: https://docs.cypress.io/guides/references/best-practices#Selecting-Elements

In this case, we should probably just check that the button exists, since the text is translatable. We don't want to be locked into content for the test to pass.

To implement it all we'd add the data-cy attribute 'view-site' to the button in question and then

.find("a.nfd-button:first-child").should("have.text", "View your site")

Becomes

.find('a[data-cy="view-site"]).should("exist")

There are a lot of places this can be implemented to help the tests be more robust and reliable over time.

@circlecube circlecube requested review from wpscholar and a team January 31, 2024 20:57
@ramyakrishnai ramyakrishnai merged commit a1720e8 into trunk Feb 2, 2024
1 of 7 checks passed
@ramyakrishnai ramyakrishnai deleted the fix/home-commerce-home-page-test branch February 2, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants