diff --git a/.ahoy.yml b/.ahoy.yml index d14af7265..0153cd31c 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -37,6 +37,7 @@ commands: COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-${PWD##*/}} \ DREVOPS_HOST_DB_PORT=$(docker compose port mariadb 3306 2>/dev/null | cut -d : -f 2) \ DREVOPS_HOST_SOLR_PORT=$(docker compose port solr 8983 2>/dev/null | cut -d : -f 2) \ + DREVOPS_HOST_SELENIUM_VNC_PORT=$(docker compose port chrome 7900 2>/dev/null | cut -d : -f 2) \ DREVOPS_HOST_HAS_SEQUELACE=$(uname -a | grep -i -q darwin && mdfind -name 'Sequel Ace' 2>/dev/null | grep -q "Ace" && echo 1 || true) \ ahoy cli ./scripts/drevops/info.sh "$@" diff --git a/.scaffold/.ahoy.yml b/.scaffold/.ahoy.yml index f8265f935..5ec25635f 100644 --- a/.scaffold/.ahoy.yml +++ b/.scaffold/.ahoy.yml @@ -9,6 +9,12 @@ commands: npm --prefix tests ci npm --prefix docs ci + docs: + name: Build Scaffold docs. + cmd: | + npm --prefix docs ci + npm --prefix docs run start + lint: name: Lint Scaffold project. cmd: | diff --git a/.scaffold/docs/content/getting-started/architecture.mdx b/.scaffold/docs/content/getting-started/architecture.mdx index 135519efa..ad95ff3a1 100644 --- a/.scaffold/docs/content/getting-started/architecture.mdx +++ b/.scaffold/docs/content/getting-started/architecture.mdx @@ -84,7 +84,6 @@ with addition of several configuration files and directories. ├── behat.yml # Behat configuration file. ├── composer.json # Composer configuration file. ├── docker-compose.yml # Docker Compose configuration file. -├── docker-compose.override.default.yml # Docker Compose local configuration file. ├── phpcs.xml # PHP CodeSniffer configuration file. ├── phpmd.xml # PHP Mess Detector configuration file. ├── phpstan.neon # PHPStan configuration file. diff --git a/.scaffold/docs/content/tools/behat.mdx b/.scaffold/docs/content/tools/behat.mdx index 1e7c9f8a8..e19c46695 100644 --- a/.scaffold/docs/content/tools/behat.mdx +++ b/.scaffold/docs/content/tools/behat.mdx @@ -169,3 +169,32 @@ There are also example tests in the [`tests/behat/features`](https://github.com/ directory that can be used as a starting point for writing tests. These tests define `@smoke` tests for the homepage and login page as well as tests for contributed modules. + +## Connecting to the browser + +For `@javascript` tests, Behat uses Selenium to connect to the browser. The +browser runs within a container and can be observed from the host machine by +using a browser thanks to the VNC server running in the container and [noVNC](https://novnc.com/). + +Run + +```shell +ahoy info +``` +and click on the link next to `Selenium VNC URL on host` to open the browser. + +Or use the following command to get the port number: +```shell +docker compose port chrome 7900 +``` +and open `http://localhost:/?autoconnect=1&password=secret` in the browser. + +:::tip + + When running tests, you can add `And I wait for 60 seconds` step to suspend + the test execution for a minute and interact with the headless browser in a + container through a browser on your host machine. + +::: + +![behat-novnc.gif](/img/behat-novnc.gif) diff --git a/.scaffold/docs/content/tools/docker.mdx b/.scaffold/docs/content/tools/docker.mdx index ade7a11cb..18b99ba8e 100644 --- a/.scaffold/docs/content/tools/docker.mdx +++ b/.scaffold/docs/content/tools/docker.mdx @@ -87,8 +87,7 @@ sections. Docker Compose reads the configuration from the `docker-compose.yml` and `docker-compose.override.yml` files. The configuration files are written in -YAML, -which [support anchors and references](http://blog.daemonl.com/2016/02/yaml.html) +YAML, which [support anchors and references](http://blog.daemonl.com/2016/02/yaml.html) that help to reduce duplication. The file provided by Scaffold contains the following sections: diff --git a/.scaffold/docs/cspell.json b/.scaffold/docs/cspell.json index d21eb4f48..c0b418e38 100644 --- a/.scaffold/docs/cspell.json +++ b/.scaffold/docs/cspell.json @@ -34,6 +34,7 @@ "localdev", "mglaman", "minimised", + "novnc", "oomphinc", "optimise", "optimised", diff --git a/.scaffold/docs/static/img/behat-novnc.gif b/.scaffold/docs/static/img/behat-novnc.gif new file mode 100644 index 000000000..668770011 Binary files /dev/null and b/.scaffold/docs/static/img/behat-novnc.gif differ diff --git a/.scaffold/tests/bats/_helper.bash b/.scaffold/tests/bats/_helper.bash index bd0ab4e63..586ae7816 100644 --- a/.scaffold/tests/bats/_helper.bash +++ b/.scaffold/tests/bats/_helper.bash @@ -400,7 +400,6 @@ assert_files_present_drevops() { assert_file_exists "behat.yml" assert_file_exists "composer.json" assert_file_exists ".ahoy.local.example.yml" - assert_file_exists "docker-compose.override.default.yml" assert_file_exists ".env.local.default" assert_file_exists "docker-compose.yml" assert_file_exists "phpcs.xml" diff --git a/.scaffold/tests/bats/_helper.workflow.bash b/.scaffold/tests/bats/_helper.workflow.bash index e52a79bb3..8f04592ad 100644 --- a/.scaffold/tests/bats/_helper.workflow.bash +++ b/.scaffold/tests/bats/_helper.workflow.bash @@ -36,13 +36,6 @@ prepare_sut() { mkdir -p .idea touch .idea/idea_file.txt assert_file_exists .idea/idea_file.txt - - # LCOV_EXCL_START - if uname -a | grep -q ARM64; then - substep "Override local Docker Compose for ARM." - cp docker-compose.override.default.yml docker-compose.override.yml - fi - # LCOV_EXCL_STOP } docker_remove_image() { @@ -310,6 +303,7 @@ assert_ahoy_info() { assert_output_not_contains "DB-in-image : ${db_image}" fi assert_output_contains "Solr URL on host :" + assert_output_contains "Selenium VNC URL on host :" assert_output_contains "Mailhog URL : http://mailhog.docker.amazee.io/" assert_output_contains "Xdebug : Disabled ('ahoy debug' to enable)" assert_output_not_contains "Containers are not running." diff --git a/.scaffold/tests/bats/fixtures/docker-compose.env.json b/.scaffold/tests/bats/fixtures/docker-compose.env.json index deb56af4e..e3954a3b5 100644 --- a/.scaffold/tests/bats/fixtures/docker-compose.env.json +++ b/.scaffold/tests/bats/fixtures/docker-compose.env.json @@ -40,13 +40,20 @@ "TZ": "Australia/Melbourne", "XDEBUG_ENABLE": "" }, - "image": "selenium/standalone-chrome:VERSION", + "image": "selenium/standalone-chromium:VERSION", "labels": { "lagoon.type": "none" }, "networks": { "default": null }, + "ports": [ + { + "mode": "ingress", + "protocol": "tcp", + "target": 7900 + } + ], "shm_size": "1073741824", "volumes": [ { diff --git a/.scaffold/tests/bats/fixtures/docker-compose.env_local.json b/.scaffold/tests/bats/fixtures/docker-compose.env_local.json index deb56af4e..e3954a3b5 100644 --- a/.scaffold/tests/bats/fixtures/docker-compose.env_local.json +++ b/.scaffold/tests/bats/fixtures/docker-compose.env_local.json @@ -40,13 +40,20 @@ "TZ": "Australia/Melbourne", "XDEBUG_ENABLE": "" }, - "image": "selenium/standalone-chrome:VERSION", + "image": "selenium/standalone-chromium:VERSION", "labels": { "lagoon.type": "none" }, "networks": { "default": null }, + "ports": [ + { + "mode": "ingress", + "protocol": "tcp", + "target": 7900 + } + ], "shm_size": "1073741824", "volumes": [ { diff --git a/.scaffold/tests/bats/fixtures/docker-compose.env_mod.json b/.scaffold/tests/bats/fixtures/docker-compose.env_mod.json index 7a346e32a..4e3d26154 100644 --- a/.scaffold/tests/bats/fixtures/docker-compose.env_mod.json +++ b/.scaffold/tests/bats/fixtures/docker-compose.env_mod.json @@ -40,13 +40,20 @@ "TZ": "Australia/Melbourne", "XDEBUG_ENABLE": "1" }, - "image": "selenium/standalone-chrome:VERSION", + "image": "selenium/standalone-chromium:VERSION", "labels": { "lagoon.type": "none" }, "networks": { "default": null }, + "ports": [ + { + "mode": "ingress", + "protocol": "tcp", + "target": 7900 + } + ], "shm_size": "1073741824", "volumes": [ { diff --git a/.scaffold/tests/bats/fixtures/docker-compose.noenv.json b/.scaffold/tests/bats/fixtures/docker-compose.noenv.json index e73841ca2..cd773e248 100644 --- a/.scaffold/tests/bats/fixtures/docker-compose.noenv.json +++ b/.scaffold/tests/bats/fixtures/docker-compose.noenv.json @@ -40,13 +40,20 @@ "TZ": "Australia/Melbourne", "XDEBUG_ENABLE": "" }, - "image": "selenium/standalone-chrome:VERSION", + "image": "selenium/standalone-chromium:VERSION", "labels": { "lagoon.type": "none" }, "networks": { "default": null }, + "ports": [ + { + "mode": "ingress", + "protocol": "tcp", + "target": 7900 + } + ], "shm_size": "1073741824", "volumes": [ { diff --git a/README.dist.md b/README.dist.md index aaa9f15f8..9e4284761 100644 --- a/README.dist.md +++ b/README.dist.md @@ -58,10 +58,6 @@ to DrevOps progress. Remove this section once onboarding is finished. - `pygmy up` - `ahoy build` -### Apple M1 adjustments - -Copy `docker-compose.override.default.yml` to `docker-compose.override.yml`. - ## Project documentation - [FAQs](docs/faqs.md) diff --git a/behat.yml b/behat.yml index e7f0bb225..abecd577d 100644 --- a/behat.yml +++ b/behat.yml @@ -28,9 +28,23 @@ default: base_url: http://nginx:8080 files_path: '%paths.base%/tests/behat/fixtures' browser_name: chrome + javascript_session: selenium2 selenium2: wd_host: "http://chrome:4444/wd/hub" - javascript_session: selenium2 + capabilities: + browser: chrome + extra_capabilities: + "goog:chromeOptions": + args: + - '--disable-gpu' # Disables hardware acceleration required in containers and cloud-based instances (like CI runners) where GPU is not available. + # Options to increase stability and speed. + - '--disable-extensions' # Disables all installed Chrome extensions. Useful in testing environments to avoid interference from extensions. + - '--disable-infobars' # Hides the infobar that Chrome displays for various notifications, like warnings when opening multiple tabs. + - '--disable-popup-blocking' # Disables the popup blocker, allowing all popups to appear. Useful in testing scenarios where popups are expected. + - '--disable-translate' # Disables the built-in translation feature, preventing Chrome from offering to translate pages. + - '--no-first-run' # Skips the initial setup screen that Chrome typically shows when running for the first time. + - '--test-type' # Disables certain security features and UI components that are unnecessary for automated testing, making Chrome more suitable for test environments. + # Provides integration with Drupal APIs. Drupal\DrupalExtension: blackbox: ~ diff --git a/docker-compose.override.default.yml b/docker-compose.override.default.yml deleted file mode 100644 index 92da5b1ce..000000000 --- a/docker-compose.override.default.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Local container services overrides. -# -# Copy this file to docker-compose.override.yml and set relevant values. -# docker-compose.override.yml is excluded from the repository, - -services: - chrome: - # Chrome image with Apple M1 support. - image: seleniarm/standalone-chromium:111.0 diff --git a/docker-compose.yml b/docker-compose.yml index 500283602..1def614d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -202,7 +202,7 @@ services: context: . dockerfile: .docker/clamav.dockerfile ports: - - "3310" # Find port on host with `docker-compose port clamav 3310`. + - "3310" # Find port on host with `docker compose port clamav 3310`. environment: << : *default-environment networks: @@ -217,7 +217,9 @@ services: # Chrome container, used for browser testing. chrome: - image: selenium/standalone-chrome:111.0 + image: selenium/standalone-chromium:128.0 + ports: + - "7900" # Find port on host with `docker compose port chrome 7900`. shm_size: '1gb' # Increase '/dev/shm' partition size to avoid browser crashing. <<: *default-volumes # Use default volumes to provide access to test fixtures. environment: diff --git a/renovate.json b/renovate.json index 5b4a9fd13..84f0f5f4e 100644 --- a/renovate.json +++ b/renovate.json @@ -73,18 +73,6 @@ "drupal/core-recommended" ] }, - { - "groupName": "Container images excluded", - "matchManagers": [ - "dockerfile", - "docker-compose" - ], - "matchDepNames": [ - "selenium/standalone-chrome", - "seleniarm/standalone-chromium" - ], - "enabled": false - }, { "groupName": "Container images", "groupSlug": "docker", @@ -95,10 +83,6 @@ "dockerfile", "docker-compose", "custom.regex" - ], - "matchPackageNames": [ - "!selenium/standalone-chrome", - "!seleniarm/standalone-chromium" ] }, { diff --git a/scripts/drevops/info.sh b/scripts/drevops/info.sh index 6256b07a6..fcadc45d6 100755 --- a/scripts/drevops/info.sh +++ b/scripts/drevops/info.sh @@ -44,6 +44,9 @@ fi if [ -n "${DREVOPS_HOST_SOLR_PORT:-}" ]; then note "Solr URL on host : http://127.0.0.1:${DREVOPS_HOST_SOLR_PORT}" fi +if [ -n "${DREVOPS_HOST_SELENIUM_VNC_PORT:-}" ]; then + note "Selenium VNC URL on host : http://localhost:${DREVOPS_HOST_SELENIUM_VNC_PORT}/?autoconnect=1&password=secret" +fi note "Mailhog URL : http://mailhog.docker.amazee.io/" note "Xdebug : $(php -v | grep -q Xdebug && echo "Enabled ('ahoy up cli' to disable)" || echo "Disabled ('ahoy debug' to enable)")" if [ "${DREVOPS_SHOW_LOGIN}" = "1" ] || [ -n "${1:-}" ]; then