Skip to content

Commit

Permalink
test (e2e): Add new e2e testRigor tests
Browse files Browse the repository at this point in the history
E2e cover of the main functionalities
CI added to build.yml
  • Loading branch information
amandassa-tR committed Feb 12, 2025
1 parent 10fcf28 commit 2f8deff
Show file tree
Hide file tree
Showing 28 changed files with 316 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:
name: Run Lint and Deploy
runs-on: ubuntu-latest

# testRigor values for workflow testing
env:
MIFOS_TEST_SUITE_ID: ${{ secrets.TEST_SUITE_ID }}
MIFOS_AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
Expand Down Expand Up @@ -46,6 +51,12 @@ jobs:
- name: Run build
run: npm run build:prod

- name: Install testRigor Command Line
run : npm install -g --verbose testrigor-cli

- name: Run testRigor tests
run: . ../../e2e/testRigor/run_testrigor_tests.sh

- name: Deploy to github pages
if: ${{ github.event_name == 'push' }}
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
60 changes: 60 additions & 0 deletions e2e/testRigor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Test Automation with testRigor for MIFOS

This document provides step-by-step instructions for setting up test automation for MIFOS 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 sute:**
- After logging into your account, create a test suite.

## Running Tests with the CLI

1. **Install testRigor CLI:**
- Ensure you have Node.js installed on your machine (version 18 or higher).
- Install the testRigor CLI globally using npm:
```bash
npm install -g testrigor
```

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 `run_testrigor_tests.sh`:**
- Before running the tests, create a .env file on the testRigor directory and set the following variables to the parameters you obtained:
- `MIFOS_TEST_SUITE_ID`: Set this variable to your Test Suite ID.
- `MIFOS_AUTH_TOKEN`: Set this variable to your auth token.
- `LOCALHOST_URL`: Set this variable to the URL where MIFOS
is running locally.

4. **Run Tests:**
```bash
./run_testrigor_tests.sh
```

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

## Additional Resources

