29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-30 17:13:41 +00:00

system test com_templates webservices (#41695)

* sitestyles

* adminstyle
This commit is contained in:
Nicola Galgano 2023-09-11 15:50:23 +02:00 committed by GitHub
parent a75867224d
commit b3f5c9fe0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 71 additions and 1 deletions

View File

@ -88,7 +88,7 @@ class StylesController extends ApiController
// If we are updating an item the template is a readonly property based on the ID
if ($this->input->getMethod() === 'PATCH') {
if (\array_key_exists('template', $data)) {
throw new InvalidParameterException('The template property cannot be modified for an existing style');
unset($data['template']);
}
$model = $this->getModel(Inflector::singularize($this->contentType), '', ['ignore_request' => true]);

View File

@ -0,0 +1,35 @@
describe('Test that templates administrator styles API endpoint', () => {
it('can deliver a list of templates administrator styles', () => {
cy.api_get('/templates/styles/administrator')
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
.its('template')
.should('include', 'atum'));
});
it('can deliver a single templates administrator style', () => {
cy.api_get('/templates/styles/administrator')
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
.its('id'))
.then((id) => {
cy.api_get(`/templates/styles/administrator/${id}`)
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('template')
.should('include', 'atum'));
});
});
it('can modify a single template administrator style', () => {
cy.api_get('/templates/styles/administrator')
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
.its('id'))
.then((id) => {
const updatedStyle = {
title: 'automated test template administrator style',
};
cy.api_patch(`/templates/styles/administrator/${id}`, updatedStyle)
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('title')
.should('equal', 'automated test template administrator style'));
});
});
});

View File

@ -0,0 +1,35 @@
describe('Test that templates API endpoint', () => {
it('can deliver a list of templates', () => {
cy.api_get('/templates/styles/site')
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
.its('template')
.should('include', 'cassiopeia'));
});
it('can deliver a single template', () => {
cy.api_get('/templates/styles/site')
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
.its('id'))
.then((id) => {
cy.api_get(`/templates/styles/site/${id}`)
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('template')
.should('include', 'cassiopeia'));
});
});
it('can modify a single template', () => {
cy.api_get('/templates/styles/site')
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
.its('id'))
.then((id) => {
const updatedStyle = {
title: 'automated test template site style',
};
cy.api_patch(`/templates/styles/site/${id}`, updatedStyle)
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('title')
.should('equal', 'automated test template site style'));
});
});
});