Skip to content

Commit

Permalink
[4.4] Use joomla-cypress 1.1.1 (joomla#43722)
Browse files Browse the repository at this point in the history
* [cypress] Updated to joomla-cypress 1.1.0

The joomla-cypress NPM package used has been updated to the latest version in order to be able to use one version in all active joomla-cms branches.
Other packages were also updated to the latest versions with the `npm update`.
The overwritten Cypress commands for faster login with session have been deleted, as they are already included in the new joomla-cypress version.

* Hack to prevent deprecated in mod_related_items

* 3 more files with workarounds

* no hack for modules

* avoid hacks

* avoid hacks

* featured

* featured

* module

* nomore

* nomore

* Fix missing apostrophe

* NPM Update only joomla-cypress

npm install joomla-cypress@1.1.0

* Update tests/System/README.md

Removed notice on overridden joomla-cypress commands

* Fixing lint:testjs errors

* Undo the changes extracted to a separate PRs

* npm update joomla-cypress 1.1.1

---------

Co-authored-by: Nicola Galgano <optimus4joomla@gmail.com>
Co-authored-by: Allon Moritz <allon.moritz@digital-peak.com>
  • Loading branch information
3 people authored Aug 7, 2024
1 parent 98a4b2a commit 46c3bc0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 86 deletions.
60 changes: 33 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"fs-extra": "^10.1.0",
"ini": "^2.0.0",
"jasmine-core": "^3.99.1",
"joomla-cypress": "^0.0.16",
"joomla-cypress": "^1.1.1",
"lightningcss": "^1.22.1",
"mysql": "^2.18.1",
"postcss": "^8.4.30",
Expand All @@ -111,4 +111,4 @@
"stylelint-order": "^5.0.0",
"stylelint-scss": "^4.7.0"
}
}
}
4 changes: 0 additions & 4 deletions tests/System/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ SMTP configuration.

The used npm package "Helpers for using Cypress with Joomla for testing" **[joomala-cypress](https://github.com/joomla-projects/joomla-cypress/)** helps in writing the Cypress tests for Joomla in extending the Cypress API with custom commands.

> [!IMPORTANT]
> Some `joomala-cypress` commands are overwritten by the System Tests,
> see [tests/System/support/commands.js](/tests/System/support/commands.js).
The **[smtp-tester](https://www.npmjs.com/package/smtp-tester)** npm package creates an SMTP server that listens
on the `smtp_port` specified in `cypress.config.mjs` during test runtime.
This server accepts connections, receives emails, and provides the capability to check the received emails during the test.
Expand Down
54 changes: 1 addition & 53 deletions tests/System/support/commands.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Imports commands fom files. The commands start with the folder name and an underscore as cypress doesn't support
* Imports commands from files. The commands start with the folder name and an underscore as Cypress doesn't support
* namespaces for commands.
*
* https://github.com/cypress-io/cypress/issues/6575
Expand All @@ -12,55 +12,3 @@ import './commands/config.mjs';
import './commands/db.mjs';

registerCommands();

Cypress.Commands.overwrite('doFrontendLogin', (originalFn, username, password, useSnapshot = true) => {
// Ensure there are valid credentials
const user = username ?? Cypress.env('username');
const pw = password ?? Cypress.env('password');

// Do normal login when no snapshot should be used
if (!useSnapshot) {
// Clear the session data
Cypress.session.clearAllSavedSessions();

// Call the normal function
return originalFn(user, pw);
}

// Do login through the session
return cy.session([user, pw, 'front'], () => originalFn(user, pw), { cacheAcrossSpecs: true });
});

Cypress.Commands.overwrite('doFrontendLogout', (originalFn) => {
// Call the login function
originalFn();

// Clear the session data
Cypress.session.clearAllSavedSessions();
});

Cypress.Commands.overwrite('doAdministratorLogin', (originalFn, username, password, useSnapshot = true) => {
// Ensure there are valid credentials
const user = username ?? Cypress.env('username');
const pw = password ?? Cypress.env('password');

// Do normal login when no snapshot should be used
if (!useSnapshot) {
// Clear the session data
Cypress.session.clearAllSavedSessions();

// Call the normal function
return originalFn(user, pw);
}

// Do login through the session
return cy.session([user, pw, 'back'], () => originalFn(user, pw), { cacheAcrossSpecs: true });
});

Cypress.Commands.overwrite('doAdministratorLogout', (originalFn) => {
// Call the login function
originalFn();

// Clear the session data
Cypress.session.clearAllSavedSessions();
});

0 comments on commit 46c3bc0

Please sign in to comment.