Skip to content

Commit 7ab7f06

Browse files
committed
Add new E2E testRigor tests
Add ci integration Refactor PHP version specification and enhance testRigor workflow with connection verification and artifact upload
1 parent 0cfbc78 commit 7ab7f06

File tree

23 files changed

+816
-19
lines changed

23 files changed

+816
-19
lines changed

.github/workflows/main.yml

Lines changed: 95 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
php-versions: ['8.2', '8.3', '8.4']
15+
php-versions: ["8.2", "8.3", "8.4"]
1616
steps:
1717
- uses: actions/checkout@v2
1818

@@ -31,30 +31,30 @@ jobs:
3131
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
3232
restore-keys: |
3333
${{ runner.os }}-php-
34-
34+
3535
- name: Install dependencies
3636
if: steps.composer-cache.outputs.cache-hit != 'true'
3737
run: composer install --prefer-dist --no-progress --no-suggest
3838

3939
- name: Run tests
4040
run: vendor/bin/phpunit --configuration dev/tests/phpunit.xml --testsuite unit --coverage-clover clover.xml
4141

42-
# - name: Monitor coverage
43-
# if: github.event_name == 'pull_request'
44-
# uses: slavcodev/coverage-monitor-action@1.2.0
45-
# with:
46-
# github_token: ${{ secrets.GITHUB_TOKEN }}
47-
# clover_file: "clover.xml"
48-
# threshold_alert: 10
49-
# threshold_warning: 20
42+
# - name: Monitor coverage
43+
# if: github.event_name == 'pull_request'
44+
# uses: slavcodev/coverage-monitor-action@1.2.0
45+
# with:
46+
# github_token: ${{ secrets.GITHUB_TOKEN }}
47+
# clover_file: "clover.xml"
48+
# threshold_alert: 10
49+
# threshold_warning: 20
5050

5151
verification-tests:
5252
name: Verification Tests
5353
runs-on: ubuntu-latest
5454
strategy:
5555
fail-fast: false
5656
matrix:
57-
php-versions: ['8.2', '8.3', '8.4']
57+
php-versions: ["8.2", "8.3", "8.4"]
5858
steps:
5959
- uses: actions/checkout@v2
6060

@@ -72,7 +72,7 @@ jobs:
7272
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
7373
restore-keys: |
7474
${{ runner.os }}-php-
75-
75+
7676
- name: Install dependencies
7777
if: steps.composer-cache.outputs.cache-hit != 'true'
7878
run: composer install --prefer-dist --no-progress --no-suggest
@@ -86,7 +86,7 @@ jobs:
8686
strategy:
8787
fail-fast: false
8888
matrix:
89-
php-versions: ['8.2', '8.3', '8.4']
89+
php-versions: ["8.2", "8.3", "8.4"]
9090
steps:
9191
- uses: actions/checkout@v2
9292

@@ -104,7 +104,7 @@ jobs:
104104
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
105105
restore-keys: |
106106
${{ runner.os }}-php-
107-
107+
108108
- name: Install dependencies
109109
if: steps.composer-cache.outputs.cache-hit != 'true'
110110
run: composer install --prefer-dist --no-progress --no-suggest
@@ -118,15 +118,15 @@ jobs:
118118
strategy:
119119
fail-fast: false
120120
matrix:
121-
php-versions: ['8.2', '8.3', '8.4']
121+
php-versions: ["8.2", "8.3", "8.4"]
122122

123123
services:
124124
chrome:
125125
image: selenium/standalone-chrome:3.141.59-zirconium
126126
ports:
127127
- 4444:4444
128128
steps:
129-
- uses: actions/checkout@v2
129+
- uses: actions/checkout@v4
130130

131131
- name: Setup PHP
132132
uses: shivammathur/setup-php@master
@@ -136,18 +136,95 @@ jobs:
136136

137137
- name: Cache Composer packages
138138
id: composer-cache
139-
uses: actions/cache@v2
139+
uses: actions/cache@v4
140140
with:
141141
path: vendor
142142
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
143143
restore-keys: |
144144
${{ runner.os }}-php-
145-
145+
146146
- name: Install dependencies
147147
if: steps.composer-cache.outputs.cache-hit != 'true'
148148
run: composer install --prefer-dist --no-progress --no-suggest
149149

150150
- name: Run tests
151151
run: bin/functional
152152

