-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Cypress] Remove Joomla command line client tool dependency #44656
Open
muhme
wants to merge
2
commits into
joomla:5.2-dev
Choose a base branch
from
muhme:cypress-replace-cmd-line-client
base: 5.2-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
184 changes: 106 additions & 78 deletions
184
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 |
---|---|---|
@@ -1,115 +1,143 @@ | ||
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'); | ||
}); | ||
const setSefDefaults = () => cy.task('deleteRelativePath', '.htaccess') | ||
.then(() => cy.config_setParameter('sef', true)) | ||
.then(() => cy.config_setParameter('sef_suffix', false)) | ||
.then(() => cy.config_setParameter('sef_rewrite', false)) | ||
.then(() => cy.db_updateExtensionParameter('enforcesuffix', '1', 'plg_system_sef')) | ||
.then(() => cy.db_updateExtensionParameter('indexphp', '1', 'plg_system_sef')) | ||
.then(() => cy.db_updateExtensionParameter('trailingslash', '0', 'plg_system_sef')) | ||
.then(() => cy.db_updateExtensionParameter('strictrouting', '1', 'plg_system_sef')); | ||
|
||
// Ensure that we always start with a clean SEF default state | ||
beforeEach(() => setSefDefaults()); | ||
|
||
// Return to the clean SEF default state for subsequent Joomla System Tests | ||
afterEach(() => setSefDefaults()); | ||
|
||
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); | ||
}); | ||
cy.config_setParameter('sef', false) | ||
.then(() => { | ||
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); | ||
}); | ||
cy.config_setParameter('sef_suffix', true) | ||
.then(() => { | ||
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); | ||
}); | ||
cy.config_setParameter('sef_suffix', true) | ||
.then(() => cy.db_updateExtensionParameter('enforcesuffix', '0', 'plg_system_sef')) | ||
.then(() => cy.request({ url: '/index.php/component/users/login', followRedirect: false })) | ||
.then((response) => { | ||
expect(response.status).to.eq(200); | ||
}) | ||
.then(() => 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); | ||
}); | ||
cy.config_setParameter('sef_rewrite', true) | ||
.then(() => cy.task('copyRelativeFile', { source: 'htaccess.txt', destination: '.htaccess' })) | ||
.then(() => 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$/); | ||
}) | ||
.then(() => 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); | ||
}); | ||
cy.config_setParameter('sef_rewrite', true) | ||
.then(() => cy.task('copyRelativeFile', { source: 'htaccess.txt', destination: '.htaccess' })) | ||
.then(() => cy.db_updateExtensionParameter('indexphp', '0', 'plg_system_sef')) | ||
.then(() => cy.request({ url: '/index.php/component/users/login', followRedirect: false })) | ||
.then((response) => { | ||
expect(response.status).to.eq(200); | ||
}) | ||
.then(() => 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.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.db_updateExtensionParameter('trailingslash', '1', 'plg_system_sef') | ||
.then(() => 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\/$/); | ||
}) | ||
.then(() => 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); | ||
}); | ||
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); | ||
}); | ||
cy.db_updateExtensionParameter('strictrouting', '0', 'plg_system_sef') | ||
.then(() => cy.request({ url: '/index.php?option=com_users&view=login', followRedirect: false })) | ||
.then((response) => { | ||
expect(response.status).to.eq(200); | ||
}) | ||
.then(() => cy.request({ url: '/index.php/component/users/login', followRedirect: false })) | ||
.then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
Cypress.Commands.add('config_setParameter', (parameter, value) => { | ||
const configPath = `${Cypress.env('cmsPath')}/configuration.php`; | ||
|
||
cy.readFile(configPath).then((fileContent) => { | ||
// Return a Cypress chainable for chaining | ||
return cy.readFile(configPath).then((fileContent) => { | ||
// Setup the new value | ||
const newValue = typeof value === 'string' ? `'${value}'` : value; | ||
|
||
|
@@ -11,7 +12,11 @@ Cypress.Commands.add('config_setParameter', (parameter, value) => { | |
// Replace the whole line with the new value | ||
const content = fileContent.replace(regex, `public $${parameter} = ${newValue};`); | ||
|
||
// Write the modified content back to the configuration file relative to the CMS root folder | ||
cy.task('writeRelativeFile', { path: 'configuration.php', content }); | ||
/* Write the modified content back to the configuration file relative to the CMS root folder and | ||
* wait for the task to complete and chain it. | ||
*/ | ||
return cy.task('writeRelativeFile', { path: 'configuration.php', content }).then((result) => { | ||
cy.log(result); // Log success message for debugging | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return type changed to
Promise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the hint, it looks right as one more change and I will test it and adopt the function header, but I'm running out of time these days, come back soon ...