- [testRigor Documentation](https://docs.testrigor.com/)
- [testRigor Command Line Documentation](https://testrigor.com/command-line/)
1 change: 1 addition & 0 deletions e2e/testRigor/rules/close-popup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
click "Close" below "Warning" if exists
8 changes: 8 additions & 0 deletions e2e/testRigor/rules/create-account.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
click "Account Type"
click "INCOME"
generate unique name, then enter into "Account Name" and save as "glAccountName"
click "Account Usage"
click "DETAIL"
generate unique name, then enter into "GL Code" and save as "glCode"
click "Submit"
check that page doesn't contain "Submit"
15 changes: 15 additions & 0 deletions e2e/testRigor/rules/create-admin-user.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
click "Create User"
generate unique name, then enter into "First Name" and save as "firstName"
generate unique name, then enter into "Last Name" and save as "lastName"
generate unique name, then enter into "Username" and save as "username"
generate unique email, then enter into "Email" and save as "email"
click "Send password to email address"
save value "Mifos!123" as "password"
enter stored value "password" into "Password"
enter stored value "password" into "Repeat Password"
click "Office"
click "Head Office"
click "Roles"
click "Super User"
click "Submit"
click "Submit"
11 changes: 11 additions & 0 deletions e2e/testRigor/rules/create-client.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
click "Create Client"
generate unique name, then enter into "First Name" and save as "firstName"
generate unique name, then enter into "Last Name" and save as "lastName"
generate from template "*******", then enter into "External ID" and save as "externalID"
click "Office"
click "Head Office"
pick-birthdate // birthDate
generate unique email, then enter into "Email Address" and save as "email"
generate from template "+##-###-###-####", then enter into "Mobile No" and save as "mobileNo"
click "Next"
click "Next"
12 changes: 12 additions & 0 deletions e2e/testRigor/rules/create-organization.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
click "Create Office"
generate unique name, then enter into "Office" and save as "officeName"
generate unique name, then enter into "External ID" and save as "externalID"
click "Parent Office"
click "Head Office"
pick-today-date
click "Submit"
// validate organization created
enter saved value "officeName" into "Filter"
check that page contains saved value "officeName" roughly below "Office Name"
check that page contains saved value "externalID" roughly below "External ID"
check that page contains string with parameters "${todayDayOfMonth} ${todayMonth} ${todayYear}" roughly below "Opened On"
5 changes: 5 additions & 0 deletions e2e/testRigor/rules/log-in-and-validate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enter saved value "username" into field "Username"
enter saved value "password" into field "Password"
click exactly "Login"
close-popup
check that page contains string with parameters "Welcome, ${username}!"
2 changes: 2 additions & 0 deletions e2e/testRigor/rules/logout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
click third "menu" on the right of "Search"
click "Sign Out"
3 changes: 3 additions & 0 deletions e2e/testRigor/rules/navigate-to-accounting-creation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
click "Accounting"
click "Chart of Accounts"
click "Add Account"
2 changes: 2 additions & 0 deletions e2e/testRigor/rules/navigate-to-admin-users-management.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
click "Admin"
click "Users" below "Admin"
2 changes: 2 additions & 0 deletions e2e/testRigor/rules/navigate-to-clients.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
click "Institution"
click "Clients" below "Institution"
3 changes: 3 additions & 0 deletions e2e/testRigor/rules/navigate-to-offices.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
click "Admin"
click "Organization" below "Admin"
click "Manage Offices"
8 changes: 8 additions & 0 deletions e2e/testRigor/rules/pick-birthdate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
click field "Date Of Birth"
click string with parameters "${todayMonthShort} ${todayYear}"
// calculate today year - 20 and save as birthYear
save expression "${todayYear} - 20" as "birthYear"
click exactly saved value "birthYear"
click saved value "todayMonthShort"
pick-today-date
save string with parameters "${todayDayOfMonth} ${todayMonth} ${birthYear}" as "birthDate"
2 changes: 2 additions & 0 deletions e2e/testRigor/rules/pick-today-date.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
click field "Opened On" if exists
click exactly saved value "todayDayOfMonth" roughly below saved value "todayMonthShort"
4 changes: 4 additions & 0 deletions e2e/testRigor/rules/validate-login-page.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
check that page contains field "Username"
check that page contains field "Password"
check that page contains button "Login"
check that page contains button "Forgot Password?"
17 changes: 17 additions & 0 deletions e2e/testRigor/run_testrigor_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
COMMIT_NAME="$(git rev-parse --verify HEAD)"

# Define default values for missing variables

# MIFOS_TEST_SUITE_ID="${TEST_SUITE_ID}"
# MIFOS_AUTH_TOKEN="${AUTH_TOKEN}"
LOCALHOST_URL="http://localhost"

# Paths for the test cases and rules files
TEST_CASES_PATH="e2e/testRigor/testcases/**/*.txt"
RULES_PATH="e2e/testRigor/rules/**/*.txt"

# Command to run the tests using the testRigor CLI
testrigor test-suite run "$MIFOS_TEST_SUITE_ID" --token "$MIFOS_AUTH_TOKEN" --localhost --url "$LOCALHOST_URL" --test-cases-path "$TEST_CASES_PATH" --rules-path "$RULES_PATH" --branch "$BRANCH_NAME" --commit "$COMMIT_NAME"
8 changes: 8 additions & 0 deletions e2e/testRigor/testcases/create-account.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
log-in-and-validate
navigate-to-accounting-creation
create-account
click "Chart of Accounts"
//validate account created
check that page contains "Filter"
enter saved value "glAccountName" into "Filter"
check that page contains saved value "glAccountName" below saved value "glAccountName"
16 changes: 16 additions & 0 deletions e2e/testRigor/testcases/create-admin-user.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
log-in-and-validate
navigate-to-admin-users-management
create-admin-user
check that page contains saved value "username" on the right of "Login Name"
check that page contains saved value "firstName" on the right of "First Name"
check that page contains saved value "lastName" on the right of "Last Name"
check that page contains saved value "email" on the right of "Email"
navigate-to-admin-users-management
//validate admin profile in table
enter saved value "firstName" into "Filter"
check that page contains saved value "firstName" below saved value "firstName"
check that page contains saved value "lastName" below saved value "firstName"
check that page contains saved value "email" below saved value "firstName"
//validate login new admin profile
logout
log-in-and-validate
21 changes: 21 additions & 0 deletions e2e/testRigor/testcases/create-client.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
log-in-and-validate
navigate-to-clients
create-client
//validate in preview
check that page contains saved value "firstName" on the right of "Name"
check that page contains saved value "lastName" on the right of "Name"
check that page contains saved value "externalID" on the right of "External ID"
check that page contains saved value "birthDate" on the right of "Date of Birth"
check that page contains string with parameters "${todayDayOfMonthTwoDigits} ${todayMonth} ${todayYear}" on the right of "Submitted On Date"
click "Submit"
//validate in profile
check that page contains saved value "firstName" on the right of "Client Name :"
check that page contains saved value "lastName" on the right of "Client Name :"
check that page contains saved value "externalID" on the right of "External Id:"
//validade in clients list
click "Clients"
enter saved value "firstName" into "Search"
enter enter
check that page contains saved value "firstName" below saved value "firstName"
check that page contains saved value "lastName" below saved value "firstName"
check that page contains saved value "externalID" onthe right of saved value "lastName"
32 changes: 32 additions & 0 deletions e2e/testRigor/testcases/create-journal-entries.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
log-in-and-validate
navigate-to-accounting-creation
create-account
//navigate to journal
click "Accounting"
click "Create Journal Entries"
//create a new Journal Entrie
enter string with parameters "${todayMonthNumber}/${todayDayOfMonth}/${todayYear}" into "Transaction Date"
click "Office"
click "Office"
click "Head Office"
click "Currency"
click "US Dollar"
click "Affected GL Entry (Debit)"
type saved value "glAccountName"
click string with parameters "(${glCode}) ${glAccountName}"
click "Affected GL Entry (Credit)"
type saved value "glAccountName"
click string with parameters "(${glCode}) ${glAccountName}" roughly below "Affected GL Entry (Credit)"
click "Payment Type"
click "Money Transfer"
enter "300" into "Debit Amount"
enter "300" into "Credit Amount"
generate from template "%*********", then enter into "Reference Number" and save as "referenceNumber"
click "Submit"
//validate Transactions
check that page contains "Revert Transaction"
grab value from the right of "Transactions" and save as "transactionID"
click "Journal Entries"
enter saved value "transactionID" into "Transaction ID"
check that page contains saved value "glAccountName" below saved value "transactionID"
check that page contains saved value "transactionID" on the left of saved value "glAccountName"
7 changes: 7 additions & 0 deletions e2e/testRigor/testcases/create-new-office.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
log-in-and-validate
navigate-to-offices
create-organization
enter saved value "officeName" into "Filter"
check that page contains saved value "officeName" below saved value "officeName"
check that page contains saved value "externalID" below saved value "officeName"
check that page contains string with parameters "${todayDayOfMonthTwoDigits} ${todayMonth} ${todayYear}" on the right of saved value "externalID"
13 changes: 13 additions & 0 deletions e2e/testRigor/testcases/delete-admin-user.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
log-in-and-validate
navigate-to-admin-users-management
create-admin-user
//delete admin profile
check that page doesn't contain "Create User"
click "Users"
enter saved value "firstName" into "Filter"
click second saved value "firstName"
click "Delete"
click "Confirm"
//validate admin profile does NOT exist
enter saved value "firstName" into "Filter"
check that page doesn't contain saved value "firstName" below saved value "firstName"
13 changes: 13 additions & 0 deletions e2e/testRigor/testcases/delete-client.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
log-in-and-validate
navigate-to-clients
create-client
click "Submit"
//delete client
click "Client actions"
click "Actions"
click "Delete"
click "Confirm"
navigate-to-clients
//validate client does NOT exist
enter saved value "firstName" into "Search"
check that page doesn't contain saved value "firstName" below saved value "firstName"
17 changes: 17 additions & 0 deletions e2e/testRigor/testcases/edit-mandatory-fields-of-organization.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
log-in-and-validate
navigate-to-offices
create-organization
//edit an organization
enter saved value "officeName" into "Filter"
click 2nd saved value "officeName"
click "Edit"
double click field "Office"
enter delete
generate unique name, then enter into field "Office" and save as "newOfficeName"
click "Submit"
check that page contains "General"
check that page contains saved value "newOfficeName"
//validate edited organization
click "Manage Offices"
enter saved value "newOfficeName" into "Filter"
check that page contains saved value "newOfficeName" below saved value "newOfficeName"
8 changes: 8 additions & 0 deletions e2e/testRigor/testcases/invalid-login.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Setting wrong credentials
save value "wrong" as "username"
save value "wrong" as "password"
enter saved value "username" into field "Username"
enter saved value "password" into field "Password"
click exactly "Login"
// validate invalid login message
check that page contains "Invalid User Details. Please try again!"
1 change: 1 addition & 0 deletions e2e/testRigor/testcases/login.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
log-in-and-validate
14 changes: 14 additions & 0 deletions e2e/testRigor/testcases/logout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
validate-login-page
log-in-and-validate
check that page doesn't contain field "Username"
check that page doesn't contain field "Password"
check that page doesn't contain button "Login"
check that page doesn't contain button "Forgot Password?"
check that page contains button "Institution"
check that page contains button "Accounting"
check that page contains button "Reports"
check that page contains button "Admin"
check that page contains button "Self Service"
check that page contains button "Configuration Wizard"
logout
validate-login-page

0 comments on commit 2f8deff

Please sign in to comment.