Skip to content

Commit e6d7478

Browse files
Kaushik1216laoneosandewt
authored
Added test for com_contact in Backend (#40736)
* Added test for com_contact in Backend * Update tests/System/integration/administrator/components/com_contact/Contact.cy.js Co-authored-by: jsanders <[email protected]> * Contacts.cy.js cs fix * Update Contacts.cy.js --------- Co-authored-by: Allon Moritz <[email protected]> Co-authored-by: jsanders <[email protected]>
1 parent ceabdd6 commit e6d7478

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
describe('Test in backend that the contact form', () => {
2+
beforeEach(() => cy.doAdministratorLogin());
3+
afterEach(() => cy.task('queryDB', "DELETE FROM #__contact_details WHERE name = 'Test contact'"));
4+
5+
it('can create a contact', () => {
6+
cy.visit('/administrator/index.php?option=com_contact&task=contact.add');
7+
cy.get('#jform_name').clear().type('Test contact');
8+
cy.clickToolbarButton('Save & Close');
9+
10+
cy.get('#system-message-container').contains('Contact saved.').should('exist');
11+
cy.contains('Test contact');
12+
});
13+
14+
it('can change access level of a test contact', () => {
15+
cy.db_createContact({ name: 'Test contact' }).then((id) => {
16+
cy.visit(`administrator/index.php?option=com_contact&task=contact.edit&id=${id}`);
17+
cy.get('#jform_access').select('Special');
18+
cy.clickToolbarButton('Save & Close');
19+
20+
cy.get('td').contains('Special').should('exist');
21+
});
22+
});
23+
24+
it('check redirection to list view', () => {
25+
cy.visit('administrator/index.php?option=com_contact&task=contact.add');
26+
cy.intercept('index.php?option=com_contact&view=contacts').as('listview');
27+
cy.clickToolbarButton('Cancel');
28+
29+
cy.wait('@listview');
30+
});
31+
});
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
describe('Test in backend that the contacts list', () => {
2+
beforeEach(() => {
3+
cy.doAdministratorLogin();
4+
cy.visit('/administrator/index.php?option=com_contact&view=contacts&filter=');
5+
});
6+
7+
it('has a title', () => {
8+
cy.get('h1.page-title').should('contain.text', 'Contacts');
9+
});
10+
11+
it('can display a list of contacts', () => {
12+
cy.db_createContact({ name: 'Test contact' }).then(() => {
13+
cy.reload();
14+
15+
cy.contains('Test contact');
16+
});
17+
});
18+
19+
it('can open the contact form', () => {
20+
cy.clickToolbarButton('New');
21+
22+
cy.contains('Contacts: New');
23+
});
24+
25+
it('can publish the test contact', () => {
26+
cy.db_createContact({ name: 'Test contact', published: 0 }).then(() => {
27+
cy.reload();
28+
cy.searchForItem('Test contact');
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('Contact published.').should('exist');
35+
});
36+
});
37+
38+
it('can unpublish the test contact', () => {
39+
cy.db_createContact({ name: 'Test contact', published: 1 }).then(() => {
40+
cy.reload();
41+
cy.searchForItem('Test contact');
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('Contact unpublished.').should('exist');
48+
});
49+
});
50+
51+
it('can feature the test contact', () => {
52+
cy.db_createContact({ name: 'Test contact', featured: 0 }).then(() => {
53+
cy.reload();
54+
cy.searchForItem('Test contact');
55+
cy.checkAllResults();
56+
cy.clickToolbarButton('Action');
57+
cy.contains('.button-featured', 'Feature').click();
58+
cy.on('window:confirm', () => true);
59+
60+
cy.get('#system-message-container').contains('Contact featured.').should('exist');
61+
});
62+
});
63+
64+
it('can unfeature the test contact', () => {
65+
cy.db_createContact({ name: 'Test contact', featured: 1 }).then(() => {
66+
cy.reload();
67+
cy.searchForItem('Test contact');
68+
cy.checkAllResults();
69+
cy.clickToolbarButton('Action');
70+
cy.contains('Unfeature').click();
71+
cy.on('window:confirm', () => true);
72+
73+
cy.get('#system-message-container').contains('Contact unfeatured.').should('exist');
74+
});
75+
});
76+
77+
it('can trash the test contact', () => {
78+
cy.db_createContact({ name: 'Test contact' }).then(() => {
79+
cy.reload();
80+
cy.searchForItem('Test contact');
81+
cy.checkAllResults();
82+
cy.clickToolbarButton('Action');
83+
cy.contains('Trash').click();
84+
cy.on('window:confirm', () => true);
85+
86+
cy.get('#system-message-container').contains('Contact trashed.').should('exist');
87+
});
88+
});
89+
90+
it('can delete the test contact', () => {
91+
cy.db_createContact({ name: 'Test contact', published: -2 }).then(() => {
92+
cy.reload();
93+
cy.setFilter('published', 'Trashed');
94+
cy.searchForItem('Test contact');
95+
cy.checkAllResults();
96+
cy.clickToolbarButton('empty trash');
97+
cy.on('window:confirm', () => true);
98+
99+
cy.get('#system-message-container').contains('Contact deleted.').should('exist');
100+
});
101+
});
102+
});

0 commit comments

Comments
 (0)