153+
testrigor-tests:
154+
name: testRigor Tests
155+
runs-on: ubuntu-latest
156+
157+
env:
158+
# testRigor variables
159+
MAGENTO_TEST_SUITE_ID: ${{vars.MAGENTO_TEST_SUITE_ID}}
160+
MAGENTO_AUTH_TOKEN: ${{secrets.MAGENTO_AUTH_TOKEN}}
161+
162+
# MFTF Magento connection variables
163+
MAGENTO_BASE_URL: ${{vars.MAGENTO_BASE_URL}}
164+
MAGENTO_BACKEND_NAME: ${{vars.MAGENTO_BACKEND_NAME}}
165+
MAGENTO_ADMIN_USERNAME: ${{vars.MAGENTO_ADMIN_USERNAME}}
166+
MAGENTO_ADMIN_PASSWORD: ${{secrets.MAGENTO_ADMIN_PASSWORD}}
167+
168+
# MFTF configuration
169+
SELENIUM_CLOSE_ALL_SESSIONS: true
170+
BROWSER: chrome
171+
WINDOW_WIDTH: 1920
172+
WINDOW_HEIGHT: 1080
173+
WAIT_TIMEOUT: 60
174+
MAGENTO_CLI_WAIT_TIMEOUT: 60
175+
TEST_ENV: ci
176+
HEADLESS: true
153177

