Skip to content

Conversation

@priyanshu6238
Copy link
Contributor

@priyanshu6238 priyanshu6238 commented Feb 12, 2026

Whatsapp form phase 2

Summary by CodeRabbit

  • Bug Fixes
    • Refined WhatsApp form data structure and API response alignment.
    • Updated form action interactions (edit, publish, deactivate, activate, and view).

* 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>
@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Mock API Data & Selectors
cypress/e2e/wa_forms/wa_form.spec.ts
Introduces FORM_DEFINITION constant and restructures all mocked API responses to use revision.definition instead of top-level definition; renames listWhatsappForms to whatsappForms in GraphQL list responses; updates test-ID selectors for form actions (EditIcon→edit-icon, adds publish-icon/deactivate-icon/activate-icon/view-form).
Test Interaction Flows
cypress/e2e/wa_forms/wa_form.spec.ts
Removes direct JSON typing during form creation and editing; replaces with alternative UI-based form-building flow; removes validation-focused test block; adjusts create/edit/publish/deactivate/activate/view test flows to align with new API structure and revised selector paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #203: Modifies the same WhatsApp Forms test file with matching changes to GraphQL mock shapes (revision.definition) and test selectors (publish-icon, deactivate-icon, activate-icon).
  • PR #200: Updates the same Cypress test file with aligned GraphQL list field renaming (listWhatsappForms → whatsappForms) and test selector/flow adjustments for viewing and editing published forms.
  • PR #196: Modifies the same test suite with updates to WhatsApp Forms flows and mocked GraphQL/API intercepts across create/list/get/update/publish operations.

Suggested labels

Depend on FE pr

Suggested reviewers

  • shijithkjayan
  • AmishaBisht
  • akanshaaa19
  • mdshamoon

Poem

🐰 Forms reshape in revision's embrace,
Selectors dance in their rightful place,
Mock data flows through the test-defined way,
WhatsApp forms validated—hip, hip, hooray! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'WhatsApp form phase 2' is vague and generic, using a phase indicator without conveying specific details about what was changed or fixed in the changeset. Use a more descriptive title that specifies the main change, such as 'Update WhatsApp form test selectors and refactor form definition structure' or 'Fix WhatsApp form E2E tests with updated API response shape'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/whatsapp_form

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@priyanshu6238 priyanshu6238 changed the title WhatsApp form WhatsApp form phase 2 Feb 12, 2026
Copy link

@coderabbitai coderabbitai bot left a 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.wait is placed before the confirmation click — likely wrong order.

Here cy.wait('@deactivateWhatsappForm') runs before cy.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, meaning cy.wait will 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 | 🟠 Major

Same 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 | 🟡 Minor

Change DeleteIcon to delete-icon for consistency with other action icons in this file.

Line 300 uses DeleteIcon (PascalCase), while all other action icons in wa_form.spec.ts use kebab-case: edit-icon (line 248), publish-icon (line 275), deactivate-icon (line 284), and activate-icon (line 293). Additionally, delete-icon is used elsewhere in the codebase (e.g., waPolls.spec.ts line 47).

🧹 Nitpick comments (2)
cypress/e2e/wa_forms/wa_form.spec.ts (2)

225-232: Unused formJson variable — dead code.

formJson is 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 on operationName, but if a request's operationName doesn'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 on operationName is 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');

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.

1 participant