diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91d2c50da..496b4a1b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,6 +46,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 diff --git a/e2e/testRigor/README.md b/e2e/testRigor/README.md new file mode 100644 index 000000000..8635a0e33 --- /dev/null +++ b/e2e/testRigor/README.md @@ -0,0 +1,67 @@ +# 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/) diff --git a/e2e/testRigor/rules/close-popup.txt b/e2e/testRigor/rules/close-popup.txt new file mode 100644 index 000000000..ffd8033e8 --- /dev/null +++ b/e2e/testRigor/rules/close-popup.txt @@ -0,0 +1 @@ +click "Close" below "Warning" if exists diff --git a/e2e/testRigor/rules/create-account.txt b/e2e/testRigor/rules/create-account.txt new file mode 100644 index 000000000..67782b9a9 --- /dev/null +++ b/e2e/testRigor/rules/create-account.txt @@ -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" diff --git a/e2e/testRigor/rules/create-admin-user.txt b/e2e/testRigor/rules/create-admin-user.txt new file mode 100644 index 000000000..c5369fa2d --- /dev/null +++ b/e2e/testRigor/rules/create-admin-user.txt @@ -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" diff --git a/e2e/testRigor/rules/create-client.txt b/e2e/testRigor/rules/create-client.txt new file mode 100644 index 000000000..92465c5a4 --- /dev/null +++ b/e2e/testRigor/rules/create-client.txt @@ -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" diff --git a/e2e/testRigor/rules/create-organization.txt b/e2e/testRigor/rules/create-organization.txt new file mode 100644 index 000000000..3454d9964 --- /dev/null +++ b/e2e/testRigor/rules/create-organization.txt @@ -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" diff --git a/e2e/testRigor/rules/log-in-and-validate.txt b/e2e/testRigor/rules/log-in-and-validate.txt new file mode 100644 index 000000000..00c649b4f --- /dev/null +++ b/e2e/testRigor/rules/log-in-and-validate.txt @@ -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}!" diff --git a/e2e/testRigor/rules/logout.txt b/e2e/testRigor/rules/logout.txt new file mode 100644 index 000000000..0ab8e0473 --- /dev/null +++ b/e2e/testRigor/rules/logout.txt @@ -0,0 +1,2 @@ +click third "menu" on the right of "Search" +click "Sign Out" diff --git a/e2e/testRigor/rules/navigate-to-accounting-creation.txt b/e2e/testRigor/rules/navigate-to-accounting-creation.txt new file mode 100644 index 000000000..ea0fbcf3d --- /dev/null +++ b/e2e/testRigor/rules/navigate-to-accounting-creation.txt @@ -0,0 +1,3 @@ +click "Accounting" +click "Chart of Accounts" +click "Add Account" diff --git a/e2e/testRigor/rules/navigate-to-admin-users-management.txt b/e2e/testRigor/rules/navigate-to-admin-users-management.txt new file mode 100644 index 000000000..ace1afcb9 --- /dev/null +++ b/e2e/testRigor/rules/navigate-to-admin-users-management.txt @@ -0,0 +1,2 @@ +click "Admin" +click "Users" below "Admin" diff --git a/e2e/testRigor/rules/navigate-to-clients.txt b/e2e/testRigor/rules/navigate-to-clients.txt new file mode 100644 index 000000000..42694adc6 --- /dev/null +++ b/e2e/testRigor/rules/navigate-to-clients.txt @@ -0,0 +1,2 @@ +click "Institution" +click "Clients" below "Institution" diff --git a/e2e/testRigor/rules/navigate-to-offices.txt b/e2e/testRigor/rules/navigate-to-offices.txt new file mode 100644 index 000000000..678ab1e4b --- /dev/null +++ b/e2e/testRigor/rules/navigate-to-offices.txt @@ -0,0 +1,3 @@ +click "Admin" +click "Organization" below "Admin" +click "Manage Offices" diff --git a/e2e/testRigor/rules/pick-birthdate.txt b/e2e/testRigor/rules/pick-birthdate.txt new file mode 100644 index 000000000..efa1dc808 --- /dev/null +++ b/e2e/testRigor/rules/pick-birthdate.txt @@ -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" diff --git a/e2e/testRigor/rules/pick-today-date.txt b/e2e/testRigor/rules/pick-today-date.txt new file mode 100644 index 000000000..5120ec332 --- /dev/null +++ b/e2e/testRigor/rules/pick-today-date.txt @@ -0,0 +1,2 @@ +click field "Opened On" if exists +click exactly saved value "todayDayOfMonth" roughly below saved value "todayMonthShort" diff --git a/e2e/testRigor/rules/validate-login-page.txt b/e2e/testRigor/rules/validate-login-page.txt new file mode 100644 index 000000000..9a0b448b5 --- /dev/null +++ b/e2e/testRigor/rules/validate-login-page.txt @@ -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?" diff --git a/e2e/testRigor/run_testrigor_tests.sh b/e2e/testRigor/run_testrigor_tests.sh new file mode 100644 index 000000000..ae3d26e38 --- /dev/null +++ b/e2e/testRigor/run_testrigor_tests.sh @@ -0,0 +1,19 @@ +#!/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="BqnXhRcaZ59ADvxHo" +MIFOS_AUTH_TOKEN="c3903536-0371-4ba3-afeb-69cf9b408ca6" +LOCALHOST_URL="http://localhost:4200" + +# Paths for the test cases and rules files +TEST_CASES_PATH="e2e/testRigor/testcases/**/*.txt" +RULES_PATH="e2e/testRigor/rules/**/*.txt" + +curl -I $LOCALHOST_URL:4200 + +# 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" \ No newline at end of file diff --git a/e2e/testRigor/testcases/create-account.txt b/e2e/testRigor/testcases/create-account.txt new file mode 100644 index 000000000..723da39d2 --- /dev/null +++ b/e2e/testRigor/testcases/create-account.txt @@ -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" diff --git a/e2e/testRigor/testcases/create-admin-user.txt b/e2e/testRigor/testcases/create-admin-user.txt new file mode 100644 index 000000000..11bee6ca0 --- /dev/null +++ b/e2e/testRigor/testcases/create-admin-user.txt @@ -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 diff --git a/e2e/testRigor/testcases/create-client.txt b/e2e/testRigor/testcases/create-client.txt new file mode 100644 index 000000000..dd5fbaa22 --- /dev/null +++ b/e2e/testRigor/testcases/create-client.txt @@ -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" diff --git a/e2e/testRigor/testcases/create-journal-entries.txt b/e2e/testRigor/testcases/create-journal-entries.txt new file mode 100644 index 000000000..c5d71d7f5 --- /dev/null +++ b/e2e/testRigor/testcases/create-journal-entries.txt @@ -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" diff --git a/e2e/testRigor/testcases/create-new-office.txt b/e2e/testRigor/testcases/create-new-office.txt new file mode 100644 index 000000000..753273167 --- /dev/null +++ b/e2e/testRigor/testcases/create-new-office.txt @@ -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" diff --git a/e2e/testRigor/testcases/delete-admin-user.txt b/e2e/testRigor/testcases/delete-admin-user.txt new file mode 100644 index 000000000..f3e748d8f --- /dev/null +++ b/e2e/testRigor/testcases/delete-admin-user.txt @@ -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" diff --git a/e2e/testRigor/testcases/delete-client.txt b/e2e/testRigor/testcases/delete-client.txt new file mode 100644 index 000000000..6d0a5fe46 --- /dev/null +++ b/e2e/testRigor/testcases/delete-client.txt @@ -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" diff --git a/e2e/testRigor/testcases/edit-mandatory-fields-of-organization.txt b/e2e/testRigor/testcases/edit-mandatory-fields-of-organization.txt new file mode 100644 index 000000000..ebb1c2fef --- /dev/null +++ b/e2e/testRigor/testcases/edit-mandatory-fields-of-organization.txt @@ -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" diff --git a/e2e/testRigor/testcases/invalid-login.txt b/e2e/testRigor/testcases/invalid-login.txt new file mode 100644 index 000000000..6114569d6 --- /dev/null +++ b/e2e/testRigor/testcases/invalid-login.txt @@ -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!" diff --git a/e2e/testRigor/testcases/login.txt b/e2e/testRigor/testcases/login.txt new file mode 100644 index 000000000..56d6cfac0 --- /dev/null +++ b/e2e/testRigor/testcases/login.txt @@ -0,0 +1 @@ +log-in-and-validate diff --git a/e2e/testRigor/testcases/logout.txt b/e2e/testRigor/testcases/logout.txt new file mode 100644 index 000000000..c77ed7e3a --- /dev/null +++ b/e2e/testRigor/testcases/logout.txt @@ -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