From 467d6044fe56f3cc52a5d0cd894b6b774ddd761b Mon Sep 17 00:00:00 2001 From: priyanshu6238 Date: Sun, 18 Jan 2026 19:36:20 +0530 Subject: [PATCH] fix: test case for wa form --- cypress/e2e/wa_forms/wa_form.spec.ts | 45 +++++++++++----------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/cypress/e2e/wa_forms/wa_form.spec.ts b/cypress/e2e/wa_forms/wa_form.spec.ts index 61c2a56..069146d 100644 --- a/cypress/e2e/wa_forms/wa_form.spec.ts +++ b/cypress/e2e/wa_forms/wa_form.spec.ts @@ -31,13 +31,17 @@ describe('Whatsapp Forms', () => { statusCode: 200, body: { data: { - listWhatsappForms: [ + whatsappForms: [ { __typename: 'WhatsappForm', id: '1', name: 'first form', description: 'first form description', status: 'DRAFT', + revision: { + definition: + '{"version":"7.2","screens":[{"title":"Page 1 of 2","layout":{"type":"SingleColumnLayout","children":[{"type":"Form","name":"flow_path","children":[{"type":"TextSubheading","text":"Sample form"}]}]}}]}', + }, categories: ['other'], }, { @@ -47,6 +51,10 @@ describe('Whatsapp Forms', () => { description: 'second form description', status: 'PUBLISHED', categories: ['lead_generation'], + revision: { + definition: + '{"version":"7.2","screens":[{"title":"Page 1 of 2","layout":{"type":"SingleColumnLayout","children":[{"type":"Form","name":"flow_path","children":[{"type":"TextSubheading","text":"Sample form"}]}]}}]}', + }, }, { __typename: 'WhatsappForm', @@ -55,6 +63,10 @@ describe('Whatsapp Forms', () => { description: 'third form description', status: 'INACTIVE', categories: ['lead_generation'], + revision: { + definition: + '{"version":"7.2","screens":[{"title":"Page 1 of 2","layout":{"type":"SingleColumnLayout","children":[{"type":"Form","name":"flow_path","children":[{"type":"TextSubheading","text":"Sample form"}]}]}}]}', + }, }, ], }, @@ -79,8 +91,10 @@ describe('Whatsapp Forms', () => { id: req.body.variables.id, name: 'first form', description: 'first form description', - definition: - '{"version":"7.2","screens":[{"title":"Page 1 of 2","layout":{"type":"SingleColumnLayout","children":[{"type":"Form","name":"flow_path","children":[{"type":"TextSubheading","text":"Sample form"}]}]}}]}', + revision: { + definition: + '{"version":"7.2","screens":[{"title":"Page 1 of 2","layout":{"type":"SingleColumnLayout","children":[{"type":"Form","name":"flow_path","children":[{"type":"TextSubheading","text":"Sample form"}]}]}}]}', + }, categories: ['survey'], status: status, metaFlowId: '869324785433064', @@ -208,25 +222,6 @@ describe('Whatsapp Forms', () => { cy.get('[data-testid="listHeader"]').should('contain', 'WhatsApp Forms'); }); - it('should show all validation errors while creating a form', () => { - cy.get('[data-testid="newItemButton"]').click(); - - cy.get('[data-testid="submitActionButton"]').click({ force: true }); - - cy.get('p').should('contain', 'Title is required'); - cy.get('p').should('contain', 'Form JSON is required'); - - cy.get('input[name=name]').first().type('Test Form'); - - cy.get('textarea[name=formJson]').first().type('Invalid JSON'); - - cy.get('[data-testid="submitActionButton"]').click({ force: true }); - - cy.get('p').should('contain', 'Must be valid JSON'); - - cy.get('[data-testid="cancelActionButton"]').click(); - }); - it('should create a new Whatsapp Form', () => { const formJson = { type: 'form', @@ -240,10 +235,6 @@ describe('Whatsapp Forms', () => { cy.get('input[name=name]').first().type('Title for Whatsapp Form'); cy.get('textarea[name=description]').first().type('This is a description for Whatsapp Form.\n'); - cy.get('textarea[name=formJson]') - .first() - .type(JSON.stringify(formJson), { parseSpecialCharSequences: false }); - cy.get('[data-testid="AutocompleteInput"]').eq(0).click().wait(500); cy.get('.MuiAutocomplete-option').eq(0).click().wait(500); @@ -273,7 +264,7 @@ describe('Whatsapp Forms', () => { }); it('published flows should be read-only', () => { - cy.get('[data-testid="EditIcon"]').eq(1).click(); + cy.contains('second form').closest('tr').find('[data-testid="view-form"]').click(); cy.wait('@getWhatsappForm'); cy.get('input[name=name]').should('be.disabled');