-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
349 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,12 @@ | ||
Feature: | ||
As a Maintainer | ||
I want to check that main pages are accesible | ||
Feature: As a user | ||
I want to visit the following pages | ||
So that I can browse the site! | ||
|
||
@behat | ||
Scenario: Homepage is working | ||
Given I go to "/" | ||
Scenario Outline: 200 response | ||
When I go to "<url>" | ||
Then the response status code should be 200 | ||
|
||
@behat | ||
Scenario: Robots.txt is working | ||
Given I go to "/robots.txt" | ||
Then the response status code should be 200 | ||
|
||
# @behat | ||
# Scenario: Sitemap is working | ||
# Given I go to "/sitemap.xml" | ||
# Then the response status code should be 200 | ||
Examples: | ||
| url | | ||
| / | | ||
| /robots.txt | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
Feature: | ||
As a Maintainer | ||
I want to check that blocked pages are not accesible | ||
Feature: As a system | ||
I want to block the following pages | ||
So user cannot access where they should not! | ||
|
||
@behat | ||
Scenario: Admin area is not accesible | ||
Given I go to "/admin" | ||
Scenario Outline: 403 response | ||
When I go to "<url>" | ||
Then the response status code should be 403 | ||
|
||
@behat | ||
Scenario: User root profile page is not acccesible | ||
Given I go to "/user/1" | ||
Then the response status code should be 403 | ||
|
||
@behat | ||
Scenario: User register page is not acccesible | ||
Given I go to "/user/register" | ||
Then the response status code should be 403 | ||
Examples: | ||
| url | | ||
| /admin | | ||
| /user/1 | | ||
| /user/register | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
Feature: | ||
As a Maintainer | ||
I want to check that some urls return not found code | ||
Feature: As a system | ||
I want to make not-found the following pages | ||
So user cannot access where they should not! | ||
|
||
@behat | ||
Scenario: Homepage works | ||
Given I go to "/url-not-working" | ||
Then the response status code should be 404 | ||
Scenario Outline: 404 response | ||
When I go to "<url>" | ||
Then the response status code should be 404 | ||
|
||
Examples: | ||
| url | | ||
| /url-not-found | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
default: | ||
autoload: | ||
"": "%paths.base%/bootstrap/" | ||
formatters: | ||
pretty: | ||
verbose: false | ||
paths: false | ||
snippets: true | ||
junit: | ||
output_path: "%paths.base%/reports/behat/junit/" | ||
suites: | ||
default: | ||
paths: | ||
- "%paths.base%/features/" | ||
filters: | ||
tags: "~@exclude" | ||
contexts: | ||
- FeatureContext | ||
- NuvoleWeb\Drupal\DrupalExtension\Context\CKEditorContext | ||
- NuvoleWeb\Drupal\DrupalExtension\Context\PositionContext | ||
- NuvoleWeb\Drupal\DrupalExtension\Context\ResponsiveContext: | ||
devices: | ||
laptop: 1200x800 | ||
desktop: 2560x1440 | ||
mobile_portrait: 370x650 | ||
mobile_landscape: 650x370 | ||
tablet_portrait: 800x1024 | ||
tablet_landscape: 1024x768 | ||
- Drupal\DrupalExtension\Context\MinkContext | ||
- Drupal\DrupalExtension\Context\MessageContext | ||
- Drupal\DrupalExtension\Context\MarkupContext | ||
- Drupal\DrupalExtension\Context\DrushContext | ||
- Metadrop\Behat\Context\CacheContext | ||
- Metadrop\Behat\Context\ContentAuthoredContext | ||
- Metadrop\Behat\Context\CronContext | ||
- Metadrop\Behat\Context\DebugContext: | ||
parameters: | ||
"report_on_error": true | ||
"error_reporting_path": "/var/www/html/web/sites/default/files/behat/errors" | ||
"error_reporting_url": "http://example.ddev.site/sites/default/files/behat/errors" | ||
"screenshots_url": "http://example.ddev.site/sites/default/files/behat/screenshots" | ||
"screenshots_path": "/var/www/html/web/sites/default/files/behat/screenshots" | ||
"page_contents_path": "/var/www/html/web/sites/default/files/behat/pages" | ||
- Metadrop\Behat\Context\FileContext | ||
- Metadrop\Behat\Context\FormContext | ||
- Metadrop\Behat\Context\EntityContext | ||
- Metadrop\Behat\Context\LogsContext: | ||
parameters: | ||
write_report: true | ||
- Metadrop\Behat\Context\NodeAccessContext | ||
- Metadrop\Behat\Context\ParagraphsContext | ||
- Metadrop\Behat\Context\UIContext: | ||
parameters: | ||
scroll_offset: -100 | ||
- Metadrop\Behat\Context\UrlContext | ||
- Metadrop\Behat\Context\UsersContext | ||
- Metadrop\Behat\Context\WaitingContext | ||
- Metadrop\Behat\Context\MediaContext | ||
|
||
extensions: | ||
Drupal\MinkExtension: | ||
ajax_timeout: 5 | ||
browserkit_http: ~ | ||
browser_name: "chrome" | ||
base_url: "https://example.com" | ||
show_cmd: lynx %s | ||
files_path: "%paths.base%/tests/functional/behat/files" | ||
javascript_session: selenium2 | ||
selenium2: | ||
# wd_host: http://127.0.0.1:4444/wd/hub | ||
wd_host: http://hub:4444/wd/hub | ||
capabilities: | ||
browser: "chrome" | ||
extra_capabilities: | ||
chromeOptions: | ||
w3c: false | ||
args: | ||
- '--no-sandbox' | ||
- '--start-maximized' | ||
- '--disable-gpu' | ||
- '--disable-web-security' | ||
- '--DNS-prefetch-disable' | ||
- '--disable-translate' | ||
- '--ignore-certificate-errors' | ||
- '--test-type' | ||
- '--disable-extensions' | ||
- '--incognito' | ||
- '--disable-infobars' | ||
NuvoleWeb\Drupal\DrupalExtension: | ||
services: "/var/www/html/vendor/metadrop/behat-contexts/services.yml" | ||
blackbox: ~ | ||
api_driver: "drupal" | ||
drupal: | ||
# Change this to the absolute path to Drupal install. | ||
drupal_root: "/var/www/html/web" | ||
region_map: | ||
content: ".region-content" | ||
content bottom: ".region-content-bottom" | ||
footer: "footer" | ||
header: ".region-header" | ||
header extra: ".region-header-extra" | ||
highlighted: ".region-highlighted" | ||
sidebar responsive: ".region-sidebar-responsive" | ||
sidebar: ".region-sidebar-left" | ||
fixed: ".region-fixed" | ||
content top: ".region-content-top" | ||
table revision: ".node-revision-table" | ||
breadcrumb: ".breadcrumb" | ||
selectors: | ||
message_selector: ".messages" | ||
success_message_selector: ".messages--success" | ||
error_message_selector: ".messages--error" | ||
warning_message_selector: ".messages--warning" | ||
text: | ||
password_field: "edit-pass" | ||
username_field: "edit-name" | ||
log_in: "Log in" | ||
log_out: "Log out" | ||
node_submit_label: "Save and publish" | ||
Bex\Behat\StepTimeLoggerExtension: | ||
enabled_always: true | ||
output: [console, csv] |
147 changes: 147 additions & 0 deletions
147
aljibe-kickstart/tests/behat/pro/bootstrap/FeatureContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Behat Feature Context file. | ||
*/ | ||
|
||
use Drupal\DrupalExtension\Context\DrupalContext; | ||
use Behat\Behat\Context\SnippetAcceptingContext; | ||
use Behat\Behat\Hook\Scope\BeforeScenarioScope; | ||
use Drupal\user\Entity\Role; | ||
|
||
/** | ||
* Main project custom context. | ||
*/ | ||
class FeatureContext extends DrupalContext implements SnippetAcceptingContext { | ||
|
||
/** | ||
* Mink context. | ||
* | ||
* @var Drupal\DrupalExtension\Context\MinkContext | ||
*/ | ||
protected $minkContext; | ||
|
||
/** | ||
* Responsive context. | ||
* | ||
* @var \NuvoleWeb\Drupal\DrupalExtension\Context\ResponsiveContext | ||
*/ | ||
protected $responsiveContext; | ||
|
||
/** | ||
* Permissions to grant and revoke on before and after suite. | ||
* | ||
* @var array | ||
* | ||
* @code | ||
* $permissions = [ | ||
* "grant" => [ | ||
* "edit any article content" => [RoleInterface::ANONYMOUS_ID], | ||
* ], | ||
* "revoke" => [ | ||
* "access content" => [RoleInterface::ANONYMOUS_ID], | ||
* ], | ||
* ]; | ||
*/ | ||
static protected $permissions = []; | ||
|
||
/** | ||
* Sets User permissions. | ||
* | ||
* @BeforeSuite | ||
*/ | ||
public static function beforeSuiteUserPermissionsSet() { | ||
$roles = Role::loadMultiple(); | ||
foreach (self::$permissions as $type => $value) { | ||
foreach ($value as $permission => $rolesList) { | ||
foreach ($rolesList as $role) { | ||
$roles[$role]->{$type . 'Permission'}($permission); | ||
$roles[$role]->trustData()->save(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Restores User permissions. | ||
* | ||
* @AfterSuite | ||
*/ | ||
public static function afterUserPermissionsRestore() { | ||
$roles = Role::loadMultiple(); | ||
foreach (self::$permissions as $type => $value) { | ||
foreach ($value as $permission => $rolesList) { | ||
foreach ($rolesList as $role) { | ||
$utype = $type == 'grant' ? 'revoke' : 'grant'; | ||
$roles[$role]->{$utype . 'Permission'}($permission); | ||
$roles[$role]->trustData()->save(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Retrieve all required sub-contexts. | ||
* | ||
* @BeforeScenario | ||
*/ | ||
public function gatherContexts(BeforeScenarioScope $scope) { | ||
$environment = $scope->getEnvironment(); | ||
$this->minkContext = $environment->getContext('Drupal\DrupalExtension\Context\MinkContext'); | ||
$this->responsiveContext = $environment->getContext('NuvoleWeb\Drupal\DrupalExtension\Context\ResponsiveContext'); | ||
} | ||
|
||
/** | ||
* Gets context parameters if they are defined. | ||
* | ||
* @param mixed $parameters | ||
* Context parameter. | ||
*/ | ||
public function __construct($parameters = NULL) { | ||
$this->customParameters = !empty($parameters) ? $parameters : []; | ||
} | ||
|
||
/** | ||
* Sets EU Cookie Compliance: Accept. | ||
* | ||
* @BeforeScenario @cookies-accept | ||
*/ | ||
public function beforeSetCookiesAccept() { | ||
// The cookie is always sent for the current domain. Since you didn't visit | ||
// a page yet, the domain has not been set yet. At the moment there's no way | ||
// to choose a domain for a cookie with mink. | ||
// You need to make a request before sending a cookie. | ||
$this->visitPath('/'); | ||
$this->getSession()->setCookie("cookie-agreed", "2"); | ||
} | ||
|
||
/** | ||
* Sets EU Cookie Compliance: Reject. | ||
* | ||
* @BeforeScenario @cookies-reject | ||
*/ | ||
public function beforeSetCookiesReject() { | ||
$this->visitPath('/'); | ||
$this->getSession()->setCookie("cookie-agreed", "0"); | ||
} | ||
|
||
/** | ||
* Clear cache. | ||
* | ||
* @BeforeScenario @cache-clear | ||
*/ | ||
public function cacheClearTag() { | ||
$this->assertCacheClear(); | ||
} | ||
|
||
/** | ||
* Before scenario sets the viewport to desktop on javascript tests. | ||
* | ||
* @BeforeScenario @javascript | ||
*/ | ||
public function beforeSetViewportEditor() { | ||
$this->responsiveContext->assertDeviceScreenResize('desktop'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Feature: As a user | ||
I want to visit the following pages | ||
So that I can browse the site! | ||
|
||
Scenario Outline: 200 response | ||
When I go to "<url>" | ||
Then the response status code should be 200 | ||
|
||
Examples: | ||
| url | | ||
| / | | ||
| /robots.txt | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Feature: As a system | ||
I want to block the following pages | ||
So user cannot access where they should not! | ||
|
||
Scenario Outline: 403 response | ||
When I go to "<url>" | ||
Then the response status code should be 403 | ||
|
||
Examples: | ||
| url | | ||
| /admin | | ||
| /user/1 | | ||
| /user/register | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Feature: As a system | ||
I want to make not-found the following pages | ||
So user cannot access where they should not! | ||
|
||
Scenario Outline: 404 response | ||
When I go to "<url>" | ||
Then the response status code should be 404 | ||
|
||
Examples: | ||
| url | | ||
| /url-not-found | |
Oops, something went wrong.