Skip to content

RGLab/UITesting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImmuneSpace UI Testing

Production Test
UITesting UITesting

Requirments

Setup in Linux/macOS

Install R packages

install.packages(c("testthat", "RSelenium", "XML", "digest", "jsonlite"))

Set environment variables

In .Renviron file on your home directory:

# Url for the server you want to point to: 
DEV_HOST=https://datatools-dev.immunespace.org
# To run tests pointing at your local instance: 
# DEV_HOST=http://<yourIPaddress>:8080

# ImmuneSpace login info
[email protected]
ISR_PWD=yourImmuneSpacePasswordHere

# SauceLabs login info
SAUCE_USERNAME=yourUsername
SAUCE_ACCESS_KEY=yourAccessKey

# optional
SELENIUM_SERVER=LOCAL # if not set, it uses SauceLabs
TEST_BROWSER=firefox # if not set, default is chrome

Docker

Install Docker

Install Docker Community Edition (CE) following the instructions from their website:

Run a Docker image containing the standalone Selenium server and a browser

To run chrome browser:

docker run -d -p 127.0.0.1:4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:2.53.1

Or to run FireFox browser:

docker run -d -p 127.0.0.1:4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:2.53.1

To run all tests

From the command line:

Rscript test.R

Or in R:

source("test.R")

To run a test file

In R:

testthat::test_file("tests/test-0-front.R", reporter = c("summary", "fail"))

To debug with a live browser window

# Start selenium server
rD <- RSelenium::rsDriver(browser="firefox")

# Open browser
remDr <- rD[["client"]]

# Stop selenium server
rD[["server"]]$stop()

To debug with a dockerized selenium container

# Run the standalone debug server
docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:3.141.59-zirconium

Use the viewer to check out what is going on:

  • Open the viewer utility through the UI (search vncviewer)
  • Connect to 'localhost:5900'
  • enter the password given by Selenium - aka 'secret'

Notes on running against a local development machine

  • Developing React Modules: Dev versions of a webpart will not be available in your dockerized test environment unless you map the npm dev server port (e.g. 3001) to that same port in the docker environment.
  • netrc files: unlike the servers, where a separate unix user is running the R session, your local instance will have an R engine that depends on there being a viable .netrc in the home directory. If you do not want to use your credentials, you will need to replace them (e.g. with a non-admin dummy user).

Setup in GitHub Actions

Configure UITesting.yaml

  • To install R and required packages
  • To cache packages
  • To run test.R script
  • To communicate with Sauce Labs after test

Set environment variables

See Creating encrypted secrets for an environment

Create DESCRIPTION file

Even though this is not a package, DESCRIPTION file is needed to run a builder in GitHub Actions Workflow in order to declare dependencies (using remotes::install_deps(dependencies = TRUE)).

Available tests

Big Thanks

Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labs