This repository contains all of the code you need for testing the DCARB Project or DCARB at Cowlar. It consists of automated test cases code that executes End-to-End Testing using the Cypress Javascript Library.
Make sure you've setup the project first. i.e the backend, frontend and devOps repos.
See Setting Up Project Locally
-
Clone the repository
Make sure to clone the repository in windows if you are using
WSL
(not insideWSL
)git clone [email protected]:cowlar/dcarb/dcarb-testing.git
-
Clone the submodule repository (You may need to request for access of [email protected]/cowlar/dcarb/dcarb-commons)
cd dcarb-testing git submodule update --init
-
Installing NPM libraries
npm ci
-
Obtain these env files from your team and place them in the root of the project:
-
cypress.env.json
file{ "ORGANIZATION_ID": "<ID of organisation>", "devUrl": "<Dev URL>", "API_URL": "<Backend API URL>", "DASHBOARD_LOGIN_CEO_USERNAME_1": "CEO Username", "DASHBOARD_LOGIN_CEO_PASSWORD": "CEO Password", "superAdminEmail": "Super Admin Email", "superAdminPassword": "Super Admin Password", "adminEmail": "Admin Email", "adminPassword": "Admin Password", "ceoEmail": "CEO Email", "ceoPassword": "CEO Password", "operatorEmail": "Operator Email", "operatorPassword": "Operator Password", "customerEmail": "Customer Email", "customerPassword": "Customer Password" }
-
and
.env
fileTEST_ENVIRONMENT="<Environment>" STAGING_TICKET="<JIRA Ticket for Staging Test Results>" XRAY_CLOUD_JIRA_URL="https://<JIRA Poject URL>" XRAY_CLOUD_AUTH_URL="https://xray.cloud.getxray.app/api/v2/authenticate" XRAY_CLIENT_ID="<XRAY Client ID>" XRAY_CLIENT_SECRET="<XRAY Client Secret>" SLACK_WEBHOOK_INTERNAL="<Slack Incoming Webhook>" SLACK_ACCESS_TOKEN="xoxb-<Slack API Access Token>" SLACK_POST_MESSAGE_URL="https://slack.com/api/chat.postMessage" SLACK_CHANNEL_ID="<Slack Channel's ID, to post results to>"
-
-
Open the Cypress tool
npm run cy:dev
gen
is a node script that creates template files, in their respective folders, with boilerplate code and file extension.
Flags starting with dashes i.e --fixture
and --help
, work when script is run as node scripts/template-gen.js
, but not with npm run gen
Syntax
npm run gen <testCaseName> [fixture]
For example if you want to create files for DC-123_SomeTestCase test case
Run
npm run gen DC-123_SomeTestCase
Note that we've given no file extension above.
Running above command will ask you to:
- Select the folder to put test case in.
- Enter description of the test case.
After hitting enter
it creates two files:
cypress/e2e/TestCases/<folder>/DC-123_SomeTestCase.cy.js
cypress/support/TestCases/<folder>/DC-123_SomeTestCase.js
ℹ️ If files exist already, it will skip those and won't overwrite them.
If fixture file is also needed, pass fixture
flag at the end. i.e.
Run
npm run gen DC-123_SomeTestCase fixture
Now above command creates three files:
cypress/e2e/TestCases/<folder>/DC-123_SomeTestCase.cy.js
cypress/support/TestCases/<folder>/DC-123_SomeTestCase.js
cypress/fixtures/<folder>/DC-123_SomeTestCase.json
To show help
npm run gen help
If you don't have Docker installed on your machine, See Installing Docker
-
Obtain these env files from your team and place them in
./docker-compose/
:.env
backend.env
frontend.env
-
Login to
registery.github.com
docker login registry.github.com
It will ask for your github username and password/access token
-
Change directory to
./docker-compose
cd docker-compose
-
Start the docker containers for the project in the background (on linux run it with
sudo
)docker compose up -d -V
-
Open (InfluxDB) localhost:8086 and login using credentials in the provided
.env
file -
Obtain the InfluxDB API token from the InfluxDB dashboard and save it in the
.env
andbackend.env
files in./docker-compose/
folder -
Run a command in InfluxDB container to load data
docker exec -it dcarb-influxdb2.local bash
-
(In Linux) Get read/write access to
./docker-compose/backups
folder. Run below command in./docker-compose
foldersudo chmod 777 ./backups
-
Get the zip file for the backup from your team. Extract it in
./docker-compose/backups
folder, then run following command in linux shell inside docker. Anything inside./docker-compose/backups
folder will become accessable inside the influx containerinflux restore /usr/backups/<backup folder> -t <influxdb_token>
-
Open (Adminer) localhost:8085, login and directly import the backup files