Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • project/varbase
  • issue/varbase-3087001
  • issue/varbase-3215888
  • issue/varbase-3245763
  • issue/varbase-3253354
  • issue/varbase-3256661
  • issue/varbase-3258740
  • issue/varbase-3259665
  • issue/varbase-3260809
  • issue/varbase-3263378
  • issue/varbase-3266504
  • issue/varbase-3269421
  • issue/varbase-3269809
  • issue/varbase-3270457
  • issue/varbase-3276911
  • issue/varbase-3277590
  • issue/varbase-3285082
  • issue/varbase-3292847
  • issue/varbase-3293400
  • issue/varbase-3293696
  • issue/varbase-3298632
  • issue/varbase-3301451
  • issue/varbase-3318323
  • issue/varbase-3318847
  • issue/varbase-3346247
  • issue/varbase-3391550
  • issue/varbase-3443948
  • issue/varbase-3471788
  • issue/varbase-3479338
  • issue/varbase-3484640
30 results
Show changes
Commits on Source (5)
Showing
with 878 additions and 530 deletions
......@@ -139,6 +139,8 @@ commands:
sudo chmod 775 .
sudo chown www-data:circleci .
composer create-project vardot/varbase:9.0.x varbase --stability dev --no-interaction -vvv
cd /var/www/html/test/varbase
composer require drupal/drush_language:~1.0
cp -r /home/circleci/project /var/www/html/test/varbase/docroot/profiles/varbase
cd /var/www/html/test/varbase
sudo rm -rf config configbit css images libraries scripts src tests traslations varbase.info.yml varbase.install varbase.libraries.yml varbase.profile varbase.services.yml yarn.lock
......@@ -161,7 +163,7 @@ commands:
cd /var/www/html/test/varbase
sudo chmod 775 -R .
sudo chown www-data:circleci -R .
## Point varbase.test at /var/www/html/test/varbase/docroot
- run:
name: Point varbase.test at /var/www/html/test/varbase/docroot
......@@ -180,20 +182,20 @@ commands:
mysql -h 127.0.0.1 -uroot -prootpw --execute="CREATE DATABASE test_varbase;" -vvv
cd /var/www/html/test/varbase/docroot
../bin/drush site-install varbase --yes --account-name="webmaster" --account-pass="dD.123123ddd" --account-mail="webmaster@vardot.com" --db-url="mysql://root:rootpw@127.0.0.1/test_varbase" --locale="en" varbase_multilingual_configuration.enable_multilingual=true varbase_extra_components.vmi=true varbase_extra_components.varbase_heroslider_media=true varbase_extra_components.varbase_carousels=true varbase_extra_components.varbase_search=true varbase_extra_components.varbase_blog=true varbase_extra_components.varbase_auth=true install_configure_form.enable_update_status_emails=NULL -vvv
../bin/drush pm-enable varbase_development --yes
../bin/drush pm-enable varbase_styleguide --yes
../bin/drush pm-enable varbase_landing --yes
../bin/drush pm-enable varbase_api --yes
../bin/drush pm-enable varbase_content_planner --yes
../bin/drush pm-enable varbase_media_instagram --yes
../bin/drush pm-enable varbase_media_twitter --yes
../bin/drush pm-enable social_auth_google --yes
../bin/drush pm-enable social_auth_facebook --yes
../bin/drush pm-enable social_auth_twitter --yes
../bin/drush pm-enable social_auth_linkedin --yes
../bin/drush config-set system.performance css.preprocess 0 --yes
../bin/drush config-set system.performance js.preprocess 0 --yes
../bin/drush config-set system.logging error_level all --yes
../bin/drush pm:enable varbase_development --yes
../bin/drush pm:enable varbase_styleguide --yes
../bin/drush pm:enable varbase_landing --yes
../bin/drush pm:enable varbase_api --yes
../bin/drush pm:enable varbase_content_planner --yes
../bin/drush pm:enable varbase_media_instagram --yes
../bin/drush pm:enable varbase_media_twitter --yes
../bin/drush pm:enable social_auth_google --yes
../bin/drush pm:enable social_auth_facebook --yes
../bin/drush pm:enable social_auth_twitter --yes
../bin/drush pm:enable social_auth_linkedin --yes
../bin/drush config:set system.performance css.preprocess 0 --yes
../bin/drush config:set system.performance js.preprocess 0 --yes
../bin/drush config:set system.logging error_level all --yes
../bin/drush cr
## Configure and run the virtual display.
......@@ -211,13 +213,31 @@ commands:
java -jar selenium-server-standalone-2.53.1.jar -port 4445
background: true
## Automated Functional Acceptance Testing - Step 1 init tests.
## Add testing users.
- run:
name: Automated Functional Acceptance Testing - Step 1 init tests
no_output_timeout: 30m
name: Add testing users.
command: |
cd /var/www/html/test/varbase/docroot/profiles/varbase
../../../bin/behat --strict --no-snippets -f pretty -o std tests/features/varbase/step1-init-tests/
cd /var/www/html/test/varbase/docroot/profiles/varbase/scripts
bash add-testing-users.sh
## Enable the Drush Language Command module and add RTL language
- run:
name: Enable the Drush Language Command module and add RTL language
command: |
cd /var/www/html/test/varbase/docroot
../bin/drush pm:enable drush_language --yes
../bin/drush language-add ar
../bin/drush language-info
../bin/drush cr
## Uninstall Antibot module to let the selenium bot work
- run:
name: Uninstall Antibot module to let the selenium bot work
command: |
cd /var/www/html/test/varbase/docroot
../bin/drush pm:uninstall antibot --yes
../bin/drush cr
jobs:
varbase-testing-01-website-base-requirements:
<<: *defaults
......@@ -229,7 +249,7 @@ jobs:
no_output_timeout: 30m
command: |
cd /var/www/html/test/varbase/docroot/profiles/varbase
../../../bin/behat --strict --no-snippets -f pretty -o std tests/features/varbase/step2-apply-tests/01-website-base-requirements/
../../../bin/behat --strict --no-snippets -f pretty -o std tests/features/varbase/01-website-base-requirements/
varbase-testing-02-user-management-03-admin-management:
<<: *defaults
steps:
......@@ -240,8 +260,8 @@ jobs:
no_output_timeout: 30m
command: |
cd /var/www/html/test/varbase/docroot/profiles/varbase
../../../bin/behat --strict --no-snippets -f pretty -o std tests/features/varbase/step2-apply-tests/02-user-management/
../../../bin/behat --strict --no-snippets -f pretty -o std tests/features/varbase/step2-apply-tests/03-admin-management/
../../../bin/behat --strict --no-snippets -f pretty -o std tests/features/varbase/02-user-management/
../../../bin/behat --strict --no-snippets -f pretty -o std tests/features/varbase/03-admin-management/
varbase-testing-04-content-structure:
<<: *defaults
steps:
......@@ -252,7 +272,7 @@ jobs:
no_output_timeout: 30m
command: |
cd /var/www/html/test/varbase/docroot/profiles/varbase
../../../bin/behat --strict --no-snippets -f pretty -o std tests/features/varbase/step2-apply-tests/04-content-structure/
../../../bin/behat --strict --no-snippets -f pretty -o std tests/features/varbase/04-content-structure/
varbase-testing-05-content-management:
<<: *defaults
steps:
......@@ -263,7 +283,7 @@ jobs:
no_output_timeout: 30m
command: |
cd /var/www/html/test/varbase/docroot/profiles/varbase
../../../bin/behat --strict --no-snippets -f pretty -o std tests/features/varbase/step2-apply-tests/05-content-management/
../../../bin/behat --strict --no-snippets -f pretty -o std tests/features/varbase/05-content-management/
workflows:
version: 2
......@@ -272,13 +292,13 @@ workflows:
- varbase-testing-01-website-base-requirements:
filters:
tags:
only: /^9.*/
only: /^9.0.*/
branches:
only: /^9.0.x/
- varbase-testing-02-user-management-03-admin-management:
filters:
tags:
only: /^9.*/
only: /^9.0.*/
branches:
only: /^9.0.x/
- varbase-testing-04-content-structure:
......@@ -290,6 +310,6 @@ workflows:
- varbase-testing-05-content-management:
filters:
tags:
only: /^9.*/
only: /^9.0.*/
branches:
only: /^9.0.x/
default:
autoload:
'': "%paths.base%/tests/features/bootstrap"
suites:
default:
paths:
- "%paths.base%/tests/features"
contexts:
- VarbaseContext:
parameters:
varbase_users:
webmaster: { email: 'webmaster@vardot.com', password: 'dD.123123ddd' }
test_authenticated: { email: 'authenticated.test@vardot.com', password: 'dD.123123ddd' }
test_editor: { email: 'editor.test@vardot.com', password: 'dD.123123ddd' }
test_content_admin: { email: 'content.admin.test@vardot.com', password: 'dD.123123ddd' }
test_seo_admin: { email: 'seo.admin.test@vardot.com', password: 'dD.123123ddd' }
test_site_admin: { email: 'site.admin.test@vardot.com', password: 'dD.123123ddd' }
test_super_admin: { email: 'super.admin.test@vardot.com', password: 'dD.123123ddd' }
- VarbaseSelectorsContext:
parameters:
selectors:
## Add all css selectors which you will use in most features.
css:
breadcrumb: ".breadcrumb"
breadcrumb first link: ".breadcrumb li:nth-child(1) a"
image button in rich text editor body field: "#cke_edit-body-und-0-value .cke_button__image"
## Add all XPath selectors which you will use in most features.
xpath:
page title: '//h1[contains(@class, "page-header")'
textarea for body field: '//*[@id="edit-body-und-0-value"]'
rich text editor for body field: '//iframe[@title="Rich Text Editor, edit-body-und-0-value"]'
HTML editor for body field: '//*[@id="edit-body-und-0-value-aced"]'
## You can add list of selectorrs which you will use in most features.
# But by loading them from files.
files_path: "%paths.base%/tests/selectors/"
files:
- "varbase/front-end-selectors.yml"
- "varbase/back-end-selectors.yml"
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\DrushContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MarkupContext
formatters:
pretty:
html:
output_path: "%paths.base%/tests/reports/"
extensions:
Drupal\MinkExtension:
ajax_timeout: 60
files_path: "%paths.base%/tests/assets/"
goutte: ~
selenium2:
wd_host: 127.0.0.1:4445/wd/hub
capabilities:
# browser: 'firefox'
browser: 'chrome'
# browser: 'phantomjs'
nativeEvents: true
marionette: true
browserName: chrome
version: "*"
extra_capabilities:
chromeOptions:
args:
- "--disable-gpu"
- "--window-size=1920,1080"
w3c: false
chrome:
switches:
- "--headless"
- "no-sandbox"
- "--no-sandbox"
- "--disable-web-security"
- "--DNS-prefetch-disable"
- "--whitelisted-ips"
- "--start-maximized"
- "--disable-translate"
- "--ignore-certificate-errors"
- "--test-type"
- "--disable-dev-shm-usage"
- "--disable-extensions"
- "incognito"
- "enable-precise-memory-info"
- "ignore-certificate-errors"
- "disable-infobars"
- "js-flags=--expose-gc"
- "--profile-directory=Default"
- "--user-data-dir=~/.config/google-chrome"
base_url: 'http://varbase.test'
# browser_name: 'firefox'
browser_name: 'chrome'
# browser_name: 'phantomjs'
javascript_session: selenium2
Drupal\DrupalExtension:
blackbox: ~
api_driver: 'drupal'
region_map:
content: ".main-container"
footer: "#footer"
left header: "#header-left"
right header: "#header-right"
right sidebar: "#aside-region"
field body: "#edit-body-wrapper"
selectors:
message_selector: '.messages'
error_message_selector: '.messages.error'
success_message_selector: '.messages.status'
warning_message_selector: '.messages.warning'
emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
name: html
renderer: Twig,Behat2
file_name: index
print_args: false
print_outp: false
loop_break: false
imports:
- behat.varbase.yml
default:
autoload:
'': "%paths.base%/tests/features/bootstrap"
suites:
default:
paths:
- "%paths.base%/tests/features"
contexts:
- VarbaseContext:
parameters:
varbase_users:
webmaster: { email: 'webmaster@vardot.com', password: 'dD.123123ddd' }
Normal user: { email: 'test.authenticated@vardot.com', password: 'dD.123123ddd' }
Editor: { email: 'test.editor@vardot.com', password: 'dD.123123ddd' }
Content admin: { email: 'test.content_admin@vardot.com', password: 'dD.123123ddd' }
SEO admin: { email: 'test.seo_admin@vardot.com', password: 'dD.123123ddd' }
Site admin: { email: 'test.site_admin@vardot.com', password: 'dD.123123ddd' }
Super admin: { email: 'test.super_admin@vardot.com', password: 'dD.123123ddd' }
- VarbaseSelectorsContext:
parameters:
selectors:
## Add all css selectors which you will use in most features.
css:
breadcrumb: ".breadcrumb"
breadcrumb first link: ".breadcrumb li:nth-child(1) a"
image button in rich text editor body field: "#cke_edit-body-und-0-value .cke_button__image"
## Add all XPath selectors which you will use in most features.
xpath:
page title: '//h1[contains(@class, "page-header")'
textarea for body field: '//*[@id="edit-body-und-0-value"]'
rich text editor for body field: '//iframe[@title="Rich Text Editor, edit-body-und-0-value"]'
HTML editor for body field: '//*[@id="edit-body-und-0-value-aced"]'
## You can add list of selectorrs which you will use in most features.
# But by loading them from files.
files_path: "%paths.base%/tests/selectors/"
files:
- "varbase/front-end-selectors.yml"
- "varbase/back-end-selectors.yml"
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\DrushContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MarkupContext
formatters:
pretty:
html:
output_path: "%paths.base%/tests/reports/"
extensions:
Drupal\MinkExtension:
ajax_timeout: 60
files_path: "%paths.base%/tests/assets/"
goutte: ~
selenium2:
wd_host: 127.0.0.1:4445/wd/hub
capabilities:
# browser: 'firefox'
browser: 'chrome'
# browser: 'phantomjs'
nativeEvents: true
marionette: true
browserName: chrome
version: "*"
extra_capabilities:
chromeOptions:
args:
- "--disable-gpu"
- "--window-size=1920,1080"
w3c: false
chrome:
switches:
- "--headless"
- "no-sandbox"
- "--no-sandbox"
- "--disable-web-security"
- "--DNS-prefetch-disable"
- "--whitelisted-ips"
- "--start-maximized"
- "--disable-translate"
- "--ignore-certificate-errors"
- "--test-type"
- "--disable-dev-shm-usage"
- "--disable-extensions"
- "incognito"
- "enable-precise-memory-info"
- "ignore-certificate-errors"
- "disable-infobars"
- "js-flags=--expose-gc"
- "--profile-directory=Default"
- "--user-data-dir=~/.config/google-chrome"
base_url: 'http://varbase.test'
# browser_name: 'firefox'
browser_name: 'chrome'
# browser_name: 'phantomjs'
javascript_session: selenium2
Drupal\DrupalExtension:
blackbox: ~
api_driver: 'drupal'
region_map:
content: ".main-container"
footer: "#footer"
left header: "#header-left"
right header: "#header-right"
right sidebar: "#aside-region"
field body: "#edit-body-wrapper"
selectors:
message_selector: '.messages'
error_message_selector: '.messages.error'
success_message_selector: '.messages.status'
warning_message_selector: '.messages.warning'
emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
name: html
renderer: Twig,Behat2
file_name: index
print_args: false
print_outp: false
loop_break: false
......@@ -76,6 +76,14 @@
"secure-http": false,
"preferred-install": {
"drupal/core": "dist"
},
"allow-plugins": {
"composer/installers": true,
"cweagans/composer-patches": true,
"oomphinc/composer-installers-extender": true,
"drupal/core-composer-scaffold": true,
"drupal/core-project-message": true,
"vardot/varbase-updater": true
}
},
"autoload": {
......@@ -94,8 +102,7 @@
"Varbase\\composer\\ScriptHandler::createRequiredFiles",
"Varbase\\composer\\ScriptHandler::removeGitDirectories"
],
"post-drupal-scaffold-cmd": ["Varbase\\composer\\ScriptHandler::postDrupalScaffoldProcedure"],
"create-new-vartheme": "scripts/create-new-vartheme.sh"
"post-drupal-scaffold-cmd": ["Varbase\\composer\\ScriptHandler::postDrupalScaffoldProcedure"]
},
"extra": {
"drupal-scaffold": {
......
......@@ -27,7 +27,7 @@
],
"author": "Vardot",
"dependencies": {
"rfs": "^9.0.3"
"rfs": "^9.0.6"
},
"devDependencies": {
"autoprefixer": "^9.6.1",
......
# Varbase Scripts
## Vartheme BS4 Scripts
## Vartheme BS5 Scripts
### Quick tip on how to use this script command file.
Default settings could be changed in scripts.settings.yml
# Create a Vartheme BS4 sub theme ( Bootstrap 4 ) SASS
# Create a Vartheme BS5 sub theme ( Bootstrap 4 ) SASS
Before we generate the new sub theme we need to have the following tools
* 1. npm and nodejs : Helps getting the bootstrap 4 and popper packages.
......@@ -41,13 +41,13 @@ After we make sure that we do have all the tools we could change directory
in the terminal to:
```
$ cd PROJECT_DIR_NAME/docroot/themes/contrib/vartheme_bs4/scripts
$ bash ./create-new-vartheme-bs4.sh "THEME_NAME"
$ cd PROJECT_DIR_NAME/docroot/themes/contrib/vartheme_bs5/scripts
$ bash ./create-new-vartheme-bs5.sh "THEME_NAME"
```
We can use
```
$ cd PROJECT_DIR_NAME/docroot/themes/contrib/vartheme_bs4
$ cd PROJECT_DIR_NAME/docroot/themes/contrib/vartheme_bs5
yarn theme:create-sub-theme "THEME_NAME"
``
......
#!/bin/usr/env bash
## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
## bash add-testing-users.sh
current_path=$(pwd);
# Include the Bash YAML library.
source ${current_path}/libs/bash-yaml.sh || exit 1 ;
# Load the list of default users for Varbase.
eval $(parse_yaml ${current_path}/varbase.users.yml);
cd ../../../ ;
for user in ${users[@]}
do
user_name="user_${user}_name";
user_mail="user_${user}_mail";
user_password="user_${user}_password";
user_role="user_${user}_role";
echo " ---------------------------------------------------------------- ";
echo " User name: ${!user_name}";
echo " User mail: ${!user_mail}";
echo " User password: ${!user_password}";
echo " User role: ${!user_role}";
echo " ================================================================= ";
../vendor/drush/drush/drush user:create "${!user_name}" --mail="${!user_mail}" --password="${!user_password}" ;
if [ ! -z "${!user_role}" ]; then
../vendor/drush/drush/drush user:role:add "${!user_role}" "${!user_name}" ;
fi
done
cd ${current_path};
......@@ -16,23 +16,11 @@
##
################################################################################
# Basic yaml parser.
parse_yaml() {
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s=\"%s\"\n", "",vn, $2, $3);
}
}'
}
current_path=$(pwd);
# Include the Bash YAML library.
source ${current_path}/libs/bash-yaml.sh || exit 1 ;
drupal_root="$current_path";
if [[ "${drupal_root: -1}" == "/" ]]; then
......@@ -58,9 +46,6 @@ fi
echo "Current path: $current_path";
echo "Drupal root: $drupal_root";
# Read scripts.settings.yml file
eval $(parse_yaml $drupal_root/profiles/varbase/scripts/scripts.settings.yml);
# Default theme name.
theme_name=$default_theme_name;
......
#!//bin/bash
################################################################################
## Create new vartheme subtheme.
################################################################################
##
## Quick tip on how to use this script command file.
##
## Create new Vartheme sub theme for a project.
## By Bash:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
## bash ./create-new-vartheme.sh "THEME_NAME" "ltr"
##------------------------------------------------------------------------------
##
## For right to left themes.
## By Bash:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
## bash ./create-new-vartheme.sh "THEME_NAME" "rtl"
## -----------------------------------------------------------------------------
##
## To create a new theme in the PROJECT_DIR_NAME/docroot/themes/custom
## By Bash:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
## bash ./create-new-vartheme.sh "THEME_NAME"
## -----------------------------------------------------------------------------
##
################################################################################
# Basic yaml parser.
parse_yaml() {
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s=\"%s\"\n", "",vn, $2, $3);
}
}'
}
current_path=$(pwd);
drupal_root="$current_path";
if [[ "${drupal_root: -1}" == "/" ]]; then
drupal_root="${drupal_root:0:${#drupal_root}-1}";
fi
if [[ "${drupal_root: -24}" == "profiles/varbase/scripts" ]]; then
drupal_root="${drupal_root:0:${#drupal_root}-24}";
fi
if [[ "${drupal_root: -16}" == "profiles/varbase" ]]; then
drupal_root="${drupal_root:0:${#drupal_root}-16}";
fi
if [[ "${drupal_root: -8}" == "profiles" ]]; then
drupal_root="${drupal_root:0:${#drupal_root}-8}";
fi
if [[ "${drupal_root: -1}" == "/" ]]; then
drupal_root="${drupal_root:0:${#drupal_root}-1}";
fi
echo "Current path: $current_path";
echo "Drupal root: $drupal_root";
# Read scripts.settings.yml file
eval $(parse_yaml $drupal_root/profiles/varbase/scripts/scripts.settings.yml);
# Default theme name.
theme_name=$default_theme_name;
# Grape the theme name argument.
if [ ! -z "$1" ]; then
arg1="$1";
if [[ $arg1 =~ ^[A-Za-z][A-Za-z0-9_]*$ ]]; then
theme_name="$arg1";
else
echo "---------------------------------------------------------------------------";
echo " Theme name is not a valid theme name! ";
echo "---------------------------------------------------------------------------";
exit 1;
fi
else
echo "---------------------------------------------------------------------------";
echo " Please add the name of your theme! ";
echo "---------------------------------------------------------------------------";
exit 1;
fi
# Default direction.
direction=$default_direction;
# Grape the direction argument. only if we have arg #2.
if [ ! -z "$2" ]; then
arg2="$2";
if [[ "$arg2" == "rtl" || "$arg2" == "RTL" ]]; then
direction=$arg2;
elif [[ "$arg2" == "ltr" || "$arg2" == "LTR" ]]; then
direction=$arg2;
else
echo "---------------------------------------------------------------------------";
echo " Direction of language is not valid! ";
echo " ltr - for (left to right) languages. ";
echo " rtl - for (right to left) languages. ";
echo "---------------------------------------------------------------------------";
exit 1;
fi
fi
# Default themes creation path.
theme_path=$drupal_root/$default_themes_creation_path;
mkdir -p ${theme_path};
cp ${current_path}/README.md ${theme_path}/README.md
# Create the new Vartheme subtheme if we do not have a folder with that name yet.
if [[ ! -d "$theme_path/$theme_name" ]]; then
# 1. Copy the VARTHEME_SUBTHEME folder to your custom theme location.
cp -r ${drupal_root}/themes/contrib/vartheme/VARTHEME_SUBTHEME ${theme_path}/${theme_name};
# 2. Rename VARTHEME_SUBTHEME.starterkit.yml your_subtheme_name.info.yml
mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.starterkit.yml ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.info.yml ;
mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.info.yml ${theme_path}/${theme_name}/${theme_name}.info.yml ;
# 3. Rename VARTHEME_SUBTHEME.libraries.yml your_subtheme_name.libraries.yml
mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.libraries.yml ${theme_path}/${theme_name}/${theme_name}.libraries.yml ;
# 4. Rename VARTHEME_SUBTHEME.theme your_subtheme_name.theme
mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.theme ${theme_path}/${theme_name}/${theme_name}.theme ;
# 5. Rename VARTHEME_SUBTHEME.settings.yml
mv ${theme_path}/${theme_name}/config/install/VARTHEME_SUBTHEME.settings.yml ${theme_path}/${theme_name}/config/install/${theme_name}.settings.yml ;
# 6. Rename VARTHEME_SUBTHEME.schema.yml
mv ${theme_path}/${theme_name}/config/schema/VARTHEME_SUBTHEME.schema.yml ${theme_path}/${theme_name}/config/schema/${theme_name}.schema.yml ;
# 7.1 Rename VARTHEME_SUBTHEME optional blocks.
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_branding.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_branding.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_breadcrumbs.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_breadcrumbs.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_content.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_content.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_copyright.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_copyright.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_footer.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_footer.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_help.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_help.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_local_actions.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_local_actions.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_local_tasks.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_local_tasks.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_main_menu.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_main_menu.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_messages.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_messages.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_page_title.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_page_title.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_socialauthlogin.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_socialauthlogin.yml
mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_views_block__varbase_heroslider_media_varbase_heroslider_media.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_views_block__varbase_heroslider_media_varbase_heroslider_media.yml
# 7.2 Rename the extentions of TWIG template files.
# html.html.twig is very important and needed file for RTL websites.
mv ${theme_path}/${theme_name}/templates/system/html.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/system/html.html.twig
# Custom Better Login templates for edit, login, rest password, and register template files.
mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--edit.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--edit.html.twig
mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--login.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--login.html.twig
mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--password.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--password.html.twig
mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--register.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--register.html.twig
mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--reset.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--reset.html.twig
# 8. Rename VARTHEME_SUBTHEME.base.css files.
mv ${theme_path}/${theme_name}/css/base/VARTHEME_SUBTHEME.base.css ${theme_path}/${theme_name}/css/base/${theme_name}.base.css
# 9. Rename VARTHEME_SUBTHEME-rtl.base.css files.
mv ${theme_path}/${theme_name}/css/rtl/base/VARTHEME_SUBTHEME-rtl.base.css ${theme_path}/${theme_name}/css/rtl/base/${theme_name}-rtl.base.css
# 10. Rename VARTHEME_SUBTHEME.base.less file.
mv ${theme_path}/${theme_name}/less/base/VARTHEME_SUBTHEME.base.less ${theme_path}/${theme_name}/less/base/${theme_name}.base.less
# 11. Rename VARTHEME_SUBTHEME-rtl.base.less file.
mv ${theme_path}/${theme_name}/less/rtl/base/VARTHEME_SUBTHEME-rtl.base.less ${theme_path}/${theme_name}/less/rtl/base/${theme_name}-rtl.base.less
# 12. Replace all VARTHEME_SUBTHEME with the machine name of your theme.
grep -rl 'VARTHEME_SUBTHEME' ${theme_path}/${theme_name} | xargs sed -i "s/VARTHEME_SUBTHEME/${theme_name}/g" ;
# 13. Replace the name: 'Vartheme Sub-Theme (LESS)' to the name of your theme.
grep -rl 'Vartheme Sub-Theme (LESS)' ${theme_path}/${theme_name} | xargs sed -i "s/Vartheme Sub-Theme (LESS)/${theme_name}/g" ;
# 14. If we want to use the RTL (right to left) bootstrap.
# 15.1 Delete the template folder bootstrap.
rm -rf ${theme_path}/${theme_name}/bootstrap ;
# 15.2 Download the bootstrap library. change the version as you need.
wget -P ${theme_path}/${theme_name} https://github.com/twbs/bootstrap/archive/v${bootstrap_library_version}.tar.gz -vvv
# 15.3 Extract the bootstrap library.
mkdir ${theme_path}/${theme_name}/bootstrap
tar -xzvf ${theme_path}/${theme_name}/v${bootstrap_library_version}.tar.gz --strip-components=1 -C ${theme_path}/${theme_name}/bootstrap -vvv
# 15.4 Delete the archived bootstrap library.
rm ${theme_path}/${theme_name}/v${bootstrap_library_version}.tar.gz
# 16. If we want to use the RTL (right to left) bootstrap.
if [[ $direction == "rtl" || $direction == "RTL" ]]; then
# 16.1. Delete the template folder bootstrap-rtl.
rm -rf ${theme_path}/${theme_name}/bootstrap-rtl ;
# 16.2. Download the bootstrap library. change the version as you need.
wget -P ${theme_path}/${theme_name} https://github.com/morteza/bootstrap-rtl/archive/v${bootstrap_rtl_library_version}.tar.gz -vvv
# 16.3. Extract the bootstrap library.
mkdir ${theme_path}/${theme_name}/bootstrap-rtl
tar -xzvf ${theme_path}/${theme_name}/v${bootstrap_rtl_library_version}.tar.gz --strip-components=1 -C ${theme_path}/${theme_name}/bootstrap-rtl -vvv
# 16.4. Delete the archived bootstrap library.
rm ${theme_path}/${theme_name}/v${bootstrap_rtl_library_version}.tar.gz
fi
generated_datetime="$(date '+%Y/%m/%d - %H:%M:%S')";
generated_log=" Generated by -- create-new-vartheme ${theme_name} ${direction} ${theme_path} -- on ${generated_datetime}";
echo "${generated_log}" >> ${theme_path}/${theme_name}/README.md;
echo "---------------------------------------------------------------------------";
echo " The new Vartheme subtheme were created at \"${theme_path}/${theme_name} :)\" ";
echo "---------------------------------------------------------------------------";
exit 0;
else
echo "---------------------------------------------------------------------------";
echo " The folder \"${theme_path}/${theme_name}\" is already in the site!";
echo "---------------------------------------------------------------------------";
exit 1;
fi
#!/bin/usr/env bash
## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
## bash delete-testing-users.sh
current_path=$(pwd);
# Include the Bash YAML library.
source ${current_path}/libs/bash-yaml.sh || exit 1 ;
# Load the list of default users for Varbase.
eval $(parse_yaml ${current_path}/varbase.users.yml);
cd ../../../ ;
for user in ${users[@]}
do
user_name="user_${user}_name";
user_mail="user_${user}_mail";
user_password="user_${user}_password";
user_role="user_${user}_role";
echo " ---------------------------------------------------------------- ";
echo " User name: ${!user_name}";
echo " User mail: ${!user_mail}";
echo " User password: ${!user_password}";
echo " User role: ${!user_role}";
echo " ================================================================= ";
../vendor/drush/drush/drush user:cancel --delete-content "${!user_name}" --yes;
done
cd ${current_path};
\ No newline at end of file
#!/usr/bin/env bash
# shellcheck disable=SC1003
# Based on https://gist.github.com/pkuczynski/8665367
parse_yaml() {
local yaml_file=$1
local prefix=$2
local s
local w
local fs
s='[[:space:]]*'
w='[a-zA-Z0-9_.-]*'
fs="$(echo @|tr @ '\034')"
(
sed -e '/- [^\“]'"[^\']"'.*: /s|\([ ]*\)- \([[:space:]]*\)|\1-\'$'\n'' \1\2|g' |
sed -ne '/^--/s|--||g; s|\"|\\\"|g; s/[[:space:]]*$//g;' \
-e "/#.*[\"\']/!s| #.*||g; /^#/s|#.*||g;" \
-e "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)${s}[:-]$s\(.*\)$s\$|\1$fs\2$fs\3|p" |
awk -F"$fs" '{
indent = length($1)/2;
if (length($2) == 0) { conj[indent]="+";} else {conj[indent]="";}
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s%s=(\"%s\")\n", "'"$prefix"'",vn, $2, conj[indent-1],$3);
}
}' |
sed -e 's/_=/+=/g' |
awk 'BEGIN {
FS="=";
OFS="="
}
/(-|\.).*=/ {
gsub("-|\\.", "_", $1)
}
{ print }'
) < "$yaml_file"
}
create_variables() {
local yaml_file="$1"
eval "$(parse_yaml "$yaml_file")"
}
\ No newline at end of file
bootstrap:
library_version: "3.4.0"
rtl_library_version: "3.4.0"
default_themes_creation_path: "themes/custom"
default_theme_name: "mytheme"
default_direction: "ltr"
varbase:
title: "Varbase"
users:
- authenticated
- editor
- content_admin
- seo_admin
- site_admin
- super_admin
user:
authenticated:
name: Normal user
mail: test.authenticated@vardot.com
password: dD.123123ddd
role: null
editor:
name: Editor
mail: test.editor@vardot.com
password: dD.123123ddd
role: editor
content_admin:
name: Content admin
mail: test.content_admin@vardot.com
password: dD.123123ddd
role: content_admin
seo_admin:
name: SEO admin
mail: test.seo_admin@vardot.com
password: dD.123123ddd
role: seo_admin
site_admin:
name: Site admin
mail: test.site_admin@vardot.com
password: dD.123123ddd
role: site_admin
super_admin:
name: Super admin
mail: test.super_admin@vardot.com
password: dD.123123ddd
role: administrator
......@@ -21,7 +21,7 @@ function varbase_development_get_editable_config_names() {
],
'reroute_email.settings' => [
'address' => 'dev-catchall@vardot.com',
'whitelist' => '*@vardot.com',
'allowed' => '*@vardot.com',
],
];
......@@ -56,16 +56,18 @@ function varbase_development_build_formbit(array &$formbit, FormStateInterface &
'#type' => 'textfield',
'#title' => t('Rerouting email addresses'),
'#default_value' => 'dev-catchall@vardot.com',
'#description' => t('Provide a space, comma, or semicolon-delimited list of email addresses.<br/>Every destination email address which is not on "Whitelisted email addresses" list will be rerouted to these addresses.<br/>If the field is empty and no value is provided, all outgoing emails would be aborted and the email would be recorded in the recent log entries (if enabled).'),
'#element_validate' => ['validate_formbit_emails'],
'#description' => t('Provide a comma-delimited list of email addresses. Every destination email address which is not fit with "Skip email rerouting for" lists will be rerouted to these addresses.<br/>If this field is empty and no value is provided, all outgoing emails would be aborted and the email would be recorded in the recent log entries (if enabled).'),
'#element_validate' => ['validate_formbit_multiple_emails', 'validate_formbit_multiple_unique'],
'#reroute_config_delimiter' => ',',
];
$formbit['whitelist'] = [
'#type' => 'textfield',
'#title' => t('Whitelisted email addresses'),
$formbit['allowed'] = [
'#type' => 'textarea',
'#rows' => 2,
'#title' => t('Skip email rerouting for email addresses:'),
'#default_value' => '*@vardot.com',
'#description' => ('Provide a space, comma, or semicolon-delimited list of email addresses to pass through. <br/>Every destination email address which is not on this list will be rerouted.<br/>If the field is empty and no value is provided, all outgoing emails would be rerouted.<br/>We can use wildcard email "*@example.com" to whitelist all emails by the domain.'),
'#element_validate' => ['validate_formbit_emails'],
'#description' => t('Provide a line-delimited list of email addresses to pass through. All emails to addresses from this list will not be rerouted.<br/>A patterns like "*@example.com" and "myname+*@example.com" can be used to add all emails by its domain or the pattern.'),
'#element_validate' => ['validate_formbit_multiple_emails', 'validate_formbit_multiple_unique'],
];
}
......@@ -86,7 +88,7 @@ function varbase_development_submit_formbit(array $editable_config_values) {
// Save the changed values for reroute_email.settings config.
$rerouteEmailSettingsConfig = \Drupal::configFactory()->getEditable('reroute_email.settings');
$rerouteEmailSettingsConfig->set('address', $editable_config_values['reroute_email.settings']['address']);
$rerouteEmailSettingsConfig->set('whitelist', $editable_config_values['reroute_email.settings']['whitelist']);
$rerouteEmailSettingsConfig->set('allowed', $editable_config_values['reroute_email.settings']['allowed']);
$rerouteEmailSettingsConfig->save(TRUE);
}
......@@ -98,7 +100,7 @@ function varbase_development_submit_formbit(array $editable_config_values) {
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
function validate_formbit_emails(array $element, FormStateInterface $form_state) {
function validate_formbit_multiple_emails(array $element, FormStateInterface $form_state) {
// Allow only valid email addresses.
$addresses = formbit_reroute_email_split_string($form_state->getValue($element['#name']));
$email_validator = new EmailValidator();
......@@ -114,6 +116,20 @@ function validate_formbit_emails(array $element, FormStateInterface $form_state)
$form_state->setValue($element['#name'], implode(',', $addresses));
}
/**
* Validate multiple email addresses field.
*
* @param array $element
* A field array to validate.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
function validate_formbit_multiple_unique(array $element, FormStateInterface $form_state): void {
// String "email@example.com; ;; , ,," save just as "email@example.com".
// This will be ignored if any validation errors occur.
$form_state->setValue($element['#name'], implode($element['#reroute_config_delimiter'] ?? PHP_EOL, formbit_reroute_email_split_string($form_state->getValue($element['#name']))));
}
/**
* Split a string into an array by pre defined allowed delimiters.
*
......@@ -134,3 +150,20 @@ function formbit_reroute_email_split_string($string) {
return $array;
}
/**
* Adjust rows value according to the content size.
*
* @param array $element
* The render array to add the access denied message to.
*
* @return array
* The updated render array.
*/
function validate_formbit_textarea_rows_value(array $element): array {
$size = substr_count($element['#default_value'], PHP_EOL) + 1;
if ($size > $element['#rows']) {
$element['#rows'] = min($size, 10);
}
return $element;
}
......@@ -4,7 +4,6 @@
step definitions, and assets, which help with the automatic testing for
varbase project websites.
This page can help you to have the list all steps, which you need to run the
Behat Gherkin Features to test a varbase website in your localhost machine.
......@@ -17,59 +16,194 @@ the composer.
composer create-project vardot/varbase:9.0.x-dev PROJECT_DIR_NAME --stability dev --no-interaction
```
--------------------------------------------------------------------------------
1. Change the base url value in behat.varbase.yml file, to the domain or the
local virtual domain.
### Add needed testing packages
```
cd path to your files of the project/PROJECT_DIR_NAME
composer require --dev drupal/core-dev:~9.0
composer require --dev drush/drush:~10
composer require --dev drupal/drupal-extension:~4.0
composer require --dev emuse/behat-html-formatter:^0.2.0
```
### Install Varbase
Have Varbase installed from the browser or using the `drush site:install` command.
But make sure to have the webmaster user with the `dD.123123ddd` passwrod.
Exmaple Drush install:
Change directory in the terminal to the path of the project and `/PROJECT_DIR_NAME/docroot`
```
../bin/drush site-install varbase --yes --account-name="webmaster" --account-pass="dD.123123ddd" --account-mail="webmaster@vardot.com" --db-url="mysql://root:rootpw@127.0.0.1/test_varbase" --locale="en" varbase_multilingual_configuration.enable_multilingual=true varbase_extra_components.vmi=true varbase_extra_components.varbase_heroslider_media=true varbase_extra_components.varbase_carousels=true varbase_extra_components.varbase_search=true varbase_extra_components.varbase_blog=true varbase_extra_components.varbase_auth=true install_configure_form.enable_update_status_emails=NULL -vvv
```
### Enable all Varbase components
Make sure that all varbase modules are insalled.
```
../bin/drush pm:enable vmi --yes
../bin/drush pm:enable varbase_heroslider_media --yes
../bin/drush pm:enable varbase_carousels --yes
../bin/drush pm:enable varbase_search --yes
../bin/drush pm:enable varbase_blog --yes
../bin/drush pm:enable varbase_development --yes
../bin/drush pm:enable varbase_styleguide --yes
../bin/drush pm:enable varbase_landing --yes
../bin/drush pm:enable varbase_api --yes
../bin/drush pm:enable varbase_content_planner --yes
../bin/drush pm:enable varbase_media_instagram --yes
../bin/drush pm:enable varbase_media_twitter --yes
../bin/drush pm:enable varbase_auth --yes
../bin/drush pm:enable social_auth_google --yes
../bin/drush pm:enable social_auth_facebook --yes
../bin/drush pm:enable social_auth_twitter --yes
../bin/drush pm:enable social_auth_linkedin --yes
../bin/drush cr
```
### Enable the Drush Language Command module and add RTL language
Needed to add the extra languages.
```
composer require drupal/drush_language:~1.0
../bin/drush pm:enable drush_language --yes
../bin/drush language-add ar
../bin/drush language-info
../bin/drush cr
```
### Uninstall Antibot module to let the
```
../bin/drush pm:uninstall antibot --yes
../bin/drush cr
```
### Change config for error reporting and CSS/JS aggrigation
```
../bin/drush config:set system.performance css.preprocess 0 --yes
../bin/drush config:set system.performance js.preprocess 0 --yes
../bin/drush config:set system.logging error_level all --yes
../bin/drush cr
```
### Add testing users.
Change directory in the terminal to the path of the project
and `/PROJECT_DIR_NAME/docroot/docroot/profiles/varbase/scripts`
And run the following base command
```
bash add-testing-users.sh
```
To delete testing users use
```
bash delete-testing-users.sh
```
## 1. Change the base url
Edit the behat.yml file, which located in:
`path to your files of the project/PROJECT_DIR_NAME/docroot/profiles/varbase/behat.yml`
to the domain or the local virtual domain.
```
base_url: 'http://localhost/testing/docroot'
```
--------------------------------------------------------------------------------
2. Open a new terminal window then start selenium2 at the port 4445. You can
## 2. Open a new terminal window then start selenium2 at the port 4445. You can
change the worker selenium robot server and the port number by changing the parameter.
```
"wd_host: 127.0.0.1:4445/wd/hub"
```
in the behat.varbase.yml file.
or you can get the selenium stand alone server from
http://www.seleniumhq.org/download/
then you could run this command in the same location in the terminal
in the behat.yml file.
Follow with the following steps to get all needed tools for selenium to work.
### Install Java.
```
sudo apt update
sudo apt install -y openjdk-11-jre openjdk-11-jre-headless openjdk-11-jdk openjdk-11-jdk-headless
```
### Install/Update Google Chrome browser.
```
sudo apt-get install libappindicator1 fonts-liberation libgbm1 libgtk-3-0 xdg-utils
export CHROME_BIN=/usr/bin/google-chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
rm google-chrome-stable_current_amd64.deb
```
### Install/Update Chrome Driver.
```
CHROME_DRIVER_VERSION=$(wget -qO- chromedriver.storage.googleapis.com/LATEST_RELEASE);
echo $CHROME_DRIVER_VERSION;
wget http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo chmod +x chromedriver
sudo mv -f chromedriver /usr/bin/
rm chromedriver_linux64.zip
```
### Get selenium standalone server.
```
$ java -jar selenium-*.jar -port 4445
wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
```
You can Install and configure selenium server to run on the selenium worker
server by using our command.
## Run selenium standalone server.
```
$ sh ./tools/install-selenium-server/install-selenium-server-2.53.1.sh
$ java -jar selenium-*.jar -port 4445
```
--------------------------------------------------------------------------------
3. Automated testing config.
## 3. Automated testing config.
To run the automated testing with behat you will need to change the [ wd_host and base_url ] settings in the [ behat.varbase.yml ] file to go with your project configuration and the selenium server.
```
Behat\MinkExtension:
Drupal\MinkExtension:
ajax_timeout: 60
files_path: "%paths.base%/tests/assets/"
goutte: ~
selenium2:
wd_host: 127.0.0.1:4445/wd/hub
capabilities:
browser: 'firefox'
# browser: 'chrome'
# browser: 'firefox'
browser: 'chrome'
# browser: 'phantomjs'
nativeEvents: true
base_url: 'http://127.0.0.1:8080'
browser_name: 'firefox'
# browser_name: 'chrome'
marionette: true
browserName: chrome
version: "*"
extra_capabilities:
chromeOptions:
args:
- "--disable-gpu"
- "--window-size=1920,1080"
w3c: false
chrome:
switches:
- "--headless"
- "no-sandbox"
- "--no-sandbox"
- "--disable-web-security"
- "--DNS-prefetch-disable"
- "--whitelisted-ips"
- "--start-maximized"
- "--disable-translate"
- "--ignore-certificate-errors"
- "--test-type"
- "--disable-dev-shm-usage"
- "--disable-extensions"
- "incognito"
- "enable-precise-memory-info"
- "ignore-certificate-errors"
- "disable-infobars"
- "js-flags=--expose-gc"
- "--profile-directory=Default"
- "--user-data-dir=~/.config/google-chrome"
base_url: 'http://varbase.test'
# browser_name: 'firefox'
browser_name: 'chrome'
# browser_name: 'phantomjs'
javascript_session: selenium2
```
......@@ -80,11 +214,11 @@ terminal then you could run the following command:
```
$ ../../../bin/behat tests/features/varbase
```
4. Run the behat command at PROJECT_DIR_NAME/docroot/profiles/varbase/tests
## 4. Run the behat command at PROJECT_DIR_NAME/docroot/profiles/varbase/tests
$ ../../../bin/behat tests/features/varbase/step2-apply-tests/01-website-base-requirements/01-01-user-registration_only-admins-login.feature
================================================================================
```
$ ../../../bin/behat tests/features/varbase/01-website-base-requirements/01-01-user-registration_only-admins-login.feature
```
```
Feature: Website Base Requirements - User Registration - Only admins login
......@@ -118,27 +252,27 @@ So that I will need a site admin or super admin to add me to the website
0m2.21s (59.89Mb)
```
================================================================================
--------------------------------------------------------------------------------
5. Run this command with the .feature file to run the Gherkin Script in it to the installed site.
## 5. Run this command with the .feature file to run the Gherkin Script in it to the installed site.
$ ../../../bin/behat tests/features/varbase/your-gherkin-feature.feature
$ ../../../bin/behat tests/features/project-name/your-gherkin-feature.feature
--------------------------------------------------------------------------------
8. Run this command to print all available step definitions
## 8. Run this command to print all available step definitions
```
$ ../../../bin/behat -di
- use -dl to just list definition expressions.
- use -di to show definitions with extended info.
- use -d 'needle' to find specific definitions.
```
All Varbase custom step definitions are tagged with #varbase tag.
All Varbase custom step definitions are tagged with #varbase tag.
Example: after a run for bin/behat -di command.
Example : after a run for bin/behat -di command.
================================================================================
```
default | Then /^I should see image with the "([^"]*)" title text$/
| #varbase : To Find an image with the title text attribute.
......@@ -150,7 +284,6 @@ $ ../../../bin/behat -di
| Example 1: Then I should see image with the "Flag Earth" alt text
| at `VarbaseContext::iShouldSeeImageWithTheAltText()`
```
================================================================================
Scenarios are tagged with the Behat tags of:
......@@ -159,30 +292,28 @@ $ ../../../bin/behat -di
* **@staging = Staging and testing server.**
* **@production = Production live server.**
So that we only run bin/behat --tags with the right tag for the environment.
So that we only run bin/behat --tags with the right tag for the environment.
Example:
================================================================================
Example:
```
$ ../../../bin/behat --tags '@development' tests/features/varbase/
$ ../../../bin/behat --tags '@development' tests/features/varbase/
```
Which it will run Scenarios which has got the @development tag.
================================================================================
```
$ ../../../bin/behat --tags '@staging' ftests/eatures/varbase/
Which it will run Scenarios which has got the @development tag.
Which it will run Scenarios which has got the @staging tag.
```
================================================================================
$ ../../../bin/behat --tags '@staging' ftests/eatures/varbase/
```
$ ../../../bin/behat --tags '@production' tests/features/varbase/
Which it will run Scenarios which has got the @staging tag.
Which it will run Scenarios which has got the @production tag.
```
$ ../../../bin/behat --tags '@production' tests/features/varbase/
```
Which it will run Scenarios which has got the @production tag.
================================================================================
6. To see the report in HTML. Go and open this file in a browser.
## 9. To see the report in HTML. Go and open this file in a browser.
PROJECT_DIR_NAME/docroot/profiles/varbase/tests/reports/index.html
You will see the latest report for latest run.
......@@ -196,50 +327,25 @@ $ ../../../bin/behat -di
$ ../../../bin/behat tests/features/example.feature --format pretty --out std --format html --out reports/report-$( date '+%Y-%m-%d_%H-%M-%S' )
7. If you want to run all Gherkin Features over a new Varbase site.
You will need to create the list of Testing users, and Add French, and Arabic
languages to the site.
# --------------------------------------------------------------------------
# You can run the following command:
# --------------------------------------------------------------------------
```
$ ../../../bin/behat tests/features/varbase/ --format pretty --out std --format html --out reports/report-$( date '+%Y-%m-%d_%H-%M-%S' )
```
After that you can see the report in the PROJECT_DIR_NAME/docroot/profiles/varbase/tests/reports folder.
# 10. If you want to run all Gherkin Features over a new Varbase site.
You will need to create the list of Testing users, and Add Arabic
languages to the site.
If you want to run the test in steps, if you are not interested in the
initialization and cleaning up after the test.
You can run the following command:
```
$ ../../../bin/behat tests/features/varbase/step1-init-tests
$ ../../../bin/behat tests/features/varbase/step2-apply-tests
$ ../../../bin/behat tests/features/varbase/step3-cleanup-tests
$ ../../../bin/behat tests/features/varbase/ --format pretty --out std --format html --out reports/report-$( date '+%Y-%m-%d_%H-%M-%S' )
```
After that you can see the report in the PROJECT_DIR_NAME/docroot/profiles/varbase/tests/reports folder.
# Advanced customized automated testing
To run the automated testing with behat you will need to change the [ wd_host and base_url ] settings in the
[ behat.varbase.yml ] file to go with your project configuration and the selenium server.
If you want to run the test in steps, if you are not interested in the
initialization and cleaning up after the test.
```
Behat\MinkExtension:
files_path: "%paths.base%/tests/assets/"
goutte: ~
selenium2:
wd_host: 127.0.0.1:4445/wd/hub
capabilities:
browser: 'firefox'
# browser: 'chrome'
# browser: 'phantomjs'
nativeEvents: true
base_url: 'http://127.0.0.1:8080'
browser_name: 'firefox'
# browser_name: 'chrome'
# browser_name: 'phantomjs'
javascript_session: selenium2
$ ../../../bin/behat tests/features/varbase
```
Testing scenarios are tagged with the Behat tags of:
### Testing scenarios are tagged with the Behat tags of:
* **@local = Local**
* **@development = Development server.**
......@@ -281,9 +387,9 @@ cd docroot/profiles/varbase;
Run the varbase full tests. init, apply, then cleanup.
```
cd docroot/profiles/varbase;
../../../bin/behat tests/features/varbase/step1-init-tests --format pretty --out std --format html --out tests/reports/varbase-init-tests-report-$( date '+%Y-%m-%d_%H-%M-%S' );
../../../bin/behat tests/features/varbase/step2-apply-tests --format pretty --out std --format html --out tests/reports/varbase-apply-tests-report-$( date '+%Y-%m-%d_%H-%M-%S' );
../../../bin/behat tests/features/varbase/step3-cleanup-tests --format pretty --out std --format html --out tests/reports/varbase-cleanup-tests-report-$( date '+%Y-%m-%d_%H-%M-%S' );
../../../bin/behat tests/features/varbase --format pretty --out std --format html --out tests/reports/varbase-apply-tests-report-$( date '+%Y-%m-%d_%H-%M-%S' );
```
Run the varbase full tests. Which equivalent to varbase-init-tests, varbase-apply-tests, varbase-cleanup-tests
......
......@@ -68,7 +68,7 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
* Varbase Context #varbase. If you want to see the list of users or add yours you can go and
* edit the behat.varbase.yml file under the varbase_users list.
*
* Example: I am a logged in user with the username "test_content_admin"
* Example: I am a logged in user with the username "Content admin"
*
* @Given /^I am a logged in user with (?:|the )"(?P<username>[^"]*)"(?:| user)$/
* @Then /^I login with (?:|the )"(?P<username>[^"]*)"(?:| user)$/
......@@ -93,6 +93,8 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
if ($this->matchingElementAfterWait('css', '[data-drupal-selector="edit-name"]', 6000)) {
$page->fillField('name', $username);
$page->fillField('pass', $password);
$this->iScrollToBottom();
$this->iWaitForSeconds(2);
$submit = $page->findButton('op');
$submit->click();
}
......@@ -125,6 +127,8 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
if ($this->matchingElementAfterWait('css', '[data-drupal-selector="edit-name"]', 6000)) {
$page->fillField('name', $username);
$page->fillField('pass', $password);
$this->iScrollToBottom();
$this->iWaitForSeconds(2);
$submit = $page->findButton('op');
$submit->click();
}
......@@ -664,6 +668,221 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
}
/**
* Section Configuration Functions
*
* =========================================================
*/
/**
* Select a section container type
*
* Varbase Context #varbase
*
* Example #1: When I select the "Edge to Edge" container type
* Example #2: And I select the "Boxed" container type
*
* @Then I select the :arg1 container type
*/
public function iSelectTheContainerType($name) {
$element = $this->getSession()->getPage()->find('xpath', "//label[contains(.,'$name') and contains(@for, 'edit-layout-settings-ui-tab-content-layout-container-type')]");
$element->click();
}
/**
* Select a section container width
*
* Varbase Context #varbase
*
* Example #1: When I select the "Tiny" container width
* Example #2: And I select the "Narrow" container width
*
* @Then I select the :arg1 container width
*/
public function iSelectTheContainerWidth($width) {
$element = $this->getSession()->getPage()->find('xpath', "//label[contains(.,'$width') and contains(@for, 'edit-layout-settings-ui-tab-content-layout-container-width')]");
$element->click();
}
/**
* Select a section breakpoint
*
* Varbase Context #varbase
*
* Example #1: Then I select the "md" "33% 67%" breakpoint
* Example #2: Then I select the "xs" "75% 25%" breakpoint
*
*
* @Then I select the :arg1 :arg2 breakpoint
*/
public function iSelectTheBreakpoint($size, $point) {
$element = $this->getSession()->getPage()->find('xpath', "//*[contains(@class,'$size') and contains(.,'$point')]");
$element->click();
}
/**
* Select with gutters option for section
*
* Varbase Context #varbase
*
* Example: And I add gutters
*
* @Then I add gutters
*/
public function iAddGutters() {
$with_gutters = $this->getSession()->getPage()->find('xpath', "//label[contains(., 'With Gutters')]");
$with_gutters->click();
}
/**
* Remove gutters between columns
*
* Varbase Context #varbase
*
* Example: And I remove gutters between columns
*
* @Then I remove gutters between columns
*/
public function iRemoveGuttersBetweenColumns() {
$no_gutters = $this->getSession()->getPage()->find('xpath', "//*[contains(@class, 'vlb_gutters_between')]");
$no_gutters->click();
}
/**
* Move to the styles tab
*
* Varbase Context #varbase
*
* Example: When I move to the styles tab
*
* @Then I move to the styles tab
*/
public function iMoveToTheStylesTab() {
$styles_tab = $this->getSession()->getPage()->find('xpath', "//a[contains(@data-target, 'appearance')]");
$styles_tab->click();
}
/**
* Open a specific setting menu under styles tab in section configuration
*
* Varbase Context #varbase
*
* Example #1: And I open the "Background" settings menu
* Example #2: When I open the "Border" settings menu
*
* @Then I open the :arg1 settings menu
*/
public function iOpenTheSettingsMenu($menu) {
$menu = $this->getSession()->getPage()->find('xpath', "//span[contains(., '$menu') and contains(@class, 'bs-group-title')]");
$menu->click();
}
/**
* Select a background color
*
* Varbase Context #varbase
*
* Example #1: Then I select the "Primary" background color
* Example #2: And I select the "Light" background color
*
* @Then I select the :arg1 background color
*/
public function iSelectTheBackgroundColor($bg_color) {
$bg_color = $this->getSession()->getPage()->find('xpath', "//label[contains(., '$bg_color') and contains(@for, 'edit-layout-settings-ui-tab-content-appearance-background-background-color')]");
$bg_color->click();
}
/**
* Uncheck the Edge to Edge Background option
*
* Varbase Contaxt #varbase
*
* Example: And I uncheck the Edge to Edge Background
*
* @Then I uncheck the Edge to Edge Background
*/
public function iUncheckTheEdgeToEdgeBackground() {
$e2e = $this->getSession()->getPage()->find('xpath', "//input[contains(@class, 'field-background-edge-to-edge')]");
$e2e->click();
}
/**
* Select a text color
*
* Varbase Context #varbase
*
* Example #1: Then I select the "Dark" text color
* Example #2: And I select the "White" text color
*
* @Then I select the :arg1 text color
*/
public function iSelectTheTextColor($color) {
$text_color = $this->getSession()->getPage()->find('xpath', "//label[contains(., '$color') and contains(@for, 'edit-layout-settings-ui-tab-content-appearance-typography-text-color-text')]");
$text_color->click();
}
/**
* Set alignment of text
*
* Varbase Context #varbase
*
* Example #1: Then I set the alignment to "End"
* Example #2: And I set the alignment to "Start"
*
* @Then I set the alignment to :arg1
*/
public function iSetTheAlignmentTo($align) {
$alignment = $this->getSession()->getPage()->find('xpath', "//label[contains(., '$align') and contains(@for, 'edit-layout-settings-ui-tab-content-appearance-typography-text-alignment')]");
$alignment->click();
}
/**
* Set horizontal alignment for blocks
*
* Varbase Context #varbase
*
* Example #1: Then I set the Horizontal alignment to "Align center"
* Example #2: And I set the horizontal alignment to "Align start"
*
* @Then I set the Horizontal alignment to :arg1
*/
public function iSetTheHorizontalAlignmentTo($h_align) {
$horizontal_alignment = $this->getSession()->getPage()->find('xpath', "//label[contains(., '$h_align') and contains(@for, 'edit-layout-settings-ui-tab-content-appearance-alignment-horizontal-alignment-justify-content')]");
$horizontal_alignment->click();
}
/**
* Set vertical alignment for blocks
*
* Varbase Context #varbase
*
* Example #1: Then I set the Vertical alignment to "Align bottom"
* Example #2: And I set the Vertical alignment to "Align middle"
*
* @Then I set the Vertical alignment to :arg1
*/
public function iSetTheVerticalAlignmentTo($v_align) {
$vertical_alignment = $this->getSession()->getPage()->find('xpath', "//label[contains(., '$v_align') and contains(@for, 'edit-layout-settings-ui-tab-content-appearance-alignment-vertical-alignment-align-items')]");
$vertical_alignment->click();
}
/**
* Select an animation for a section
*
* Varbase Context #varbase
*
* Example #1: Then I select the "Flip Right" animation
* Example #2: When I select the "Zoom Out" animation
*
* @Then I select the :arg1 animation
*/
public function iSelectTheAnimation($anime) {
$animation = $this->getSession()->getPage()->find('xpath', "//label[contains(., '$anime') and contains(@for, 'edit-layout-settings-ui-tab-content-appearance-animation-scroll-effects')]");
$animation->click();
}
/**
* Images Functions.
*
......@@ -1056,7 +1275,7 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
*/
public function iShouldSeeValueInTheInputElement($text, $selector) {
$elements = $this->getSession()->getPage()->findAll('xpath', "//input[@id='{$selector}']");
$elements = $this->getSession()->getPage()->findAll('xpath', "//*[@id='{$selector}']");
if (empty($elements)) {
throw new \Exception(sprintf('The input element "%s" was not found in the page', $selector));
}
......@@ -1500,13 +1719,13 @@ JS;
*
* Varbase Context #varbase.
*
* Example #1: When I scrolldown
* Example #2: And I scrolldown.
* Example #1: When I scroll down
* Example #2: And I scroll down.
*
* @When I scrolldown
* @When /^(?:|I )scroll down$/
*/
public function iScrolldown() {
$this->getSession()->executeScript("javascript:window.scrollBy(200,350)");
$this->getSession()->executeScript("javascript:window.scrollBy(0,350)");
}
/**
......@@ -1514,14 +1733,73 @@ JS;
*
* Varbase Context #varbase.
*
* Example #1: When I scrollup.
* Example #1: When I scroll up.
*
* @When I scrollup
* @When /^(?:|I )scroll up$/
*/
public function iScrollup() {
$this->getSession()->executeScript("javascript:window.scrollBy(0,-350)");
}
/**
* Scroll down in the current status of the page and pass a value.
*
* Varbase Context #varbase.
*
* Example #1: When I scroll down 800
* Example #2: And I scroll down 2000
*
* @When /^(?:|I )scroll down (?P<value>\d+)$/
*/
public function iScrolldownWithValue($value) {
$this->getSession()->executeScript("javascript:window.scrollBy(0," . $value . ")");
}
/**
* Scroll up in the current status of the page and pass a value.
*
* Varbase Context #varbase.
*
* Example #1: When I scroll up 1000
*
* @When /^(?:|I ) scroll up (?P<value>\d+)$/
*/
public function iScrollupWithValue($value) {
$this->getSession()->executeScript("javascript:window.scrollBy(0,-" . $value . ")");
}
/**
* Scroll to top
*
* Varbase Context #varbase.
*
* Example #1: When I scroll to top
* Example #2: When I scroll to the top
* Example #3: When I scroll to the top of the page
* Example #4: And scroll to top
*
* @When /^(?:|I )scroll to (?:|the )top(?:| of the page)$/
*/
public function iScrollToTop() {
$this->getSession()->executeScript("javascript:window.scrollBy(0,0)");
}
/**
* Scroll to bottom
*
* Varbase Context #varbase.
*
* Example #1: When I scroll to bottom
* Example #2: And I scroll to the bottom
* Example #3: When I scroll to the bottom of the page
* Example #4: And scroll to bottom
*
* @When /^(?:|I )scroll to (?:|the )bottom(?:| of the page)$/
*/
public function iScrollToBottom() {
$this->getSession()->executeScript("javascript:window.scrollBy(0,document.body.scrollHeight)");
}
/**
* Check if the Image media browser opened.
*
......@@ -1805,4 +2083,4 @@ JS;
}
}
}
\ No newline at end of file
}
......@@ -6,19 +6,19 @@ So that I will need a site admin or super admin to add me to the website
Background:
Given I am an anonymous user
@local @development @staging @production
@javascript @local @development @staging @production
Scenario: Check that create new account options does not appear for anonymous users
When I go to "/user"
And I wait
Then I should not see "Create new account"
@local @development @staging @production
@javascript @local @development @staging @production
Scenario: Check that only admin can create an account
When I go to "/user/register"
And I wait
Then I should see "Access denied"
@local @development @staging @production
@javascript @local @development @staging @production
Scenario: Verify that anonymous users cannot access admin pages
When I go to "/admin"
And I wait
......
......@@ -3,7 +3,7 @@ As a logged in user with the User ID number 1
I want to be able to see the list of User Roles
So that they must be (Editor, Site Admin, Content Admin, Super Admin)
@local @development @staging @production
@javascript @local @development @staging @production
Scenario: Check that all default list of roles are present
Given I am a logged in user with the "webmaster" user
When I go to "/admin/people/roles"
......
......@@ -5,7 +5,7 @@ So that can use different type of rich text editors.
@javascript @local @development @staging @production
Scenario: Check if Site Admin user can change the text format for the body of Basic page
Given I am a logged in user with the "test_site_admin"
Given I am a logged in user with the "Site admin"
When I go to "/node/add/page"
And I wait
Then I should see "Create Basic page"
......@@ -27,7 +27,7 @@ So that can use different type of rich text editors.
@javascript @local @development @staging @production
Scenario: Check if Super Admin user can change the text format for the body of Basic page
Given I am a logged in user with the "test_super_admin"
Given I am a logged in user with the "Super admin"
When I go to "/node/add/page"
And I wait
Then I should see "Create Basic page"
......
......@@ -5,7 +5,7 @@ So that can be sure that the website is using the English language as one of the
@javascript @local @development @staging @production
Scenario: Check if we can Create Basic page with English for the language of the content
Given I am a logged in user with the "test_content_admin" user
Given I am a logged in user with the "Content admin" user
And I go to "/node/add/page"
And I wait
When I select "English" from "Language"
......@@ -20,7 +20,7 @@ So that can be sure that the website is using the English language as one of the
@javascript @local @development @staging @production
Scenario: Check if we can Create Landing page with English for the language of the content
Given I am a logged in user with the "test_content_admin" user
Given I am a logged in user with the "Content admin" user
And I go to "/node/add/landing_page"
And I wait
When I select "English" from "Language"
......@@ -34,7 +34,7 @@ So that can be sure that the website is using the English language as one of the
@javascript @local @development @staging @production
Scenario: Check if we can Create Basic page with English for the language of the content
Given I am a logged in user with the "test_site_admin" user
Given I am a logged in user with the "Site admin" user
And I go to "/node/add/page"
And I wait
When I select "English" from "Language"
......@@ -49,7 +49,7 @@ So that can be sure that the website is using the English language as one of the
@javascript @local @development @staging @production
Scenario: Check if we can Create Landing page with English for the language of the content
Given I am a logged in user with the "test_site_admin" user
Given I am a logged in user with the "Site admin" user
And I go to "/node/add/landing_page"
And I wait
When I select "English" from "Language"
......