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

Behat testing example #113

Merged
merged 9 commits into from
Feb 6, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: ddev-selenium-standalone-chrome
repository: ddev/ddev-selenium-standalone-chrome
version: 1.0.4
install_date: "2024-01-31T12:01:30Z"
project_files:
- docker-compose.selenium-chrome.yaml
- config.selenium-standalone-chrome.yaml
global_files: []
removal_actions: []
29 changes: 29 additions & 0 deletions .ddev/config.selenium-standalone-chrome.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ddev-generated
# Remove the line above if you don't want this file to be overwritten when you run
# ddev get ddev/ddev-selenium-standalone-chrome
#
# This file comes from https://github.com/ddev/ddev-selenium-standalone-chrome
#
web_environment:
- BROWSERTEST_OUTPUT_DIRECTORY=/tmp
- BROWSERTEST_OUTPUT_BASE_URL=${DDEV_PRIMARY_URL}
- SIMPLETEST_BASE_URL=http://web
- SIMPLETEST_DB=mysql://db:db@db/db
# Use disable-dev-shm-usage instead of setting shm_usage
# https://developers.google.com/web/tools/puppeteer/troubleshooting#tips
# The format of chromeOptions is defined at https://chromedriver.chromium.org/capabilities
- MINK_DRIVER_ARGS_WEBDRIVER=[\"chrome\", {\"browserName\":\"chrome\",\"chromeOptions\":{\"w3c\":false,\"args\":[\"--disable-gpu\",\"--headless\", \"--no-sandbox\", \"--disable-dev-shm-usage\"]}}, \"http://selenium-chrome:4444/wd/hub\"]
# Nightwatch
- DRUPAL_TEST_BASE_URL=http://web
- DRUPAL_TEST_DB_URL=mysql://db:db@db/db
- DRUPAL_TEST_WEBDRIVER_HOSTNAME=selenium-chrome
- DRUPAL_TEST_WEBDRIVER_PORT=4444
- DRUPAL_TEST_WEBDRIVER_PATH_PREFIX=/wd/hub
- DRUPAL_TEST_WEBDRIVER_CHROME_ARGS=--disable-gpu --headless --no-sandbox --disable-dev-shm-usage
- DRUPAL_TEST_CHROMEDRIVER_AUTOSTART=false
- DRUPAL_NIGHTWATCH_SEARCH_DIRECTORY=../
- DRUPAL_NIGHTWATCH_IGNORE_DIRECTORIES=node_modules,vendor,.*,sites/*/files,sites/*/private,sites/simpletest
- DRUPAL_NIGHTWATCH_OUTPUT=reports/nightwatch
# DTT
- DTT_BASE_URL=http://web
- DTT_MINK_DRIVER_ARGS=[\"chrome\", {\"browserName\":\"chrome\",\"chromeOptions\":{\"w3c\":false,\"args\":[\"--disable-gpu\",\"--headless\", \"--no-sandbox\", \"--disable-dev-shm-usage\"]}}, \"http://selenium-chrome:4444/wd/hub\"]
34 changes: 34 additions & 0 deletions .ddev/docker-compose.selenium-chrome.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ddev-generated
# Remove the line above if you don't want this file to be overwritten when you run
# ddev get ddev/ddev-selenium-standalone-chrome
#
# This file comes from https://github.com/ddev/ddev-selenium-standalone-chrome
#
version: '3.6'
services:
selenium-chrome:
image: seleniarm/standalone-chromium:4.1.4-20220429
container_name: ddev-${DDEV_SITENAME}-selenium-chrome
expose:
# The internal noVNC port, which operates over HTTP so it can be exposed
# through the router.
- 7900
environment:
- VIRTUAL_HOST=$DDEV_HOSTNAME
- HTTPS_EXPOSE=7900:7900
- HTTP_EXPOSE=7910:7900
external_links:
- ddev-router:${DDEV_SITENAME}.${DDEV_TLD}
# To enable VNC access for traditional VNC clients like macOS "Screen Sharing",
# uncomment the following two lines.
#ports:
# - "5900:5900"
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: $DDEV_APPROOT
volumes:
- ".:/mnt/ddev_config"

web:
links:
- selenium-chrome
35 changes: 35 additions & 0 deletions .github/snippets/settings.local.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/**
* @file
* Settings file to connect to a local mysql.
* Copied into position on GitHub CI runs.
*/

$databases['default']['default']['database'] = "db";
$databases['default']['default']['username'] = "user";
$databases['default']['default']['password'] = "";
$databases['default']['default']['host'] = "localhost";
$databases['default']['default']['port'] = "30123";
$databases['default']['default']['driver'] = "mysql";


// This will prevent Drupal from setting read-only permissions on sites/default.
$settings['skip_permissions_hardening'] = TRUE;

// This will ensure the site can only be accessed through the intended host
// names. Additional host patterns can be added for custom configurations.
$settings['trusted_host_patterns'] = ['.*'];

// Don't use Symfony's APCLoader. ddev includes APCu; Composer's APCu loader has
// better performance.
$settings['class_loader_auto_detect'] = FALSE;

// Set $settings['config_sync_directory'] if not set in settings.php.
if (empty($settings['config_sync_directory'])) {
$settings['config_sync_directory'] = 'sites/default/files/sync';
}

// Enable verbose logging for errors.
// https://www.drupal.org/forum/support/post-installation/2018-07-18/enable-drupal-8-backend-errorlogdebugging-mode
$config['system.logging']['error_level'] = 'verbose';
35 changes: 35 additions & 0 deletions .github/workflows/behaviour.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Behaviour Tests
on: [pull_request]

env:
PLATFORMSH_CLI_TOKEN: ${{ secrets.PLATFORMSH_CLI_TOKEN }}

jobs:
tests:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup DDEV
uses: ddev/github-action-setup-ddev@v1

# example: composer install
- run: ddev composer install

# Install Psh CLI.
- name: Install Psh CLI
run: curl -sS https://platform.sh/cli/installer | php

# Get the database to reflect main and run update.
- name: Fill database and bring Drupal up to date
run: |
~/.platformsh/bin/platform db:dump --environment=main --project=nlw7xhb3fyt7y --stdout | ddev mysql
ddev exec drush -y cache-rebuild
ddev exec drush -y updatedb
ddev exec drush -y config-import

# Finally, run the tests.
- name: Run Behat tests
run: |
ddev exec behat --colors
9 changes: 2 additions & 7 deletions .github/workflows/rachelnorfolk.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
name: RachelNorfolk Custom Modules

on:
push:
branches-ignore:
- 'main'
pull_request:
branches:
- 'main'
on: [pull_request]

jobs:
build-test:
runs-on: ubuntu-latest
Expand Down
28 changes: 28 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
default:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\DrushContext
extensions:
Drupal\DrupalExtension:
blackbox: ~
region_map:
header: "#header"
content: ".main-content"
social-bar: ".social-bar"
footer: "footer.site-footer"
Behat\MinkExtension:
base_url: http://web
selenium2:
wd_host: http://selenium-chrome:4444/wd/hub
capabilities:
chrome:
switches:
- "--disable-gpu"
- "--headless"
- "--no-sandbox"
- "--disable-dev-shm-usage"
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
"platformsh/config-reader": "^2.3"
},
"require-dev": {
"behat/mink-browserkit-driver": "^2.2",
"drupal/core-dev": "^10.2",
"drupal/drupal-extension": "^5.0",
"drupal/stage_file_proxy": "^2.1"
},
"conflict": {
Expand Down
Loading
Loading