Skip to content

Commit 352698f

Browse files
authored
[5.3][cypress] add tests for issue 45190 (#45208)
1 parent c8b3f3c commit 352698f

File tree

6 files changed

+213
-1
lines changed

6 files changed

+213
-1
lines changed

administrator/components/com_templates/src/View/Templates/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function addToolbar()
142142
$toolbar = $this->getDocument()->getToolbar();
143143

144144
// Add a shortcut to the styles list view.
145-
$toolbar->linkButton('', 'COM_TEMPLATES_MANAGER_STYLES_BUTTON')
145+
$toolbar->linkButton('styles', 'COM_TEMPLATES_MANAGER_STYLES_BUTTON')
146146
->url('index.php?option=com_templates&view=styles&client_id=' . $clientId)
147147
->icon('icon-brush thememanager');
148148

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
describe('Test in backend that the styles list', () => {
2+
beforeEach(() => cy.doAdministratorLogin());
3+
4+
it('can list site styles', () => {
5+
cy.visit('/administrator/index.php?option=com_templates&view=styles&client_id=0');
6+
cy.get('h1.page-title').should('contain.text', 'Templates: Styles (Site)');
7+
cy.get('#client_id option:selected').should('have.text', 'Site');
8+
cy.get('#styleList tbody a').contains('Cassiopeia - Default').click();
9+
cy.get('h1.page-title').should('contain.text', 'Templates: Edit Style');
10+
cy.clickToolbarButton('Cancel');
11+
});
12+
13+
it('can list administrator styles', () => {
14+
cy.visit('/administrator/index.php?option=com_templates&view=styles&client_id=1');
15+
cy.get('h1.page-title').should('contain.text', 'Templates: Styles (Administrator)');
16+
cy.get('#client_id option:selected').should('have.text', 'Administrator');
17+
cy.get('#styleList tbody a').contains('Atum - Default').click();
18+
cy.get('h1.page-title').should('contain.text', 'Templates: Edit Style');
19+
cy.clickToolbarButton('Cancel');
20+
});
21+
22+
it('can select client', () => {
23+
cy.visit('/administrator/index.php?option=com_templates&view=styles&client_id=0');
24+
cy.get('h1.page-title').should('contain.text', 'Templates: Styles (Site)');
25+
cy.get('#client_id').select('Administrator');
26+
cy.get('h1.page-title').should('contain.text', 'Templates: Styles (Administrator)');
27+
cy.get('#client_id').select('Site');
28+
cy.get('h1.page-title').should('contain.text', 'Templates: Styles (Site)');
29+
});
30+
31+
it('can open templates', () => {
32+
cy.visit('/administrator/index.php?option=com_templates&view=styles&client_id=1');
33+
cy.get('h1.page-title').should('contain.text', 'Templates: Styles (Administrator)');
34+
cy.get('#toolbar-templates').click();
35+
cy.get('h1.page-title').should('contain.text', 'Templates: Templates (Administrator)');
36+
});
37+
38+
it('can open options', () => {
39+
cy.visit('/administrator/index.php?option=com_templates&view=styles&client_id=0');
40+
cy.intercept('**/administrator/index.php?option=com_config&view=component&component=com_templates*').as('options');
41+
cy.intercept('**/administrator/index.php?option=com_templates&view=styles&client_id=0*').as('listview');
42+
43+
cy.clickToolbarButton('Options');
44+
cy.wait('@options');
45+
cy.title().should('contain', 'Template: Options');
46+
cy.get('h1.page-title').should('contain', 'Template: Options');
47+
48+
cy.clickToolbarButton('Cancel');
49+
cy.wait('@listview');
50+
});
51+
});
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
describe('Test in backend that the templates list', () => {
2+
beforeEach(() => cy.doAdministratorLogin());
3+
4+
it('can list site templates', () => {
5+
cy.visit('/administrator/index.php?option=com_templates&view=templates&client_id=0');
6+
cy.get('h1.page-title').should('contain.text', 'Templates: Templates (Site)');
7+
cy.get('#client_id option:selected').should('have.text', 'Site');
8+
cy.get('#templateList tbody .template-name a').contains('Cassiopeia').click();
9+
cy.get('h1.page-title').should('contain.text', 'Templates: Customise (Cassiopeia)');
10+
cy.clickToolbarButton('Cancel');
11+
});
12+
13+
it('can list administrator templates', () => {
14+
cy.visit('/administrator/index.php?option=com_templates&view=templates&client_id=1');
15+
cy.get('h1.page-title').should('contain.text', 'Templates: Templates (Administrator)');
16+
cy.get('#client_id option:selected').should('have.text', 'Administrator');
17+
cy.get('#templateList tbody .template-name a').contains('Atum').click();
18+
cy.get('h1.page-title').should('contain.text', 'Templates: Customise (Atum)');
19+
cy.clickToolbarButton('Cancel');
20+
});
21+
22+
it('can select client', () => {
23+
cy.visit('/administrator/index.php?option=com_templates&view=templates&client_id=0');
24+
cy.get('h1.page-title').should('contain.text', 'Templates: Templates (Site)');
25+
cy.get('#client_id').select('Administrator');
26+
cy.get('h1.page-title').should('contain.text', 'Templates: Templates (Administrator)');
27+
cy.get('#client_id').select('Site');
28+
cy.get('h1.page-title').should('contain.text', 'Templates: Templates (Site)');
29+
});
30+
31+
it('can open styles', () => {
32+
cy.visit('/administrator/index.php?option=com_templates&view=templates&client_id=0');
33+
cy.get('h1.page-title').should('contain.text', 'Templates: Templates (Site)');
34+
cy.get('#toolbar-styles').click();
35+
cy.get('h1.page-title').should('contain.text', 'Templates: Styles (Site)');
36+
});
37+
38+
it('can open options', () => {
39+
cy.visit('/administrator/index.php?option=com_templates&view=templates&client_id=1');
40+
cy.intercept('**/administrator/index.php?option=com_config&view=component&component=com_templates*').as('options');
41+
cy.intercept('**/administrator/index.php?option=com_templates&view=templates&client_id=1*').as('listview');
42+
43+
cy.clickToolbarButton('Options');
44+
cy.wait('@options');
45+
cy.title().should('contain', 'Template: Options');
46+
cy.get('h1.page-title').should('contain', 'Template: Options');
47+
48+
cy.clickToolbarButton('Cancel');
49+
cy.wait('@listview');
50+
});
51+
});
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
describe('Test in frontend that the config config view', () => {
2+
beforeEach(() => cy.doFrontendLogin());
3+
4+
it('can edit site configuration without menu item', () => {
5+
cy.visit('/index.php?option=com_config&view=config');
6+
cy.title().should('equal', 'Home');
7+
cy.get('#jform_sitename_pagetitles').select('After');
8+
cy.get('#application-form button[data-submit-task="config.apply"]').click();
9+
10+
cy.checkForSystemMessage('Configuration saved.');
11+
cy.title().should('equal', `Home - ${Cypress.env('sitename')}`);
12+
cy.get('#jform_sitename_pagetitles').select('No');
13+
cy.get('#application-form button[data-submit-task="config.apply"]').click();
14+
15+
cy.checkForSystemMessage('Configuration saved.');
16+
cy.title().should('equal', 'Home');
17+
});
18+
19+
it('can edit site configuration with menu item', () => {
20+
cy.db_createMenuItem({ title: 'automated test site configuration', link: 'index.php?option=com_config&view=config' })
21+
.then(() => {
22+
cy.visit('/');
23+
cy.get('a:contains(automated test site configuration)').click();
24+
25+
cy.title().should('equal', 'automated test site configuration');
26+
cy.get('head meta[name=description]').should('not.exist');
27+
cy.get('#jform_MetaDesc').clear().type('test meta description');
28+
cy.get('#application-form button[data-submit-task="config.apply"]').click();
29+
30+
cy.checkForSystemMessage('Configuration saved.');
31+
cy.get('head meta[name=description]').should('have.attr', 'content').should('contain', 'test meta description');
32+
cy.get('#jform_MetaDesc').clear();
33+
cy.get('#application-form button[data-submit-task="config.apply"]').click();
34+
35+
cy.checkForSystemMessage('Configuration saved.');
36+
cy.get('head meta[name=description]').should('not.exist');
37+
});
38+
});
39+
40+
it('can toggle inline help options', () => {
41+
cy.visit('/index.php?option=com_config&view=config');
42+
cy.get('#jform_access-desc').should('be.not.visible');
43+
cy.get('button.button-inlinehelp').click();
44+
cy.get('#jform_access-desc').should('be.visible');
45+
cy.get('button.button-inlinehelp').click();
46+
cy.get('#jform_access-desc').should('be.not.visible');
47+
});
48+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
describe('Test in frontend that the config modules view', () => {
2+
beforeEach(() => cy.doFrontendLogin());
3+
4+
it('can edit a module', () => {
5+
cy.visit('/');
6+
cy.get('nav.mod-breadcrumbs__wrapper li.mod-breadcrumbs__here').should('exist');
7+
cy.get('nav.mod-breadcrumbs__wrapper li.mod-breadcrumbs__divider').should('not.exist');
8+
cy.get('nav.mod-breadcrumbs__wrapper a.jmodedit').click();
9+
10+
cy.title().should('equal', 'Module Settings');
11+
cy.get('#options button.accordion-button').contains('Options').click();
12+
cy.get('#jform_params_showHere0').click();
13+
cy.get('#modules-form button[data-submit-task="modules.apply"]').click();
14+
15+
cy.checkForSystemMessage('Module saved.');
16+
cy.get('nav.mod-breadcrumbs__wrapper li.mod-breadcrumbs__here').should('not.exist');
17+
cy.get('nav.mod-breadcrumbs__wrapper li.mod-breadcrumbs__divider').should('exist');
18+
cy.get('#options button.accordion-button').contains('Options').click();
19+
cy.get('#jform_params_showHere1').click();
20+
cy.get('#modules-form button[data-submit-task="modules.save"]').click();
21+
22+
cy.checkForSystemMessage('Module saved.');
23+
});
24+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
describe('Test in frontend that the config config view', () => {
2+
beforeEach(() => cy.doFrontendLogin());
3+
4+
it('can edit template settings without menu item', () => {
5+
cy.visit('/index.php?option=com_config&view=templates');
6+
cy.title().should('equal', 'Home');
7+
cy.get('#params_siteDescription').clear().type('test site description');
8+
cy.get('#templates-form button[data-submit-task="templates.apply"]').click();
9+
10+
cy.checkForSystemMessage('Configuration saved.');
11+
cy.get('header div.site-description').should('contain', 'test site description');
12+
cy.get('#params_siteDescription').clear();
13+
cy.get('#templates-form button[data-submit-task="templates.apply"]').click();
14+
15+
cy.checkForSystemMessage('Configuration saved.');
16+
cy.get('header div.site-description').should('not.exist');
17+
});
18+
19+
it('can edit template settings with menu item', () => {
20+
cy.db_createMenuItem({ title: 'automated test template settings', link: 'index.php?option=com_config&view=templates' })
21+
.then(() => {
22+
cy.visit('/');
23+
cy.get('a:contains(automated test template settings)').click();
24+
25+
cy.title().should('equal', 'automated test template settings');
26+
cy.get('#params_brand0').click();
27+
cy.get('#templates-form button[data-submit-task="templates.apply"]').click();
28+
29+
cy.checkForSystemMessage('Configuration saved.');
30+
cy.get('header div.navbar-brand').should('not.exist');
31+
cy.get('#params_brand1').click();
32+
cy.get('#templates-form button[data-submit-task="templates.apply"]').click();
33+
34+
cy.checkForSystemMessage('Configuration saved.');
35+
cy.get('header div.navbar-brand').should('exist');
36+
});
37+
});
38+
});

0 commit comments

Comments
 (0)