forked from capability-boosters-dev/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We have no documentation in Confluence or this repo for running Selenium tests natively. This commit adds a doc for that. We're also migrating the "prepare" script from the qa_tools repo to this one. Test Plan: - follow the instructions in doc/testing_with_selenium.md to verify it's accurate - run script/canvas_update to verify it still works - follow the setup instructions in script/prepare/README.md and verify it works Change-Id: I11d63e60dc1faa8be1dfacfc9bebfcbea55c31f1 Reviewed-on: https://gerrit.instructure.com/167300 Tested-by: Jenkins Reviewed-by: David Tan <[email protected]> QA-Review: David Tan <[email protected]> Product-Review: Michael Hargiss <[email protected]>
- Loading branch information
Showing
5 changed files
with
449 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Testing with Selenium | ||
|
||
You may run the Selenium tests either natively or in docker. | ||
|
||
## Running Selenium Tests Natively (Mac) | ||
|
||
We're making a few assumptions here: | ||
- you're using an Apple computer | ||
- you've already installed Homebrew | ||
- you've already installed Postgres (postgresapp.com is an excellent option), | ||
and Postgres is running on your computer | ||
- you've already installed Node.js | ||
|
||
0. Install `yarn` if you haven't already: | ||
|
||
```sh | ||
brew install yarn | ||
``` | ||
|
||
If you find you need an older version of yarn, follow these instructions to | ||
install the older version and switch to it: | ||
|
||
[https://stackoverflow.com/a/52525732/3038677](https://stackoverflow.com/a/52525732/3038677) | ||
|
||
1. Follow the instructions in `script/prepare/README.md` to setup the `prepare` | ||
script. | ||
|
||
You'll use the `prepare` script later to automate installing and updating Canvas | ||
on your computer. | ||
|
||
Note: some features of `prepare` only work if you have access to Instructure's | ||
Gerrit host. See the README for details. | ||
|
||
2. Install a web browser driver on your computer for the browser you wish to run | ||
the tests in. Homebrew is the easiest way to go: | ||
|
||
```sh | ||
brew install chromedriver # necessary for running tests in Chrome | ||
brew install geckodriver # necessary for running tests in Firefox | ||
``` | ||
|
||
Now let's get Canvas ready to run the tests. | ||
|
||
3. Copy the Selenium and database configuration files: | ||
|
||
```sh | ||
cp config/selenium.yml.example config/selenium.yml | ||
cp config/database.yml.example config/database.yml | ||
``` | ||
|
||
4. Use `prepare` to install Canvas plugins and dependencies, create databases, | ||
run database migrations, etc: | ||
|
||
```sh | ||
prepare | ||
``` | ||
|
||
You might encounter problems with some Ruby dependencies. The ["Dependency | ||
Installation" section](https://github.com/instructure/canvas-lms/wiki/Quick-Start#dependency-installation) | ||
in the public Canvas LMS Github wiki has some useful tips. | ||
|
||
4.a. Optional. Run delayed jobs in the foreground (not all Selenium tests need | ||
this but some do): | ||
|
||
```sh | ||
script/delayed_job run | ||
``` | ||
|
||
or run it in the background: | ||
|
||
```sh | ||
script/delayed_job run & | ||
``` | ||
|
||
5. Run the Selenium tests: | ||
|
||
```sh | ||
bundle exec rspec spec/selenium | ||
``` | ||
|
||
or run a specific Selenium test: | ||
|
||
```sh | ||
bundle exec rspec spec/selenium/accounts_spec.rb:36 | ||
``` | ||
|
||
## Running Selenium Tests in Docker | ||
|
||
See the [Selenium section](https://github.com/instructure/canvas-lms/blob/master/doc/docker/developing_with_docker.md#selenium) | ||
of the `doc/docker/developing_with_docker.md` instructions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#!/bin/bash | ||
|
||
# This file contains commonly used BASH functions for scripting in canvas-lms, | ||
# particularly script/canvas_update and script/prepare/prepare . As such, | ||
# *be careful* when you modify these functions as doing so will impact multiple | ||
# scripts that likely aren't used or tested in continuous integration builds. | ||
|
||
function echo_console_and_log { | ||
echo "$1" | ||
echo "$1" >>"$LOG" | ||
} | ||
|
||
function print_results { | ||
exit_code=$? | ||
set +e | ||
|
||
if [ "${exit_code}" == "0" ]; then | ||
echo "" | ||
echo_console_and_log " \o/ Success!" | ||
else | ||
echo "" | ||
echo_console_and_log " /o\ Something went wrong. Check ${LOG} for details." | ||
fi | ||
|
||
exit ${exit_code} | ||
} | ||
|
||
function ensure_in_canvas_root_directory { | ||
if ! is_canvas_root; then | ||
echo "Please run from a Canvas root directory" | ||
exit 0 | ||
fi | ||
} | ||
|
||
function is_canvas_root { | ||
CANVAS_IN_README=$(head -1 README.md 2>/dev/null | grep 'Canvas LMS') | ||
[[ "$CANVAS_IN_README" != "" ]] && is_git_dir | ||
return $? | ||
} | ||
|
||
function is_git_dir { | ||
git rev-parse --is-inside-git-dir >/dev/null 2>&1 && [ -d .git ] | ||
return $? | ||
} | ||
|
||
# Parameter: the name of the script calling this function | ||
function intro_message { | ||
script_name="$1" | ||
echo "Bringing Canvas up to date ..." | ||
echo " Log file is $LOG" | ||
|
||
echo >>"$LOG" | ||
echo "-----------------------------" >>"$LOG" | ||
echo "$1 ($(date)):" >>"$LOG" | ||
echo "-----------------------------" >>"$LOG" | ||
} | ||
|
||
function update_plugin { | ||
( | ||
cd "$1" | ||
if is_git_dir; then | ||
echo_console_and_log " Updating plugin $1 ..." | ||
git checkout master >>"$LOG" 2>&1 | ||
git pull --rebase >>"$LOG" 2>&1 | ||
fi | ||
) | ||
} | ||
|
||
function update_plugins { | ||
# Loop through each plugin dir, and if it's a git repo, update it | ||
# This needs to be done first so that db:migrate can pull in any plugin- | ||
# precipitated changes to the database. | ||
for dir in {gems,vendor}; do | ||
if [ -d "$dir/plugins" ]; then | ||
for plugin in $dir/plugins/*; do update_plugin "$plugin"; done | ||
fi | ||
done | ||
} | ||
|
||
function checkout_master_canvas { | ||
echo_console_and_log " Checking out canvas-lms master ..." | ||
git checkout master >>"$LOG" 2>&1 | ||
} | ||
|
||
function rebase_canvas { | ||
echo_console_and_log " Rebasing canvas-lms on HEAD ..." | ||
git pull --rebase >>"$LOG" 2>&1 | ||
} | ||
|
||
function bundle_install { | ||
echo_console_and_log " Installing gems (bundle install) ..." | ||
rm Gemfile.lock* >/dev/null 2>&1 | ||
bundle install >>"$LOG" 2>&1 | ||
} | ||
|
||
function bundle_install_with_check { | ||
echo_console_and_log " Checking your gems (bundle check) ..." | ||
if bundle check >>"$LOG" 2>&1 ; then | ||
echo_console_and_log " Gems are up to date, no need to bundle install ..." | ||
else | ||
bundle_install | ||
fi | ||
} | ||
|
||
function rake_db_migrate_dev_and_test { | ||
echo_console_and_log " Migrating development DB ..." | ||
RAILS_ENV=development bundle exec rake db:migrate >>"$LOG" 2>&1 | ||
|
||
echo_console_and_log " Migrating test DB ..." | ||
RAILS_ENV=test bundle exec rake db:migrate >>"$LOG" 2>&1 | ||
} | ||
|
||
function install_node_packages { | ||
echo_console_and_log " Installing Node packages ..." | ||
bundle exec rake js:yarn_install >>"$LOG" 2>&1 | ||
} | ||
|
||
function compile_assets { | ||
echo_console_and_log " Compiling assets (css and js only, no docs or styleguide) ..." | ||
bundle exec rake canvas:compile_assets_dev >>"$LOG" 2>&1 | ||
} |
Oops, something went wrong.