-
Notifications
You must be signed in to change notification settings - Fork 5
WhatsApp form phase 2 #210
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
base: main
Are you sure you want to change the base?
Conversation
* fix: test case for wa form * fix: update test selectors for editing and publishing Whatsapp Forms * fix: refactor form definition to use constant for consistency in Whatsapp Forms tests --------- Co-authored-by: Akansha Sakhre <asakhre2002@gmail.com>
📝 WalkthroughWalkthroughThis PR updates the WhatsApp Forms Cypress test suite to align with backend API changes, including restructuring the form definition from a top-level JSON field to a revision object, renaming GraphQL list response fields, updating test selectors, and refactoring form creation/editing test flows. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
cypress/e2e/wa_forms/wa_form.spec.ts (3)
283-290:⚠️ Potential issue | 🟠 Major
cy.waitis placed before the confirmation click — likely wrong order.Here
cy.wait('@deactivateWhatsappForm')runs beforecy.get('[data-testid="ok-button"]').click(). If clicking the deactivate icon opens a confirmation dialog (as is typical and consistent with the publish test), the API call won't fire until the user confirms, meaningcy.waitwill time out.Compare with the publish test (lines 275-278) where the order is: click icon → click ok-button → wait for API. The deactivate and delete tests appear to have this reversed.
🐛 Proposed fix
it('should make a form inactive', () => { cy.get('[data-testid="deactivate-icon"]').eq(0).click(); - cy.wait('@deactivateWhatsappForm'); - cy.get('[data-testid="ok-button"]').click({ force: true }); + cy.wait('@deactivateWhatsappForm'); cy.get('div').should('contain', 'Form deactivated successfully'); });
299-306:⚠️ Potential issue | 🟠 MajorSame wait-before-confirm issue in the delete test.
Same problem as the deactivate test:
cy.wait('@deleteWhatsappForm')precedes the ok-button click. If deletion requires confirmation, reorder to match the publish test pattern.🐛 Proposed fix
it('should delete a Whatsapp Form', () => { cy.get('[data-testid="DeleteIcon"]').first().click(); - cy.wait('@deleteWhatsappForm'); - cy.get('[data-testid="ok-button"]').click({ force: true }); + cy.wait('@deleteWhatsappForm'); cy.get('div').should('contain', 'Form deleted successfully'); });
300-300:⚠️ Potential issue | 🟡 MinorChange
DeleteIcontodelete-iconfor consistency with other action icons in this file.Line 300 uses
DeleteIcon(PascalCase), while all other action icons inwa_form.spec.tsuse kebab-case:edit-icon(line 248),publish-icon(line 275),deactivate-icon(line 284), andactivate-icon(line 293). Additionally,delete-iconis used elsewhere in the codebase (e.g.,waPolls.spec.tsline 47).
🧹 Nitpick comments (2)
cypress/e2e/wa_forms/wa_form.spec.ts (2)
225-232: UnusedformJsonvariable — dead code.
formJsonis declared but never referenced in the test body. It appears to be a leftover from a previous version of this test that typed JSON directly into a form field.🧹 Proposed fix
it('should create a new Whatsapp Form', () => { - const formJson = { - type: 'form', - title: 'Sample Form', - fields: [ - { type: 'text', label: 'Name' }, - { type: 'email', label: 'Email' }, - ], - }; cy.get('[data-testid="newItemButton"]').click();
9-214: Consider consolidating intercepts into a single handler to reduce fragility.All eight
cy.intercept('POST', '**/api', ...)calls match the same URL pattern. Each one guards onoperationName, but if a request'soperationNamedoesn't match any guard, it silently falls through to the real server — which can cause flaky failures in CI. A single intercept with a switch/map onoperationNameis easier to maintain and makes unhandled operations explicit.♻️ Sketch
cy.intercept('POST', '**/api', (req) => { const handlers: Record<string, (req: any) => void> = { CreateWhatsappForm: (req) => req.reply({ ... }), listWhatsappForms: (req) => req.reply({ ... }), WhatsappForm: (req) => req.reply({ ... }), // ... other operations }; const handler = handlers[req.body.operationName]; if (handler) handler(req); // else: optionally fail or let it pass through }).as('graphql');
Whatsapp form phase 2
Summary by CodeRabbit