|
| 1 | +describe('Test that menu items administrator API endpoint', () => { |
| 2 | + afterEach(() => cy.task('queryDB', "DELETE FROM #__menu WHERE title = 'automated test administrator menu item' ")); |
| 3 | + |
| 4 | + it('can deliver a list of administrator menu items types', () => { |
| 5 | + cy.api_get('/menus/administrator/items/types') |
| 6 | + .then((response) => cy.wrap(response).its('body').its('data.0').its('type') |
| 7 | + .should('include', 'menutypes')); |
| 8 | + }); |
| 9 | + |
| 10 | + it('can deliver a list of administrator menu items', () => { |
| 11 | + cy.db_createMenuItem({ title: 'automated test administrator menu item', client_id: 1 }) |
| 12 | + .then(() => cy.api_get('/menus/administrator/items')) |
| 13 | + .then((response) => cy.api_responseContains(response, 'title', 'automated test administrator menu item')); |
| 14 | + }); |
| 15 | + |
| 16 | + it('can deliver a single administrator menu item', () => { |
| 17 | + cy.db_createMenuItem({ title: 'automated test administrator menu item', client_id: 1 }) |
| 18 | + .then((id) => cy.api_get(`/menus/administrator/items/${id}`)) |
| 19 | + .then((response) => cy.wrap(response).its('body').its('data').its('attributes') |
| 20 | + .its('title') |
| 21 | + .should('include', 'automated test administrator menu item')); |
| 22 | + }); |
| 23 | + |
| 24 | + it('can create an administrator menu item', () => { |
| 25 | + cy.api_post('/menus/administrator/items', { |
| 26 | + title: 'automated test administrator menu item', |
| 27 | + menutype: 'main-menu', |
| 28 | + access: '1', |
| 29 | + parent_id: '1', |
| 30 | + client_id: 1, |
| 31 | + publish_down: '', |
| 32 | + publish_up: '', |
| 33 | + published: '1', |
| 34 | + template_style_id: '0', |
| 35 | + toggle_modules_assigned: '1', |
| 36 | + toggle_modules_published: '1', |
| 37 | + type: 'component', |
| 38 | + alias: '', |
| 39 | + link: '', |
| 40 | + }) |
| 41 | + .then((response) => cy.wrap(response).its('body').its('data').its('attributes') |
| 42 | + .its('title') |
| 43 | + .should('include', 'automated test administrator menu item')); |
| 44 | + }); |
| 45 | + |
| 46 | + it('can update an administrator menu item', () => { |
| 47 | + cy.db_createMenuItem({ title: 'automated test administrator menu item', type: 'component', client_id: 1 }) |
| 48 | + .then((id) => cy.api_patch(`/menus/administrator/items/${id}`, { title: 'updated automated test administrator menu item', type: 'component' })) |
| 49 | + .then((response) => cy.wrap(response).its('body').its('data').its('attributes') |
| 50 | + .its('title') |
| 51 | + .should('include', 'updated automated test administrator menu item')); |
| 52 | + }); |
| 53 | + |
| 54 | + it('can delete an administrator menu item', () => { |
| 55 | + cy.db_createMenuItem({ title: 'automated test administrator menu item', published: -2, client_id: 1 }) |
| 56 | + .then((id) => cy.api_delete(`/menus/administrator/items/${id}`)); |
| 57 | + }); |
| 58 | +}); |
0 commit comments