Skip to content

Commit 0d90fd1

Browse files
committed
prepare for webservices testings
1 parent 4106a19 commit 0d90fd1

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

cypress.config.dist.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default defineConfig({
77
screenshotsFolder: 'tests/cypress/output/screenshots',
88
viewportHeight: 1000,
99
viewportWidth: 1200,
10-
e2e: {
10+
e2e: {
1111
setupNodeEvents(on, config) {
1212
setupPlugins(on, config);
1313
},
@@ -16,6 +16,7 @@ export default defineConfig({
1616
'tests/cypress/integration/install/*.cy.{js,jsx,ts,tsx}',
1717
'tests/cypress/integration/administrator/**/*.cy.{js,jsx,ts,tsx}',
1818
'tests/cypress/integration/site/**/*.cy.{js,jsx,ts,tsx}',
19+
'tests/cypress/integration/api/**/*.cy.{js,jsx,ts,tsx}',
1920
'tests/cypress/integration/plugins/**/*.cy.{js,jsx,ts,tsx}',
2021
],
2122
supportFile: 'tests/cypress/support/index.js',
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
describe('Test that weblinks API endpoint', () => {
2+
afterEach(() => cy.task('queryDB', 'DELETE FROM #__weblinks WHERE title LIKE "%automated test weblink%"'));
3+
4+
it('can deliver a list of weblinks', () => {
5+
cy.db_createWeblink({ title: 'automated test weblink' })
6+
.then(() => cy.api_get('/weblinks'))
7+
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
8+
.its('title')
9+
.should('include', 'automated test weblink'));
10+
});
11+
12+
it('can deliver a single weblink', () => {
13+
cy.db_createWeblink({ title: 'automated test weblink' })
14+
.then((weblink) => cy.api_get(`/weblinks/${weblink.id}`))
15+
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
16+
.its('title')
17+
.should('include', 'automated test weblink'));
18+
});
19+
20+
it('can create a weblink', () => {
21+
cy.db_createCategory({ extension: 'com_weblinks' })
22+
.then((categoryId) => cy.api_post('/weblinks', {
23+
title: 'automated test weblink',
24+
alias: 'test-weblink',
25+
url: 'http://example.com',
26+
description: 'automated test weblink description',
27+
catid: categoryId,
28+
state: 1,
29+
language: '*',
30+
}))
31+
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
32+
.its('title')
33+
.should('include', 'automated test weblink'));
34+
});
35+
36+
it('can update a weblink', () => {
37+
cy.db_createWeblink({ title: 'automated test weblink' })
38+
.then((weblink) => cy.api_patch(`/weblinks/${weblink.id}`, { title: 'updated automated test weblink' }))
39+
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
40+
.its('title')
41+
.should('include', 'updated automated test weblink'));
42+
});
43+
44+
it('can delete a weblink', () => {
45+
cy.db_createWeblink({ title: 'automated test weblink', state: -2 })
46+
.then((weblink) => cy.api_delete(`/weblinks/${weblink.id}`));
47+
});
48+
});

0 commit comments

Comments
 (0)