Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 95 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.2', '8.3', '8.4']
php-versions: ["8.2", "8.3", "8.4"]
steps:
- uses: actions/checkout@v2

Expand All @@ -31,30 +31,30 @@ jobs:
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

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

# - name: Monitor coverage
# if: github.event_name == 'pull_request'
# uses: slavcodev/coverage-monitor-action@1.2.0
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# clover_file: "clover.xml"
# threshold_alert: 10
# threshold_warning: 20
# - name: Monitor coverage
# if: github.event_name == 'pull_request'
# uses: slavcodev/coverage-monitor-action@1.2.0
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# clover_file: "clover.xml"
# threshold_alert: 10
# threshold_warning: 20

verification-tests:
name: Verification Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['8.2', '8.3', '8.4']
php-versions: ["8.2", "8.3", "8.4"]
steps:
- uses: actions/checkout@v2

Expand All @@ -72,7 +72,7 @@ jobs:
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
Expand All @@ -86,7 +86,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.2', '8.3', '8.4']
php-versions: ["8.2", "8.3", "8.4"]
steps:
- uses: actions/checkout@v2

Expand All @@ -104,7 +104,7 @@ jobs:
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
Expand All @@ -118,15 +118,15 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.2', '8.3', '8.4']
php-versions: ["8.2", "8.3", "8.4"]

services:
chrome:
image: selenium/standalone-chrome:3.141.59-zirconium
ports:
- 4444:4444
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@master
Expand All @@ -136,18 +136,95 @@ jobs:

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run tests
run: bin/functional

testrigor-tests:
name: testRigor Tests
runs-on: ubuntu-latest

env:
# testRigor variables
MAGENTO_TEST_SUITE_ID: ${{vars.MAGENTO_TEST_SUITE_ID}}
MAGENTO_AUTH_TOKEN: ${{secrets.MAGENTO_AUTH_TOKEN}}

# MFTF Magento connection variables
MAGENTO_BASE_URL: ${{vars.MAGENTO_BASE_URL}}
MAGENTO_BACKEND_NAME: ${{vars.MAGENTO_BACKEND_NAME}}
MAGENTO_ADMIN_USERNAME: ${{vars.MAGENTO_ADMIN_USERNAME}}
MAGENTO_ADMIN_PASSWORD: ${{secrets.MAGENTO_ADMIN_PASSWORD}}

# MFTF configuration
SELENIUM_CLOSE_ALL_SESSIONS: true
BROWSER: chrome
WINDOW_WIDTH: 1920
WINDOW_HEIGHT: 1080
WAIT_TIMEOUT: 60
MAGENTO_CLI_WAIT_TIMEOUT: 60
TEST_ENV: ci
HEADLESS: true

services:
chrome:
image: selenium/standalone-chrome:3.141.59-zirconium
ports:
- 4444:4444

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: "8.2"
extensions: curl, dom, intl, json, openssl, zip

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Verify Magento connection
run: |
echo "Testing connection to $MAGENTO_BASE_URL"
curl -f -s -o /dev/null $MAGENTO_BASE_URL || echo "Warning: Cannot connect to Magento"

- name: Build MFTF project
run: php bin/mftf build:project

- name: Verify MFTF configuration
run: php bin/mftf doctor || true

- name: Run testRigor tests
run: |
echo "Running MFTF testRigor tests..."
php bin/mftf run:testrigor

- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: mftf-test-artifacts
path: |
dev/tests/acceptance/_output/
var/log/
retention-days: 7
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
composer.phar
vendor/*
.env
node_modules/
package-lock.json
.mftf-tools/
_generated
AcceptanceTester.php
cghooks.lock
Expand Down
1 change: 0 additions & 1 deletion bin/mftf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ try {
exit(1);
}


try {
$version = json_decode(file_get_contents(FW_BP . DIRECTORY_SEPARATOR . 'composer.json'), true);
$version = $version['version'];
Expand Down
12 changes: 12 additions & 0 deletions bin/testrigor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
echo "==============================="
echo " EXECUTE testRigor Tests "
echo "==============================="

echo "Building MFTF project..."
bin/mftf build:project

echo "$MAGENTO_BASE_URL"

echo "Running testRigor tests..."
chmod +x ./dev/tests/testRigor/testrigor && ./dev/tests/testRigor/testrigor
105 changes: 105 additions & 0 deletions dev/tests/testRigor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Test Automation with testRigor for Magento

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.

## Table of Contents

- [Creating an Account on testRigor](#creating-an-account-on-testrigor)
- [Running Tests with the CLI](#running-tests-with-the-cli)
- [Additional Resources](#additional-resources)

## Creating an Account on testRigor

1. **Visit the testRigor website:**

- Go to [testRigor](https://www.testrigor.com/).

2. **Sign up for a new account:**

- Click on the "Sign Up" button on the top right corner.
- Select the "Public Open Source" version.
- Fill in the required details and follow the instructions to complete the registration.

3. **Verify your email and log in:**

- Check your email inbox for a verification email from testRigor.
- Click on the verification link to activate your account.
- Once your account is activated, log in.

4. **Create a test suite:**
- After logging into your account, create a test suite.

## Running Tests with the CLI

1. **Prerequisites:**

- **None!** MFTF will automatically download and install all required dependencies (Node.js and TestRigor CLI) on first run.
- Everything is installed locally within the project, requiring zero manual setup.
- The framework is fully self-contained and ready for CI/CD environments.

2. **Obtain Required Parameters:**

- **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.
- **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 `########-####-####-####-############`.

3. **Set Parameters in `.env` file:**

- Before running the tests, create a .env file on the testRigor directory and set the following variables to the parameters you obtained:
- `MAGENTO_TEST_SUITE_ID`: Set this variable to your Test Suite ID.
- `MAGENTO_AUTH_TOKEN`: Set this variable to your auth token.
- `MAGENTO_BASE_URL`: Set this variable to the URL where Magento is running locally.

Example `.env` file:
```
MAGENTO_TEST_SUITE_ID=12345
MAGENTO_AUTH_TOKEN=########-####-####-####-############
MAGENTO_BASE_URL=http://localhost:8080
```

4. **Run Tests:**

```bash
bin/mftf run:testrigor
```

The command will:
- Automatically check if Node.js and TestRigor CLI are installed
- Download and install them locally if not found (no manual installation needed!)
- Load environment variables from the `.env` file in the project root
- Execute your TestRigor test suite

5. **View Test Results:**
- You can view the results on testRigor by opening the link shown in the terminal.

## Troubleshooting

### Automatic Installation Issues

MFTF handles all installations automatically. If you encounter issues:

1. **Check for curl:**
```bash
curl --version
```
The framework uses `curl` to download Node.js. Most systems have it pre-installed.

2. **Verify disk space:**
Ensure you have at least 100MB of free disk space for Node.js and dependencies.

3. **Check file permissions:**
The framework creates a `.mftf-tools` directory in the project root. Ensure the directory is writable.

4. **Manual cleanup:**
If installation fails, try removing cached files:
```bash
rm -rf .mftf-tools node_modules
```
Then run the command again.

5. **Using system Node.js:**
If you already have Node.js 18+ installed system-wide, MFTF will detect and use it automatically, skipping the download.

## Additional Resources

- [testRigor Documentation](https://docs.testrigor.com/)
- [testRigor Command Line Documentation](https://testrigor.com/command-line/)
6 changes: 6 additions & 0 deletions dev/tests/testRigor/rules/add_any_item_to_the_cart.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
click "New Luma Yoga Collection Get fit and look fab in new seasonal styles Shop New Yoga"
click "Ida Workout Parachute Pant"
click "28"
click "Blue"
click "Add to Cart"
check if page contains "Add to Cart"
9 changes: 9 additions & 0 deletions dev/tests/testRigor/rules/create_an_account.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
click "Create an Account"
generate from template "%$$$$$$", then enter into "First Name" and save it as "firstName"
generate from template "%$$$$$$", then enter into "Last Name" and save it as "lastName"
generate unique email, then enter into "Email" and save as "Email"
enter stored value "password" into "Password"
enter stored value "password" into "Confirm Password"
click "Create an Account" below "Confirm Password"
validate that page contains "Thank you for registering"
validate that page contains string with parameters "Welcome, ${firstName} ${lastName}"
10 changes: 10 additions & 0 deletions dev/tests/testRigor/rules/proceed_to_checkout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
click "Proceed to Checkout"
wait 1 sec until page contains "Shipping Address"
fill out required fields of form "Shipping Address" with generated values
select "Alabama" from "State/Province"
generate from template "#####", then enter into field "Zip/Postal code"
generate from template "#########", then enter into field "Phone Number"
click "$" roughly below "Shipping methods"
validate that page contains button "Next"
click "Next"
click "Place Order"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scroll down
click "Cronus Yoga Pant"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
click "Josie Yoga Jacket"
click "XS"
click "Blue"
click "Add to Cart"
Empty file.
1 change: 1 addition & 0 deletions dev/tests/testRigor/testcases/Before_testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
validate that page contains "Default welcome msg!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
create an account
open url saved value "homePrefix"
add any item to the cart
scroll up until page contains "shopping cart"
click button "shopping cart"
proceed to checkout
validate that page contains "Thank you for your purchase!"
validate that page has regex "Your order number is: [0-9]{9}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
click "Women"
click "Bras & Tanks"
check if page contains "Tank" above "$" and roughly below "Shopping Options"
scroll down until page contains "Page 2"
click "Page 2"
check if page contains "Bra" above "$" and roughly below "Shopping Options"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
hover over "Women"
click "Tops"
click "Breathe-Easy Tank"
click "XS"
click "Yellow"
click "Add to Cart"
click button "shopping cart"
validate that page contains "Breathe-Easy tank" roughly below "Item"
Loading