Skip to content

Commit 9ac8bf8

Browse files
authored
Merge pull request #596 from alikon/initial-webservices-tests
prepare for webservices testings still room for improvements for GSoC studentes
2 parents 4106a19 + a8407ac commit 9ac8bf8

File tree

6 files changed

+68
-4
lines changed

6 files changed

+68
-4
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',

jorobo.dist.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
extension = weblinks
2-
version = 4.0.0
2+
version = 5.0.0-dev
33
source = src
44
target = package
55

@@ -8,7 +8,7 @@ target = package
88
; and add Release to the target (separated by space) above
99
[github]
1010
remote = origin
11-
branch = develop
11+
branch = 5.x-dev
1212
token =
1313
owner = joomla-extensions
1414
repository = weblinks

src/api/components/com_weblinks/src/View/Weblinks/JsonApiView.php renamed to src/api/components/com_weblinks/src/View/Weblinks/JsonapiView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @since __DEPLOY_VERSION__
2424
*/
25-
class JsonApiView extends BaseApiView
25+
class JsonapiView extends BaseApiView
2626
{
2727
/**
2828
* The fields to render item in the documents

tests/cypress/integration/administrator/components/com_weblinks/CheckPackage.cy.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ describe('Test that the weblinks extension package', () => {
5858
.within(() => {
5959
cy.get('td').eq(2).should('contain', 'Administrator'); // Location column
6060
cy.get('td').eq(3).should('contain', 'Component'); // Type column
61+
// todo make version check dinamic
62+
// cy.get('td').eq(4).should('contain', '5.0.0-dev'); // Version column
6163
cy.get('td').eq(7).should('contain', 'N/A'); // Folder column
6264
});
6365
});
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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_enableExtension('1', 'plg_webservices_weblinks');
6+
cy.db_createWeblink({ title: 'automated test weblink' })
7+
.then(() => cy.api_get('/weblinks'))
8+
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
9+
.its('title')
10+
.should('include', 'automated test weblink'));
11+
cy.db_enableExtension('0', 'plg_webservices_weblinks');
12+
});
13+
14+
it('can deliver a single weblink', () => {
15+
cy.db_enableExtension('1', 'plg_webservices_weblinks');
16+
cy.db_createWeblink({ title: 'automated test weblink' })
17+
.then((weblink) => cy.api_get(`/weblinks/${weblink.id}`))
18+
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
19+
.its('title')
20+
.should('include', 'automated test weblink'));
21+
cy.db_enableExtension('0', 'plg_webservices_weblinks');
22+
});
23+
24+
it('can create a weblink', () => {
25+
cy.db_enableExtension('1', 'plg_webservices_weblinks');
26+
cy.db_createCategory({ extension: 'com_weblinks' })
27+
.then((categoryId) => cy.api_post('/weblinks', {
28+
title: 'automated test weblink',
29+
alias: 'test-weblink',
30+
url: 'http://example.com',
31+
description: 'automated test weblink description',
32+
catid: categoryId,
33+
state: 1,
34+
language: '*',
35+
}))
36+
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
37+
.its('title')
38+
.should('include', 'automated test weblink'));
39+
cy.db_enableExtension('0', 'plg_webservices_weblinks');
40+
});
41+
42+
it('can update a weblink', () => {
43+
cy.db_enableExtension('1', 'plg_webservices_weblinks');
44+
cy.db_createWeblink({ title: 'automated test weblink' })
45+
.then((weblink) => cy.api_patch(`/weblinks/${weblink.id}`, { title: 'updated automated test weblink' }))
46+
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
47+
.its('title')
48+
.should('include', 'updated automated test weblink'));
49+
cy.db_enableExtension('0', 'plg_webservices_weblinks');
50+
});
51+
52+
it('can delete a weblink', () => {
53+
cy.db_enableExtension('1', 'plg_webservices_weblinks');
54+
cy.db_createWeblink({ title: 'automated test weblink', state: -2 })
55+
.then((weblink) => cy.api_delete(`/weblinks/${weblink.id}`))
56+
.then((response) => cy.wrap(response).its('status').should('eq', 204));
57+
cy.db_enableExtension('0', 'plg_webservices_weblinks');
58+
});
59+
});

tests/cypress/integration/install/install.cy.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ describe('Install Joomla and Weblinks package', () => {
88
cy.disableStatistics()
99
cy.setErrorReportingToDevelopment()
1010
cy.doAdministratorLogout()
11+
// Update to the correct secret for the API tests because of the bearer token
12+
cy.config_setParameter('secret', 'tEstValue');
1113
})
1214
})

0 commit comments

Comments
 (0)