Skip to content

Commit

Permalink
Cypress test for adding field in contact form in com_contact (#40186)
Browse files Browse the repository at this point in the history
* add test for field com_contact

* updates

* changes

* changes

* updates

* updates

* adding more default values

* updates

* updates

* Update db.js

---------

Co-authored-by: Allon Moritz <allon.moritz@digital-peak.com>
  • Loading branch information
rajputanuj31 and laoneo authored Mar 28, 2023
1 parent 7d28502 commit 245ff34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/System/integration/site/components/com_contact/Contact.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,20 @@ describe('Test that the Contact Form', () => {
cy.get('.m-0').should('exist');
});
});

it('can display an added field', () => {
cy.db_createFieldGroup({ title: 'automated test_field group', context: 'com_contact.mail' })
.then((id) => cy.db_createField({
group_id: id, context: 'com_contact.mail', type: 'checkboxes', fieldparams: JSON.stringify({ options: { options0: { name: 'test value', value: '' } } }),
}))
.then(() => cy.db_getUserId())
.then((userId) => cy.db_createContact({ name: 'automated test contact 1', user_id: userId }))
.then((contactId) => {
cy.visit(`index.php?option=com_contact&view=contact&id='${contactId}'`);

cy.contains('automated test_field group').should('exist');
cy.contains('test field').should('exist');
cy.contains('test value').should('exist');
});
});
});
1 change: 1 addition & 0 deletions tests/System/support/commands/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Cypress.Commands.add('db_createFieldGroup', (fieldGroup) => {
access: 1,
created: '2023-01-01 20:00:00',
modified: '2023-01-01 20:00:00',
params: '',
};

return cy.task('queryDB', createInsertQuery('fields_groups', { ...defaultFieldGroupOptions, ...fieldGroup })).then(async (info) => info.insertId);
Expand Down

0 comments on commit 245ff34

Please sign in to comment.