From 609eafcdf9cd726c73346242501affe1d543602d Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 25 Jan 2024 22:15:51 +0530 Subject: [PATCH] Added an api test for site menu items (#42708) --- .../api/com_menus/SiteMenuItems.cy.js | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/System/integration/api/com_menus/SiteMenuItems.cy.js diff --git a/tests/System/integration/api/com_menus/SiteMenuItems.cy.js b/tests/System/integration/api/com_menus/SiteMenuItems.cy.js new file mode 100644 index 00000000000..ada836d48ed --- /dev/null +++ b/tests/System/integration/api/com_menus/SiteMenuItems.cy.js @@ -0,0 +1,57 @@ +describe('Test that menu items site API endpoint', () => { + afterEach(() => cy.task('queryDB', "DELETE FROM #__menu WHERE title = 'automated test site menu item' ")); + + it('can deliver a list of site menu items types', () => { + cy.api_get('/menus/site/items/types') + .then((response) => cy.wrap(response).its('body').its('data.0').its('type') + .should('include', 'menutypes')); + }); + + it('can deliver a list of site menu items', () => { + cy.db_createMenuItem({ title: 'automated test site menu item' }) + .then(() => cy.api_get('/menus/site/items')) + .then((response) => cy.api_responseContains(response, 'title', 'automated test site menu item')); + }); + + it('can deliver a single site menu item', () => { + cy.db_createMenuItem({ title: 'automated test site menu item' }) + .then((id) => cy.api_get(`/menus/site/items/${id}`)) + .then((response) => cy.wrap(response).its('body').its('data').its('attributes') + .its('title') + .should('include', 'automated test site menu item')); + }); + + it('can create a site menu item', () => { + cy.api_post('/menus/site/items', { + title: 'automated test site menu item', + menutype: 'main-menu', + access: '1', + parent_id: '1', + publish_down: '', + publish_up: '', + published: '1', + template_style_id: '0', + toggle_modules_assigned: '1', + toggle_modules_published: '1', + type: 'component', + alias: '', + link: '', + }) + .then((response) => cy.wrap(response).its('body').its('data').its('attributes') + .its('title') + .should('include', 'automated test site menu item')); + }); + + it('can update a site menu item', () => { + cy.db_createMenuItem({ title: 'automated test site menu item', type: 'component' }) + .then((id) => cy.api_patch(`/menus/site/items/${id}`, { title: 'updated automated test site menu item', type: 'component' })) + .then((response) => cy.wrap(response).its('body').its('data').its('attributes') + .its('title') + .should('include', 'updated automated test site menu item')); + }); + + it('can delete a site menu item', () => { + cy.db_createMenuItem({ title: 'automated test site menu item', published: -2 }) + .then((id) => cy.api_delete(`/menus/site/items/${id}`)); + }); +});