|
| 1 | +describe('Test that field contact API endpoint', () => { |
| 2 | + afterEach(() => cy.task('queryDB', 'DELETE FROM #__fields')); |
| 3 | + |
| 4 | + it('can deliver a list of fields', () => { |
| 5 | + cy.db_createField({ title: 'automated test field', context: 'com_contact.contact' }) |
| 6 | + .then(() => cy.api_get('/fields/contacts/contact')) |
| 7 | + .then((response) => cy.wrap(response).its('body').its('data.0').its('attributes') |
| 8 | + .its('title') |
| 9 | + .should('include', 'automated test field')); |
| 10 | + }); |
| 11 | + |
| 12 | + it('can create a field', () => { |
| 13 | + cy.api_post('/fields/contacts/contact', { |
| 14 | + title: 'automated test field', |
| 15 | + access: 1, |
| 16 | + context: 'com_contact.contact', |
| 17 | + default_value: '', |
| 18 | + description: '', |
| 19 | + group_id: 0, |
| 20 | + label: 'contact field', |
| 21 | + language: '*', |
| 22 | + name: 'contact-field', |
| 23 | + note: '', |
| 24 | + params: { |
| 25 | + class: '', |
| 26 | + display: '2', |
| 27 | + display_readonly: '2', |
| 28 | + hint: '', |
| 29 | + label_class: '', |
| 30 | + label_render_class: '', |
| 31 | + layout: '', |
| 32 | + prefix: '', |
| 33 | + render_class: '', |
| 34 | + show_on: '', |
| 35 | + showlabel: '1', |
| 36 | + suffix: '', |
| 37 | + }, |
| 38 | + required: 0, |
| 39 | + state: 1, |
| 40 | + type: 'text', |
| 41 | + }) |
| 42 | + .then((response) => cy.wrap(response).its('body').its('data').its('attributes') |
| 43 | + .its('title') |
| 44 | + .should('include', 'automated test field')); |
| 45 | + }); |
| 46 | + |
| 47 | + it('can update a field', () => { |
| 48 | + cy.db_createField({ title: 'automated test field', context: 'com_contact.contact' }) |
| 49 | + .then((id) => cy.api_patch(`/fields/contacts/contact/${id}`, { title: 'updated automated test field' })) |
| 50 | + .then((response) => cy.wrap(response).its('body').its('data').its('attributes') |
| 51 | + .its('title') |
| 52 | + .should('include', 'updated automated test field')); |
| 53 | + }); |
| 54 | + |
| 55 | + it('can delete a field', () => { |
| 56 | + cy.db_createField({ title: 'automated test field', state: -2 }) |
| 57 | + .then((id) => cy.api_delete(`/fields/contacts/contact/${id}`)); |
| 58 | + }); |
| 59 | +}); |
0 commit comments