Fix test to handle dynamic h1 text on formidableforms.com#2083
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2083 +/- ##
============================================
- Coverage 27.17% 27.17% -0.01%
- Complexity 8114 8116 +2
============================================
Files 127 127
Lines 26980 26984 +4
============================================
+ Hits 7332 7333 +1
- Misses 19648 19651 +3 ☔ View full report in Codecov by Sentry. |
WalkthroughThe pull request modifies the Cypress end-to-end tests for the Forms page, focusing on enhancing the validation of header data in the list view. It replaces a direct assertion for header text with a more flexible validation approach that checks against an array of acceptable texts. Additionally, the structure of the test cases is refined, particularly in encapsulating date validation logic, while maintaining the overall flow of the tests. Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
tests/cypress/e2e/Forms/formPageDataValidation.cy.js (1)
18-23: LGTM! The changes effectively handle dynamic h1 text.The implementation correctly uses cy.origin() for cross-origin navigation and makes the test more resilient by validating against multiple possible header texts.
Consider these maintainability improvements:
describe("Forms page", () => { const formidableFormsUpgradeUrl = 'https://formidableforms.com/lite-upgrade/?utm_source=WordPress&utm_medium=settings-license&utm_campaign=liteplugin&utm_content=lite-banner'; + const validHeaderTexts = [ + 'The Only WordPress Form Maker & Application Builder Plugin', + 'Upgrade Today to Unlock the Full Power of Formidable Forms' + ]; const origin = Cypress.config('baseUrl'); // ... it("should validate all data in list view", () => { // ... cy.origin('https://formidableforms.com', () => { cy.get('h1').then(($h1) => { const text = $h1.text(); - expect(['The Only WordPress Form Maker & Application Builder Plugin', 'Upgrade Today to Unlock the Full Power of Formidable Forms']).to.include(text); + expect(validHeaderTexts, `Expected h1 text "${text}" to be one of the valid options`).to.include(text); }); });Additionally, consider creating a custom command for this validation if it's used in multiple tests:
// In cypress/support/commands.js Cypress.Commands.add('validateFormidableHeader', (validTexts) => { cy.get('h1').then(($h1) => { const text = $h1.text(); expect(validTexts, `Expected h1 text "${text}" to be one of the valid options`).to.include(text); }); }); // In test file cy.origin('https://formidableforms.com', () => { cy.validateFormidableHeader(validHeaderTexts); });
|
@Crabcyborg The tests are now working fine. As you mentioned, the issue was due to a change on formidableforms.com that was causing the failure. Thank you! |
Crabcyborg
left a comment
There was a problem hiding this comment.
Thank you @lauramekaj1! This looks great!
🚀
No description provided.