cms/tests/System/integration/api/com_content/Articles.cy.js

48 lines
1.6 KiB
JavaScript

afterEach(() => {
cy.task('queryDB', 'DELETE FROM #__content');
});
describe('Test that content API endpoint', () => {
it('can deliver a list of articles', () => {
cy.db_createArticle({ title: 'automated test article' })
.then(() => cy.api_get('/content/articles'))
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
.its('title')
.should('include', 'automated test article'));
});
it('can create an article', () => {
cy.api_post('/content/articles', {
title: 'automated test article',
alias: 'test-article',
catid: 2,
introtext: '',
fulltext: '',
state: 1,
access: 1,
language: '*',
created: '2023-01-01 20:00:00',
modified: '2023-01-01 20:00:00',
images: '',
urls: '',
attribs: '',
metadesc: '',
metadata: '',
}).then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('title')
.should('include', 'automated test article'));
});
it('can update an article', () => {
cy.db_createArticle({ title: 'automated test article' })
.then((id) => cy.api_patch(`/content/articles/${id}`, { title: 'updated automated test article' }))
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('title')
.should('include', 'updated automated test article'));
});
it('can delete an article', () => {
cy.db_createArticle({ title: 'automated test article', state: -2 }).then((id) => cy.api_delete(`/content/articles/${id}`));
});
});