-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an api test for site menu items (#42708)
- Loading branch information
1 parent
d9a443b
commit 609eafc
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
tests/System/integration/api/com_menus/SiteMenuItems.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`)); | ||
}); | ||
}); |