Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use selenium and chromedriver as composer dev dependencies #1387

Merged
merged 18 commits into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ before_script:
# test if web server works
- sleep 3
- wget "http://127.0.0.1:8088/bolt/login"
- export PATH=$PATH:$PWD/vendor/bin

script:
# this checks that the source code follows the Bolt Code Syntax rules
Expand All @@ -65,7 +66,7 @@ script:
# run API tests
- make behat-api-quiet
# run JS e2e tests
- ./run_behat_tests.sh && make behat-js-quiet
- make behat-js-quiet
# Upload Behat logs
- ./vendor/bin/upload-textfiles "var/log/behat-reports/*.log"

25 changes: 19 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
DC_RUN ?= docker-compose run --rm

SHELL = bash

COMPOSER ?= COMPOSER_MEMORY_LIMIT=-1 composer

.PHONY: help install server server-stop cache csclear cscheck csfix csfix-tests stancheck test \
behat behat-js behat-js-quiet behat-api behat-api-quiet full-test db-create db-update db-reset \
behat behat-quiet behat-js behat-js-quiet behat-api behat-api-quiet full-test db-create db-update db-reset \
docker-install docker-install-deps docker-start docker-assets-serve \
docker-update docker-cache docker-csclear docker-cscheck docker-csfix docker-stancheck docker-db-create docker-db-reset \
docker-db-update docker-npm-fix-env docker-test docker-server-stop docker-behat docker-full-test \
Expand Down Expand Up @@ -73,22 +75,33 @@ behat-api-quiet: ## to run behat API tests quietly

behat-js: ## to run behat JS tests
make server
java -jar -Dwebdriver.chrome.driver="./bin/chromedriver" ./bin/selenium-server-standalone-3.141.59.jar >/dev/null 2>&1 &
echo "Running Behat e2e tests. Make sure you have the latest version of Google Chrome installed"
## If not already in path, add vendor/bin/ to it, where chromedriver executable can be found.
[ ":${PATH}:" != *":$(pwd)/vendor/bin:"* ] && PATH="$(pwd)/vendor/bin:${PATH}"
## run the selenium server. chromedriver executable must be in $PATH
vendor/bin/selenium-server-standalone >/dev/null 2>&1 &
sleep 2s
vendor/bin/behat --tags=javascript
kill -9 $(lsof -t -i:4444)
# kill -9 $(lsof -t -i:4444)

behat-js-quiet: ## to run behat JS tests quietly
make server
java -jar -Dwebdriver.chrome.driver="./bin/chromedriver" -Djava.awt.headless=true ./bin/selenium-server-standalone-3.141.59.jar >/dev/null 2>&1 &
echo "Running Behat e2e tests. Make sure you have the latest version of Google Chrome installed"
./run_behat_tests.sh
## run the selenium server. chromedriver executable must be in $PATH
vendor/bin/selenium-server-standalone >/dev/null 2>&1 &
sleep 2s
vendor/bin/behat --tags=javascript --format=progress
kill -9 $(lsof -t -i:4444)
# kill -9 $(lsof -t -i:4444)

make behat:
behat:
make behat-api
make behat-js

behat-quiet:
make behat-api-quiet
make behat-js-quiet

full-test: ## to run full tests
make cscheck
make test
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,12 @@ make test
```

To run E2E tests:
- Follow the Behat tests [installation guide](tests/e2e/README.md), then:
```
make behat-js
```

Read more about running and creating tests on the [e2e tests page](tests/e2e/README.md).

Fixing IDE issues
-----------------

Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@
"phpstan/phpstan-symfony": "^0.12",
"phpunit/phpunit": "^7.5",
"roave/security-advisories": "dev-master@dev",
"se/selenium-server-standalone": "^3.141",
"symfony/browser-kit": "^4.4",
"symfony/css-selector": "^4.4",
"symplify/easy-coding-standard": "^7.2"
"symplify/easy-coding-standard": "^7.2",
"vaimo/binary-chromedriver": "^5.0"
},
"config": {
"preferred-install": {
Expand Down
21 changes: 3 additions & 18 deletions run_behat_tests.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
#!/usr/bin/env bash

if [[ "$OSTYPE" == "linux-gnu" ]]; then
wget http://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar -P ./bin --quiet
echo "Adding chromedriver to PATH variable"
export PATH="$(pwd)/vendor/bin:${PATH}"

wget https://chromedriver.storage.googleapis.com/81.0.4044.69/chromedriver_linux64.zip -P ./bin --quiet
unzip ./bin/chromedriver_linux64.zip -d ./bin
rm ./bin/chromedriver_linux64.zip

elif [[ "$OSTYPE" == "darwin"* ]]; then
wget http://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar -P ./bin --quiet

wget https://chromedriver.storage.googleapis.com/81.0.4044.69/chromedriver_mac64.zip -P ./bin --quiet
unzip ./bin/chromedriver_mac64.zip -d ./bin
rm ./bin/chromedriver_mac64.zip

elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
echo "Sorry, can't handle windows.";
else
echo "Don't know how to handle this platform, sorry";
fi
echo $PATH
6 changes: 1 addition & 5 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ Bolt uses [Behat](http://docs.behat.org/en/v2.5/guides/1.gherkin.html) for E2E t
Installation
---
Be sure that you have Java installed.

Run under `core` folder:
```
./run_behat_tests.sh
```
Be sure that you have the latest stable Chrome version installed.

Usage
---
Expand Down