Skip to content

Commit 3a4d8fb

Browse files
laoneosandewt
andauthored
Adds system tests for modules (#40404)
* Adds system tests for modules * cs * Search more stable for edited module * Update tests/System/integration/administrator/components/com_modules/Module.cy.js Co-authored-by: jsanders <[email protected]> * has --------- Co-authored-by: jsanders <[email protected]>
1 parent 9002a3b commit 3a4d8fb

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
describe('Test in backend that the module form', () => {
2+
beforeEach(() => cy.doAdministratorLogin());
3+
afterEach(() => cy.task('queryDB', "DELETE FROM #__modules WHERE title = 'Test module'"));
4+
5+
it('can create a module', () => {
6+
cy.visit('/administrator/index.php?option=com_modules&task=module.add&client_id=0&eid=44');
7+
cy.get('#jform_title').clear().type('Test module');
8+
cy.clickToolbarButton('Save & Close');
9+
10+
cy.get('#system-message-container').contains('Module saved').should('exist');
11+
cy.contains('Test module');
12+
});
13+
14+
it('can edit a module', () => {
15+
cy.db_createModule({ title: 'Test module', module: 'mod_custom' }).then((id) => {
16+
cy.visit(`/administrator/index.php?option=com_modules&task=module.edit&id=${id}`);
17+
cy.get('#jform_title').clear().type('Test module edited');
18+
cy.clickToolbarButton('Save & Close');
19+
20+
// This is needed as it can be that the backend list still has a filter active
21+
cy.visit('/administrator/index.php?option=com_modules&view=modules&filter=');
22+
cy.reload();
23+
24+
cy.contains('Test module edited');
25+
});
26+
});
27+
});
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
describe('Test in backend that the module list', () => {
2+
beforeEach(() => {
3+
cy.doAdministratorLogin();
4+
cy.visit('/administrator/index.php?option=com_modules&view=modules&filter=');
5+
});
6+
7+
it('has a title', () => {
8+
cy.get('h1.page-title').should('contain.text', 'Modules');
9+
});
10+
11+
it('can display a list of modules', () => {
12+
cy.db_createModule({ title: 'Test module', module: 'mod_custom' }).then(() => {
13+
cy.reload();
14+
15+
cy.contains('Test module');
16+
});
17+
});
18+
19+
it('can open the module list', () => {
20+
cy.clickToolbarButton('New');
21+
22+
cy.contains('Select a Module Type');
23+
});
24+
25+
it('can publish the test module', () => {
26+
cy.db_createModule({ title: 'Test module', module: 'mod_custom', published: 0 }).then(() => {
27+
cy.reload();
28+
cy.searchForItem('Test module');
29+
cy.checkAllResults();
30+
cy.clickToolbarButton('Action');
31+
cy.contains('Publish').click();
32+
cy.on('window:confirm', () => true);
33+
34+
cy.get('#system-message-container').contains('Module published').should('exist');
35+
});
36+
});
37+
38+
it('can unpublish the test module', () => {
39+
cy.db_createModule({ title: 'Test module', module: 'mod_custom', published: 1 }).then(() => {
40+
cy.reload();
41+
cy.searchForItem('Test module');
42+
cy.checkAllResults();
43+
cy.clickToolbarButton('Action');
44+
cy.contains('Unpublish').click();
45+
cy.on('window:confirm', () => true);
46+
47+
cy.get('#system-message-container').contains('Module unpublished').should('exist');
48+
});
49+
});
50+
51+
it('can trash the test module', () => {
52+
cy.db_createModule({ title: 'Test module', module: 'mod_custom' }).then(() => {
53+
cy.reload();
54+
cy.searchForItem('Test module');
55+
cy.checkAllResults();
56+
cy.clickToolbarButton('Action');
57+
cy.contains('Trash').click();
58+
cy.on('window:confirm', () => true);
59+
60+
cy.get('#system-message-container').contains('Module trashed').should('exist');
61+
});
62+
});
63+
64+
it('can delete the test module', () => {
65+
cy.db_createModule({ title: 'Test module', module: 'mod_custom', published: -2 }).then(() => {
66+
cy.reload();
67+
cy.setFilter('state', 'Trashed');
68+
cy.searchForItem('Test module');
69+
cy.checkAllResults();
70+
cy.clickToolbarButton('empty trash');
71+
cy.on('window:confirm', () => true);
72+
73+
cy.get('#system-message-container').contains('Module deleted').should('exist');
74+
});
75+
});
76+
});

0 commit comments

Comments
 (0)