-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5.2] add test for site router (sef) (#44253)
* [5.2] add test for site router (sef) * use copyFileSync
- Loading branch information
Showing
7 changed files
with
403 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
tests/System/integration/plugins/system/sef/SefPlugin.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
describe('Test that the sef system plugin', () => { | ||
afterEach(() => { | ||
cy.task('deleteRelativePath', '.htaccess'); | ||
cy.exec(`php ${Cypress.env('cmsPath')}/cli/joomla.php config:set sef=true sef_suffix=false sef_rewrite=false`); | ||
cy.db_updateExtensionParameter('enforcesuffix', '1', 'plg_system_sef'); | ||
cy.db_updateExtensionParameter('indexphp', '1', 'plg_system_sef'); | ||
cy.db_updateExtensionParameter('trailingslash', '0', 'plg_system_sef'); | ||
cy.db_updateExtensionParameter('strictrouting', '1', 'plg_system_sef'); | ||
}); | ||
|
||
it('can process if option \'sef\' disabled', () => { | ||
cy.exec(`php ${Cypress.env('cmsPath')}/cli/joomla.php config:set sef=false`); | ||
cy.request({ url: '/index.php?option=com_users&view=login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
cy.request({ url: '/index.php/component/users/login', failOnStatusCode: false, followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(404); | ||
}); | ||
}); | ||
|
||
it('can process if option \'enforcesuffix\' enabled', () => { | ||
cy.exec(`php ${Cypress.env('cmsPath')}/cli/joomla.php config:set sef_suffix=true`); | ||
cy.request({ url: '/index.php/component/users/login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(301); | ||
expect(response.redirectedToUrl).to.match(/\/index\.php\/component\/users\/login\.html$/); | ||
}); | ||
cy.request({ url: '/index.php/component/users/login.html', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
}); | ||
|
||
it('can process if option \'enforcesuffix\' disabled', () => { | ||
cy.exec(`php ${Cypress.env('cmsPath')}/cli/joomla.php config:set sef_suffix=true`); | ||
cy.db_updateExtensionParameter('enforcesuffix', '0', 'plg_system_sef'); | ||
cy.request({ url: '/index.php/component/users/login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
cy.request({ url: '/index.php/component/users/login.html', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
}); | ||
|
||
it('can process if option \'indexphp\' enabled', () => { | ||
cy.exec(`php ${Cypress.env('cmsPath')}/cli/joomla.php config:set sef_rewrite=true`); | ||
cy.task('copyRelativeFile', { source: 'htaccess.txt', destination: '.htaccess' }); | ||
cy.request({ url: '/index.php/component/users/login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(301); | ||
expect(response.redirectedToUrl).to.match(/(?<!index\.php)\/component\/users\/login$/); | ||
}); | ||
cy.request({ url: '/component/users/login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
}); | ||
|
||
it('can process if option \'indexphp\' disabled', () => { | ||
cy.exec(`php ${Cypress.env('cmsPath')}/cli/joomla.php config:set sef_rewrite=true`); | ||
cy.task('copyRelativeFile', { source: 'htaccess.txt', destination: '.htaccess' }); | ||
cy.db_updateExtensionParameter('indexphp', '0', 'plg_system_sef'); | ||
cy.request({ url: '/index.php/component/users/login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
cy.request({ url: '/component/users/login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
}); | ||
|
||
it('can process if option \'trailingslash\' disabled', () => { | ||
cy.request({ url: '/index.php/component/users/login/', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(301); | ||
expect(response.redirectedToUrl).to.match(/\/index\.php\/component\/users\/login$/); | ||
}); | ||
cy.request({ url: '/index.php/component/users/login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
cy.visit('/'); | ||
cy.get('li.nav-item').contains('Home') | ||
.should('have.attr', 'href') | ||
.and('match', /\/index\.php$/); | ||
}); | ||
|
||
it('can process if option \'trailingslash\' enabled', () => { | ||
cy.db_updateExtensionParameter('trailingslash', '1', 'plg_system_sef'); | ||
cy.request({ url: '/index.php/component/users/login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(301); | ||
expect(response.redirectedToUrl).to.match(/\/index\.php\/component\/users\/login\/$/); | ||
}); | ||
cy.request({ url: '/index.php/component/users/login/', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
cy.visit('/'); | ||
cy.get('li.nav-item').contains('Home') | ||
.should('have.attr', 'href') | ||
.and('match', /\/index\.php\/$/); | ||
}); | ||
|
||
it('can process if option \'strictrouting\' enabled', () => { | ||
cy.request({ url: '/index.php?option=com_users&view=login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(301); | ||
expect(response.redirectedToUrl).to.match(/\/index\.php\/component\/users\/login$/); | ||
}); | ||
cy.request({ url: '/index.php/component/users/login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
}); | ||
|
||
it('can process if option \'strictrouting\' disabled', () => { | ||
cy.db_updateExtensionParameter('strictrouting', '0', 'plg_system_sef'); | ||
cy.request({ url: '/index.php?option=com_users&view=login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
cy.request({ url: '/index.php/component/users/login', followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
}); | ||
}); |
132 changes: 132 additions & 0 deletions
132
tests/System/integration/site/components/com_contact/Router.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
describe('Test in frontend that the contact site router', () => { | ||
it('can process contact without a menu item', () => { | ||
cy.db_createContact({ name: 'Test Contact', alias: 'test-contact-router' }).then((contact) => { | ||
cy.request({ url: `/index.php?option=com_contact&view=contact&id=${contact.id}`, followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(301); | ||
expect(response.redirectedToUrl).to.match(/\/index\.php\/component\/contact\/contact\/test-contact-router$/); | ||
}); | ||
|
||
cy.visit('/index.php/component/contact/contact/test-contact-router'); | ||
cy.url().should('match', /\/index\.php\/component\/contact\/contact\/test-contact-router$/); | ||
cy.title().should('equal', 'Test Contact'); | ||
cy.get('main h1').contains('Home'); | ||
cy.get('main h2').contains('Test Contact'); | ||
cy.get('main h3').contains('Contact'); | ||
cy.get('nav.mod-breadcrumbs__wrapper ol.mod-breadcrumbs').children().as('breadcrumb'); | ||
cy.get('@breadcrumb').should('have.length', 4); | ||
cy.get('@breadcrumb').eq(2).should('contain', 'Uncategorised'); | ||
cy.get('@breadcrumb').eq(3).should('contain', 'Test Contact'); | ||
}); | ||
}); | ||
|
||
it('can process contact with a single contact menu item', () => { | ||
cy.db_createContact({ name: 'Test Contact', alias: 'test-contact-router' }).then((contact) => { | ||
cy.db_createMenuItem({ | ||
title: 'Test Menu Single Contact', | ||
alias: 'test-menu-contact-router', | ||
path: 'test-menu-contact-router', | ||
link: `index.php?option=com_contact&view=contact&id=${contact.id}`, | ||
}); | ||
cy.request({ url: `/index.php?option=com_contact&view=contact&id=${contact.id}&catid=${contact.catid}`, followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(301); | ||
expect(response.redirectedToUrl).to.match(/\/index\.php\/test-menu-contact-router$/); | ||
}); | ||
|
||
cy.visit('/index.php/test-menu-contact-router'); | ||
cy.url().should('match', /\/index\.php\/test-menu-contact-router$/); | ||
cy.title().should('equal', 'Test Menu Single Contact'); | ||
cy.get('main h1').contains('Test Contact'); | ||
cy.get('main h2').contains('Contact'); | ||
cy.get('nav.mod-breadcrumbs__wrapper ol.mod-breadcrumbs').children().as('breadcrumb'); | ||
cy.get('@breadcrumb').should('have.length', 3); | ||
cy.get('@breadcrumb').eq(2).should('contain', 'Test Menu Single Contact'); | ||
}); | ||
}); | ||
|
||
it('can process contact with a category list menu item', () => { | ||
cy.db_createContact({ name: 'Test Contact', alias: 'test-contact-router' }).then((contact) => { | ||
cy.db_createMenuItem({ | ||
title: 'Test Menu Contact Category', | ||
alias: 'test-menu-category-router', | ||
path: 'test-menu-category-router', | ||
link: `index.php?option=com_contact&view=category&id=${contact.catid}`, | ||
}); | ||
cy.request({ url: `/index.php?option=com_contact&view=contact&id=${contact.id}&catid=${contact.catid}`, followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(301); | ||
expect(response.redirectedToUrl).to.match(/\/index\.php\/test-menu-category-router\/test-contact-router$/); | ||
}); | ||
|
||
cy.visit('/index.php/test-menu-category-router'); | ||
cy.url().should('match', /\/index\.php\/test-menu-category-router$/); | ||
cy.title().should('equal', 'Test Menu Contact Category'); | ||
cy.get('main h1').contains('Uncategorised'); | ||
cy.get('nav.mod-breadcrumbs__wrapper ol.mod-breadcrumbs').children().as('breadcrumb'); | ||
cy.get('@breadcrumb').should('have.length', 3); | ||
cy.get('@breadcrumb').eq(2).should('contain', 'Test Menu Contact Category'); | ||
cy.get('main div.com-contact-category a') | ||
.contains('Test Contact') | ||
.should('have.attr', 'href') | ||
.and('match', /\/index\.php\/test-menu-category-router\/test-contact-router$/); | ||
|
||
cy.visit('/index.php/test-menu-category-router/test-contact-router'); | ||
cy.url().should('match', /\/index\.php\/test-menu-category-router\/test-contact-router$/); | ||
cy.title().should('equal', 'Test Contact'); | ||
cy.get('main h1').contains('Test Contact'); | ||
cy.get('main h2').contains('Contact'); | ||
cy.get('nav.mod-breadcrumbs__wrapper ol.mod-breadcrumbs').children().as('breadcrumb'); | ||
cy.get('@breadcrumb').should('have.length', 4); | ||
cy.get('@breadcrumb').eq(2).should('contain', 'Test Menu Contact Category'); | ||
cy.get('@breadcrumb').eq(3).should('contain', 'Test Contact'); | ||
}); | ||
}); | ||
|
||
it('can process contact with a categories list menu item', () => { | ||
cy.db_createContact({ name: 'Test Contact', alias: 'test-contact-router' }).then((contact) => { | ||
cy.db_createMenuItem({ | ||
title: 'Test Menu Contact Categories', | ||
alias: 'test-menu-categories-router', | ||
path: 'test-menu-categories-router', | ||
link: 'index.php?option=com_contact&view=categories&id=0', | ||
}); | ||
cy.request({ url: `/index.php?option=com_contact&view=contact&id=${contact.id}&catid=${contact.catid}`, followRedirect: false }).then((response) => { | ||
expect(response.status).to.eq(301); | ||
expect(response.redirectedToUrl).to.match(/\/index\.php\/test-menu-categories-router\/uncategorised\/test-contact-router$/); | ||
}); | ||
|
||
cy.visit('/index.php/test-menu-categories-router'); | ||
cy.url().should('match', /\/index\.php\/test-menu-categories-router$/); | ||
cy.title().should('equal', 'Test Menu Contact Categories'); | ||
cy.get('nav.mod-breadcrumbs__wrapper ol.mod-breadcrumbs').children().as('breadcrumb'); | ||
cy.get('@breadcrumb').should('have.length', 3); | ||
cy.get('@breadcrumb').eq(2).should('contain', 'Test Menu Contact Categories'); | ||
cy.get('main div.com-contact-categories h3 a') | ||
.contains('Uncategorised') | ||
.should('have.attr', 'href') | ||
.and('match', /\/index\.php\/test-menu-categories-router\/uncategorised$/); | ||
|
||
cy.visit('/index.php/test-menu-categories-router/uncategorised'); | ||
cy.url().should('match', /\/index\.php\/test-menu-categories-router\/uncategorised$/); | ||
cy.title().should('equal', 'Test Menu Contact Categories'); | ||
cy.get('main h1').contains('Uncategorised'); | ||
cy.get('nav.mod-breadcrumbs__wrapper ol.mod-breadcrumbs').children().as('breadcrumb'); | ||
cy.get('@breadcrumb').should('have.length', 4); | ||
cy.get('@breadcrumb').eq(2).should('contain', 'Test Menu Contact Categories'); | ||
cy.get('@breadcrumb').eq(3).should('contain', 'Uncategorised'); | ||
cy.get('main div.com-contact-category a') | ||
.contains('Test Contact') | ||
.should('have.attr', 'href') | ||
.and('match', /\/index\.php\/test-menu-categories-router\/uncategorised\/test-contact-router$/); | ||
|
||
cy.visit('/index.php/test-menu-categories-router/uncategorised/test-contact-router'); | ||
cy.url().should('match', /\/index\.php\/test-menu-categories-router\/uncategorised\/test-contact-router$/); | ||
cy.title().should('equal', 'Test Contact'); | ||
cy.get('main h1').contains('Test Contact'); | ||
cy.get('main h2').contains('Contact'); | ||
cy.get('nav.mod-breadcrumbs__wrapper ol.mod-breadcrumbs').children().as('breadcrumb'); | ||
cy.get('@breadcrumb').should('have.length', 5); | ||
cy.get('@breadcrumb').eq(2).should('contain', 'Test Menu Contact Categories'); | ||
cy.get('@breadcrumb').eq(3).should('contain', 'Uncategorised'); | ||
cy.get('@breadcrumb').eq(4).should('contain', 'Test Contact'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.