Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 18 additions & 27 deletions cypress/e2e/wa_forms/wa_form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
},
{
Expand All @@ -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',
Expand All @@ -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"}]}]}}]}',
},
},
],
},
Expand All @@ -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',
Expand Down Expand Up @@ -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', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want this test? Are we not validating the json anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, in the new form builder, we have removed the JSON option from the Create WhatsApp Form page.

Image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So where do we create the form json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After publishing the form, we are redirected to the configuration page, where we create the form and then publish it.

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',
Expand All @@ -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);

Expand Down Expand Up @@ -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');
Expand Down
Loading