User tests: Successful: Unsuccessful:
add system test for cli/joomla.php cache:clean command
run npx cypress run --spec tests/System/integration/cli/Cache.cy.js
N/A
test
Please select:
Documentation link for guide.joomla.org:
No documentation changes for guide.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.
| Status | New | ⇒ | Pending |
| Category | ⇒ | JavaScript Unit Tests |
| Labels |
Added:
Unit/System Tests
PR-5.4-dev
|
||
Now you are testing two things in one test, if module caching is working and the command. Also if else blocks should whenever possible be avoided in tests. Creating a file manually in the cache folder, running the command and testing if the file got deleted should be enough.
did you think something like this ?
describe('Test that console command cache', () => {
it('can clean cache', () => {
const cachedFile = Cypress.env('cmsPath') + 'administrator/cache/test.txt';
cy.task('writeRelativeFile', { path: 'administrator/cache/test.txt', content: 'test delete file from cache', mode: 0o666 });
cy.exec(`php ${Cypress.env('cmsPath')}/cli/joomla.php cache:clean`)
.its('stdout')
.should('contain', 'Cache cleaned');
cy.readFile(cachedFile).should('not.exist');
});
});Yes exactly
Nice, would be good if you can create a file in the test and check afterwards if it gets deleted. Like that we know that the command actually works.