Skip to content

Commit

Permalink
Added an api test for site menu items (#42708)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajputanuj31 authored Jan 25, 2024
1 parent d9a443b commit 609eafc
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/System/integration/api/com_menus/SiteMenuItems.cy.js
Original file line number Diff line number Diff line change
@@ -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}`));
});
});

0 comments on commit 609eafc

Please sign in to comment.