forked from joomla/joomla-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArticles.cy.js
More file actions
73 lines (69 loc) · 2.93 KB
/
Articles.cy.js
File metadata and controls
73 lines (69 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
describe('Test that content API endpoint', () => {
afterEach(() => cy.task('queryDB', 'DELETE FROM #__content'));
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 deliver a single article', () => {
cy.db_createArticle({ title: 'automated test article' })
.then((article) => cy.api_get(`/content/articles/${article.id}`))
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('title')
.should('include', 'automated test article'));
});
it('keeps core article images when a custom field is named images', () => {
cy.db_createField({
title: 'images field',
name: 'images',
label: 'images',
context: 'com_content.article',
required: 0,
})
.then(() => cy.db_createArticle({
title: 'automated test article with images',
images: '{"image_intro":"images/sampledata/cassiopeia/images/headers/flowers.jpg","image_intro_alt":"","float_intro":"","image_intro_caption":"","image_fulltext":"images/sampledata/cassiopeia/images/headers/flowers.jpg","image_fulltext_alt":"","float_fulltext":"","image_fulltext_caption":""}',
}))
.then((article) => cy.api_get(`/content/articles/${article.id}`))
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('images')
.its('image_intro')
.should('include', 'flowers.jpg'));
});
it('can create an article', () => {
cy.db_createCategory({ extension: 'com_content' })
.then((categoryId) => cy.api_post('/content/articles', {
title: 'automated test article',
alias: 'test-article',
catid: categoryId,
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((article) => cy.api_patch(`/content/articles/${article.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((article) => cy.api_delete(`/content/articles/${article.id}`));
});
});