Skip to content

Commit 1d29813

Browse files
authored
Added test for com_banners in Backend (#40738)
1 parent e6d7478 commit 1d29813

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
describe('Test in backend that the banners form', () => {
2+
beforeEach(() => cy.doAdministratorLogin());
3+
afterEach(() => cy.task('queryDB', "DELETE FROM #__banners WHERE name = 'Test banner'"));
4+
5+
it('can create a banner', () => {
6+
cy.visit('/administrator/index.php?option=com_banners&task=banner.add');
7+
cy.get('#jform_name').clear().type('Test banner');
8+
cy.clickToolbarButton('Save & Close');
9+
10+
cy.get('#system-message-container').contains('Banner saved.').should('exist');
11+
cy.contains('Test banner');
12+
});
13+
14+
it('check redirection to list view', () => {
15+
cy.visit('administrator/index.php?option=com_banners&task=banner.add');
16+
cy.intercept('index.php?option=com_banners&view=banners').as('listview');
17+
cy.clickToolbarButton('Cancel');
18+
19+
cy.wait('@listview');
20+
});
21+
});
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 banners list', () => {
2+
beforeEach(() => {
3+
cy.doAdministratorLogin();
4+
cy.visit('/administrator/index.php?option=com_banners&view=banners&filter=');
5+
});
6+
7+
it('has a title', () => {
8+
cy.get('h1.page-title').should('contain.text', 'Banners');
9+
});
10+
11+
it('can display a list of banners', () => {
12+
cy.db_createBanner({ name: 'Test banner' }).then(() => {
13+
cy.reload();
14+
15+
cy.contains('Test banner');
16+
});
17+
});
18+
19+
it('can open the banner form', () => {
20+
cy.clickToolbarButton('New');
21+
22+
cy.contains('Banners: New');
23+
});
24+
25+
it('can publish the test banner', () => {
26+
cy.db_createBanner({ name: 'Test banner', state: 0 }).then(() => {
27+
cy.reload();
28+
cy.searchForItem('Test banner');
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('Banner published.').should('exist');
35+
});
36+
});
37+
38+
it('can unpublish the test banner', () => {
39+
cy.db_createBanner({ name: 'Test banner', state: 1 }).then(() => {
40+
cy.reload();
41+
cy.searchForItem('Test banner');
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('Banner unpublished.').should('exist');
48+
});
49+
});
50+
51+
it('can trash the test banner', () => {
52+
cy.db_createBanner({ name: 'Test banner' }).then(() => {
53+
cy.reload();
54+
cy.searchForItem('Test banner');
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('Banner trashed.').should('exist');
61+
});
62+
});
63+
64+
it('can delete the test banner', () => {
65+
cy.db_createBanner({ name: 'Test banner', state: -2 }).then(() => {
66+
cy.reload();
67+
cy.setFilter('published', 'Trashed');
68+
cy.searchForItem('Test banner');
69+
cy.checkAllResults();
70+
cy.clickToolbarButton('empty trash');
71+
cy.on('window:confirm', () => true);
72+
73+
cy.get('#system-message-container').contains('Banner deleted.').should('exist');
74+
});
75+
});
76+
});

0 commit comments

Comments
 (0)