Skip to content

Commit 8d555a7

Browse files
authored
[Cypress][docu] tests/System/README.md revised in 5 points (joomla#44660)
* tests/System/README.md revised in 5 points * Added paragraph 'Config commands' with missing description for `config_setParameter` * Added web server configuration with `rewrite_module` and directory's `AllowOverride` (needed after adding SEF tests) * Added JBT as sample for Docker integration * Unified heading to have only first word and proper nouns to start with upercase letter * Using 'Joomla System Tests' as proper noun and replaced different writings (e.g. CMS System Tests) * Linked to the official Joomla Docker containers * Revert to title case in capitalisation
1 parent 0c154ff commit 8d555a7

File tree

1 file changed

+53
-22
lines changed

1 file changed

+53
-22
lines changed

tests/System/README.md

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# System Tests in Joomla
1+
# Joomla System Tests
22

3-
The Joomla CMS System Tests are end-to-end (E2E) tests and executed in real browsers
3+
The **Joomla System Tests** are end-to-end (E2E) tests and executed in real browsers
44
using the [Cypress](https://www.cypress.io) test automation tool.
55
These tests simulate real user interactions, clicking and navigating like a human would,
66
to ensure the entire application works as expected.
@@ -10,14 +10,14 @@ and details how to execute and extend tests.
1010
It concludes with solutions for common failure situations in the troubleshooting chapter.
1111

1212

13-
## Software Architecture Overview
13+
## Software Architecture Overview
1414

1515
The following software architecture diagram illustrates the Joomla System Tests architecture and provides an overview.
1616
It is simplified to offer an initial understanding. Detailed explanations follow later in this document.
1717

18-
![System Tests Architecture](images/system-tests.svg)
18+
![Joomla System Tests Architecture](images/system-tests.svg)
1919

20-
On the left, **Cypress** is running as a [Node.js](https://nodejs.org/) application. The file **`cypress.config.mjs`** is used to configure settings and preferences for running the System Tests in your environment.
20+
On the left, **Cypress** is running as a [Node.js](https://nodejs.org/) application. The file **`cypress.config.mjs`** is used to configure settings and preferences for running the Joomla System Tests in your environment.
2121

2222
In the middle, the **Cypress Test Runner** controls a **Browser** with the **Joomla** application running HTML, CSS, and JavaScript. Also running in the browser context are the **Database Commands**, the **API commands** and the npm packages **[joomala-cypress](https://github.com/joomla-projects/joomla-cypress/)** and
2323
**[smtp-tester](https://www.npmjs.com/package/smtp-tester)**.
@@ -26,19 +26,32 @@ The **Joomla** CMS server software is depicted on the right. It runs with PHP on
2626
several key components: the public **User-Frontend**, the administrator **Admin-Backend**, the **API**, and the **Web-Installer**. These components and their interactions will be detailed later in the document.
2727
The file **`configuration.php`** is used to configure settings for Joomla server software.
2828

29-
Joomla uses a **Database**, and the System Tests do as well.
29+
Joomla uses a **Database**, and the Joomla System Tests do as well.
3030

3131

3232
## Installation
3333

34-
Joomla System Tests work on different operating systems such as macOS, desktop Linux distributions like Ubuntu,
35-
and Windows (using WSL 2 or a framework like Laragon). They also work well with Docker containers.
36-
You will need a Web Server and a database like MariaDB running.
34+
Joomla System Tests are compatible with various operating systems, including macOS, desktop Linux distributions like Ubuntu, and Windows (using WSL 2 or frameworks like Laragon).
35+
They are fully compatible with the official [Joomla Docker containers](https://hub.docker.com/_/joomla).
36+
37+
To run these tests, you will need a web server (e.g. Apache) and a database (e.g. MariaDB).
38+
Ensure the web server is configured to load the `rewrite_module` and allow directory overrides. For example, in Apache:
39+
40+
```apache
41+
# Load the rewrite module
42+
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
43+
44+
# Configure directory overrides
45+
<Directory "...">
46+
AllowOverride All
47+
</Directory>
48+
```
49+
3750
Before getting started, please ensure you have the following prerequisites installed:
3851
[PHP](https://www.php.net/), [Git](https://git-scm.com/), [npm](https://www.npmjs.com/),
3952
and [Composer](https://getcomposer.org/).
4053

41-
The following steps are required for the installation of the CMS System Tests.
54+
The following steps are required for the installation of the Joomla System Tests.
4255

4356
1. Clone Joomla into an empty folder (e.g. `/var/www/html`) where it can be served by a Web Server
4457
```
@@ -58,7 +71,7 @@ cp cypress.config.dist.mjs cypress.config.mjs
5871
5. Adapt the env variables in the file `cypress.config.mjs`, they should point to the site, user data and database environment. Ensure that the `smtp_port` is not in use on your system.
5972

6073

61-
## Running System Tests
74+
## Running Joomla System Tests
6275

6376
After installation, you can start the Joomla System Tests with headless Cypress. The test suite starts with Joomla Web-Installer as the first test step.
6477
```
@@ -86,34 +99,35 @@ npx cypress run --spec 'tests/System/integration/{administrator,site,api,plugins
8699
> npm run cypress:open
87100
> ```
88101
89-
If you are running System Tests, you will see `console.log()` outputs from Cypress Tasks in the Node.js environment. If you would like to see `console.log()` output from the browser in headless mode as well, you can use the Electron web browser and set the following environment variable:
102+
If you are running Joomla System Tests, you will see `console.log()` outputs from Cypress Tasks in the Node.js environment. If you would like to see `console.log()` output from the browser in headless mode as well, you can use the Electron web browser and set the following environment variable:
90103
```
91104
export ELECTRON_ENABLE_LOGGING=1
92105
npm run cypress:run --browser electron
93106
```
94107
95108
96-
## Software Architecture – More Detailed
109+
## Software Architecture Details
97110
98-
Since many interactions in System Tests are involved, the following image illustrates 10 simplified interactions,
111+
Since Joomla System Tests involve many interactions, the following image illustrates 10 simplified interactions,
99112
which are numbered and described below.
100113
101-
![System Tests Architecture with 10 Interactions](images/system-tests-interactions.svg)
114+
![Joomla System Tests Architecture with 10 Interactions](images/system-tests-interactions.svg)
102115
103116
1. **Cypress** starts the **Browser** and runs **Cypress Test Runner** to control Joomla running in the browser and access the DOM.
104117
2. **Joomla** software running in the browser sends requests to the **Web Server** and receives responses just as it would during normal use, even without tests.
105118
3. The Cypress custom **API commands** (described later) interact with the Joomla **API** on the Web Server.
106119
4. Cypress **Tasks** are used to execute code within the Cypress Node.js context. These tasks are triggered by the Cypress Test Runner, which runs in the browser, and are typically used for operations like
107120
interacting with the file system.
108121
5. Joomla on the Web Server interacts with the **Database** as it normally would, without running any tests.
109-
6. System Tests has Cypress custom **Database Commands** (described later) to interact with the database.
110-
7. The file `cypress.config.mjs` is read by **Cypress** and used to configure settings and preferences for running the System Tests in your environment.
122+
6. Joomla System Tests has Cypress custom **Database Commands** (described later) to interact with the database.
123+
7. The file `cypress.config.mjs` is read by **Cypress** and used to configure settings and
124+
preferences for running the Joomla System Tests in your environment.
111125
8. The Joomla installation is initiated by the test spec [Installation.cy.js](integration/install/Installation.cy.js),
112126
which is the first test executed in the overall test suite.
113127
This test spec deletes the Joomla configuration file, and since the `configuration.php` file no longer exists,
114128
the following Joomla Web-Installer call starts the installation process, including database creation.
115129
To ensure that this initial test spec runs correctly, the `installation` folder must not be deleted,
116-
allowing the System Tests to be executed multiple times.
130+
allowing the Joomla System Tests to be executed multiple times.
117131
After the Joomla Web-Installer completes, [Installation.cy.js](integration/install/Installation.cy.js)
118132
modifies some parameters in the `configuration.php` file, such as SMTP settings or the API `$secret`.
119133
9. Joomla Web-Installer creates `configuration.php` file. For security reasons, the file mask is set to read-only (444).
@@ -178,7 +192,7 @@ The following code in a test executes the writing file task with parameters:
178192
### Commands
179193

180194
We are using [custom commands](https://docs.cypress.io/api/cypress-api/custom-commands) to enhance Cypress
181-
with reusable code snippets for the System Tests.
195+
with reusable code snippets for the Joomla System Tests.
182196
These commands can be used to create objects in the database or to call the API.
183197
Since Cypress doesn't support namespaces for commands, we prefix them in the function name.
184198
Therefore, a Database Command always starts with `db_`, and an API command with `api_`.
@@ -221,7 +235,7 @@ The following commands are available and are served by the file [tests/System/su
221235
- **db_updateExtensionParameter** – Sets the parameter for the given extension
222236

223237

224-
#### API commands
238+
#### API Commands
225239

226240
The API commands make API requests to the CMS API endpoint `/api/index.php/v1`.
227241
They are asynchronous and must be chained like:
@@ -240,6 +254,23 @@ The following commands are available and are served by the file
240254
- **api_responseContains** – Checks if the given attribute in the response contains the specified value
241255

242256

257+
#### Config Commands
258+
259+
There is a single config command provided by the file
260+
[tests/System/support/commands/config.mjs](/tests/System/support/commands/config.mjs):
261+
262+
- **config_setParameter** - Sets a parameter in `configuration.php` file
263+
264+
Even tough `config_setParameter` is a Cypress command running in the browser context,
265+
it uses `cy.readFile()` and the Cypress task `writeRelativeFile` to delegate file system operations to Node.js,
266+
as browsers cannot access the filesystem directly.
267+
268+
This command is asynchronous and must be chained, as shown below:
269+
```JavaScript
270+
cy.config_setParameter('sef', false).then(() => { ... })`
271+
```
272+
273+
243274
### Developer Tips
244275
245276
#### Running a Single Test
@@ -264,7 +295,7 @@ cy.wait(20000); // waits for 20 seconds
264295
265296
## Troubleshooting
266297
267-
### Errors 'EACCES: permission denied' or 'EPERM: operation not permitted'
298+
### Error 'EACCES: permission denied' or 'EPERM: operation not permitted'
268299
269300
If the Cypress installation step or the entire test suite is executed by a non-root user, the following error may occur:
270301
```
@@ -312,7 +343,7 @@ but you still need to configure `cypress.config.mjs` file.
312343

313344
### Timeout Error on Slow Machines
314345

315-
If you encounter the following error while running the System Tests on slow machines:
346+
If you encounter the following error while running the Joomla System Tests on slow machines:
316347

317348
```
318349
AssertionError: Timed out retrying after 4000ms: Expected to find element

0 commit comments

Comments
 (0)