178+
services:
179+
chrome:
180+
image: selenium/standalone-chrome:3.141.59-zirconium
181+
ports:
182+
- 4444:4444
183+
184+
steps:
185+
- uses: actions/checkout@v4
186+
187+
- name: Setup PHP
188+
uses: shivammathur/setup-php@master
189+
with:
190+
php-version: "8.2"
191+
extensions: curl, dom, intl, json, openssl, zip
192+
193+
- name: Cache Composer packages
194+
id: composer-cache
195+
uses: actions/cache@v4
196+
with:
197+
path: vendor
198+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
199+
restore-keys: |
200+
${{ runner.os }}-php-
201+
202+
- name: Install dependencies
203+
if: steps.composer-cache.outputs.cache-hit != 'true'
204+
run: composer install --prefer-dist --no-progress --no-suggest
205+
206+
- name: Verify Magento connection
207+
run: |
208+
echo "Testing connection to $MAGENTO_BASE_URL"
209+
curl -f -s -o /dev/null $MAGENTO_BASE_URL || echo "Warning: Cannot connect to Magento"
210+
211+
- name: Build MFTF project
212+
run: php bin/mftf build:project
213+
214+
- name: Verify MFTF configuration
215+
run: php bin/mftf doctor || true
216+
217+
- name: Run testRigor tests
218+
run: |
219+
echo "Running MFTF testRigor tests..."
220+
php bin/mftf run:testrigor
221+
222+
- name: Upload test artifacts
223+
if: failure()
224+
uses: actions/upload-artifact@v4
225+
with:
226+
name: mftf-test-artifacts
227+
path: |
228+
dev/tests/acceptance/_output/
229+
var/log/
230+
retention-days: 7

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
composer.phar
33
vendor/*
44
.env
5+
node_modules/
6+
package-lock.json
7+
.mftf-tools/
58
_generated
69
AcceptanceTester.php
710
cghooks.lock

bin/mftf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ try {
2525
exit(1);
2626
}
2727

28-
2928
try {
3029
$version = json_decode(file_get_contents(FW_BP . DIRECTORY_SEPARATOR . 'composer.json'), true);
3130
$version = $version['version'];

bin/testrigor

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
echo "==============================="
3+
echo " EXECUTE testRigor Tests "
4+
echo "==============================="
5+
6+
echo "Building MFTF project..."
7+
bin/mftf build:project
8+
9+
echo "$MAGENTO_BASE_URL"
10+
11+
echo "Running testRigor tests..."
12+
chmod +x ./dev/tests/testRigor/testrigor && ./dev/tests/testRigor/testrigor

dev/tests/testRigor/README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Test Automation with testRigor for Magento
2+
3+
This document provides step-by-step instructions for setting up test automation for Magento using testRigor. It covers creating an account, setting up a test suite, and running tests using the testRigor CLI.
4+
5+
## Table of Contents
6+
7+
- [Creating an Account on testRigor](#creating-an-account-on-testrigor)
8+
- [Running Tests with the CLI](#running-tests-with-the-cli)
9+
- [Additional Resources](#additional-resources)
10+
11+
## Creating an Account on testRigor
12+
13+
1. **Visit the testRigor website:**
14+
15+
- Go to [testRigor](https://www.testrigor.com/).
16+
17+
2. **Sign up for a new account:**
18+
19+
- Click on the "Sign Up" button on the top right corner.
20+
- Select the "Public Open Source" version.
21+
- Fill in the required details and follow the instructions to complete the registration.
22+
23+
3. **Verify your email and log in:**
24+
25+
- Check your email inbox for a verification email from testRigor.
26+
- Click on the verification link to activate your account.
27+
- Once your account is activated, log in.
28+
29+
4. **Create a test suite:**
30+
- After logging into your account, create a test suite.
31+
32+
## Running Tests with the CLI
33+
34+
1. **Prerequisites:**
35+
36+
- **None!** MFTF will automatically download and install all required dependencies (Node.js and TestRigor CLI) on first run.
37+
- Everything is installed locally within the project, requiring zero manual setup.
38+
- The framework is fully self-contained and ready for CI/CD environments.
39+
40+
2. **Obtain Required Parameters:**
41+
42+
- **Test Suite ID:** You can obtain the Test Suite ID in the URL of your test suite. If the URL is `https://app.testrigor.com/test-suites/12345`, then `12345` is your Test Suite ID.
43+
- **Auth Token:** You can obtain your token from the "CI/CD integration" section on testRigor. Look for "auth-token" and copy the value next to it, which will be in the format `########-####-####-####-############`.
44+
45+
3. **Set Parameters in `.env` file:**
46+
47+
- Before running the tests, create a .env file on the testRigor directory and set the following variables to the parameters you obtained:
48+
- `MAGENTO_TEST_SUITE_ID`: Set this variable to your Test Suite ID.
49+
- `MAGENTO_AUTH_TOKEN`: Set this variable to your auth token.
50+
- `MAGENTO_BASE_URL`: Set this variable to the URL where Magento is running locally.
51+
52+
Example `.env` file:
53+
```
54+
MAGENTO_TEST_SUITE_ID=12345
55+
MAGENTO_AUTH_TOKEN=########-####-####-####-############
56+
MAGENTO_BASE_URL=http://localhost:8080
57+
```
58+
59+
4. **Run Tests:**
60+
61+
```bash
62+
bin/mftf run:testrigor
63+
```
64+
65+
The command will:
66+
- Automatically check if Node.js and TestRigor CLI are installed
67+
- Download and install them locally if not found (no manual installation needed!)
68+
- Load environment variables from the `.env` file in the project root
69+
- Execute your TestRigor test suite
70+
71+
5. **View Test Results:**
72+
- You can view the results on testRigor by opening the link shown in the terminal.
73+
74+
## Troubleshooting
75+
76+
### Automatic Installation Issues
77+
78+
MFTF handles all installations automatically. If you encounter issues:
79+
80+
1. **Check for curl:**
81+
```bash
82+
curl --version
83+
```
84+
The framework uses `curl` to download Node.js. Most systems have it pre-installed.
85+
86+
2. **Verify disk space:**
87+
Ensure you have at least 100MB of free disk space for Node.js and dependencies.
88+
89+
3. **Check file permissions:**
90+
The framework creates a `.mftf-tools` directory in the project root. Ensure the directory is writable.
91+
92+
4. **Manual cleanup:**
93+
If installation fails, try removing cached files:
94+
```bash
95+
rm -rf .mftf-tools node_modules
96+
```
97+
Then run the command again.
98+
99+
5. **Using system Node.js:**
100+
If you already have Node.js 18+ installed system-wide, MFTF will detect and use it automatically, skipping the download.
101+
102+
## Additional Resources
103+
104+
- [testRigor Documentation](https://docs.testrigor.com/)
105+
- [testRigor Command Line Documentation](https://testrigor.com/command-line/)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
click "New Luma Yoga Collection Get fit and look fab in new seasonal styles Shop New Yoga"
2+
click "Ida Workout Parachute Pant"
3+
click "28"
4+
click "Blue"
5+
click "Add to Cart"
6+
check if page contains "Add to Cart"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
click "Create an Account"
2+
generate from template "%$$$$$$", then enter into "First Name" and save it as "firstName"
3+
generate from template "%$$$$$$", then enter into "Last Name" and save it as "lastName"
4+
generate unique email, then enter into "Email" and save as "Email"
5+
enter stored value "password" into "Password"
6+
enter stored value "password" into "Confirm Password"
7+
click "Create an Account" below "Confirm Password"
8+
validate that page contains "Thank you for registering"
9+
validate that page contains string with parameters "Welcome, ${firstName} ${lastName}"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
click "Proceed to Checkout"
2+
wait 1 sec until page contains "Shipping Address"
3+
fill out required fields of form "Shipping Address" with generated values
4+
select "Alabama" from "State/Province"
5+
generate from template "#####", then enter into field "Zip/Postal code"
6+
generate from template "#########", then enter into field "Phone Number"
7+
click "$" roughly below "Shipping methods"
8+
validate that page contains button "Next"
9+
click "Next"
10+
click "Place Order"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
scroll down
2+
click "Cronus Yoga Pant"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
click "Josie Yoga Jacket"
2+
click "XS"
3+
click "Blue"
4+
click "Add to Cart"

0 commit comments

Comments
 (0)