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

IBX-8708: Updated doc section in ibexa/behat repository #122

Merged
merged 5 commits into from
Sep 28, 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
16 changes: 8 additions & 8 deletions doc/extending.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Extending BehatBundle
# Extending Behat

There are two extension points:
- ## Support for custom Field Types
If you want BehatBundle to support your custom Field Type when generating Content items you need to implement `EzSystems\Behat\API\ContentData\FieldTypeData\FieldTypeDataProviderInterface` and tag the service with the `ezplatform.behat.fieldtype_data_provider` tag.
If you want ibexa/behat to support your custom Field Type when generating Content items you need to implement `Ibexa\Behat\API\ContentData\FieldTypeData\FieldTypeDataProviderInterface` and tag the service with the `ibexa.behat.fieldtype_data_provider` tag.

Example service definition:
```
App\CustomFieldTypeProvider:
tags: ['ezplatform.behat.fieldtype_data_provider']
tags: ['ibexa.behat.fieldtype_data_provider']
```
Example class implementing the interface:
```
<?php

namespace App;

use EzSystems\Behat\API\ContentData\FieldTypeData\AbstractFieldTypeDataProvider;
use Ibexa\Behat\API\ContentData\FieldTypeData\AbstractFieldTypeDataProvider;

class CustomFieldTypeProvider extends AbstractFieldTypeDataProvider
{
Expand All @@ -34,21 +34,21 @@ class CustomFieldTypeProvider extends AbstractFieldTypeDataProvider
```

- ## Support for custom Limitations
If you want to create Roles with permissions containing custom Limitations, you need to implement `EzSystems\Behat\API\Context\LimitationParser\LimitationParserInterface` and tag your service with the `ezplatform.behat.limitation_parser` tag. This will allow you to parse values passed in Gherkin tables into Limitation objects.
If you want to create Roles with permissions containing custom Limitations, you need to implement `Ibexa\Behat\API\Context\LimitationParser\LimitationParserInterface` and tag your service with the `ibexa.behat.limitation_parser` tag. This will allow you to parse values passed in Gherkin tables into Limitation objects.

Example service definition:
```
App\CustomLimitationParser:
tags: ['ezplatform.behat.limitation_parser']
tags: ['ibexa.behat.limitation_parser']
```
Example class implementing the interface:
```
<?php

namespace App;

use eZ\Publish\API\Repository\Values\User\Limitation;
use EzSystems\Behat\API\Context\LimitationParser\LimitationParserInterface
use Ibexa\Contracts\Core\Repository\Values\User\Limitation;
use Ibexa\Behat\API\Context\LimitationParser\LimitationParserInterface
use CustomLimitation;

class CustomLimitationParser implements LimitationParserInterface
Expand Down
14 changes: 7 additions & 7 deletions doc/features.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# BehatBundle features
# Behat features

## Example usages

### API examples
See [BehatBundle examples](https://github.com/ibexa/behat/tree/master/features/examples) to see how to use Behat sentences to:
See [Behat examples](https://github.com/ibexa/behat/tree/master/features/examples) to see how to use Behat sentences to:
- create Languages, Content items, Content Types
- create Users with complex permissions
- create given YAML configuration

### Logging into the repository

Use the [TestContext](../src/lib/API/Context/TestContext.php) to log in to the Repository and perform API calls as given user. You can tag your scenario with `@admin` to be automatically logged in as admin user before the scenario starts.
Use the [TestContext](../src/lib/API/Context/TestContext.php) to log in to the Repository and perform API calls as given user.

### Browser examples

Look at [AdminUI feature files](https://github.com/ezsystems/ezplatform-admin-ui/tree/master/features/standard) to see example browser tests for AdminUI. If you want to reuse these Steps in your code in addition to the Context that defines them you also need to include:
Look at [AdminUI feature files](https://github.com/ibexa/admin-ui/tree/4.6/features/standard) to see example browser tests for AdminUI. If you want to reuse these Steps in your code in addition to the Context that defines them you also need to include:
- `Ibexa\Behat\Browser\Context\Hooks`
- `Ibexa\Behat\Browser\Context\BrowserContext`

#### Improved drag and drop

Selenium does not support drag and drop interactions between iframes. To achieve that you can use the `UtilityContext::moveWithHover` method (which also supports hover simulation between the actions). See the [drag-mock documentation](https://github.com/andywer/drag-mock#browser) (the library we use behind the scenes) for more information.

Before you start using that you need to inject the [drag-mock script](../Resources/public/js/scripts/drag-mock.js) into your templates: one way of doing this is described in [Webpack Encore configuration doc](https://doc.ezplatform.com/en/latest/guide/bundles/#configuration-from-a-bundle). For an example see [ez.config.manager.js](../src/bundle/Resources/encore/ez.config.manager.js).
Before you start using that you need to inject the [drag-mock script](../src/bundle/Resources/public/js/scripts/drag-mock.js) into your templates: one way of doing this is described in [Webpack Encore configuration doc](https://doc.ibexa.co/en/4.6/administration/back_office/back_office_elements/importing_assets_from_bundle/#configuration-from-a-bundle). For an example see [ez.config.manager.js](../src/bundle/Resources/encore/ez.config.manager.js).

## BehatBundle extension
## Behat extension

### SiteAccess awareness

Expand All @@ -36,4 +36,4 @@ Use the `Ibexa\Behat\Browser\Context\DebuggingContext` Context class to access b

## Default testing configuration

BehatBundle might override some settings with values that are needed for testing. If you want to disable this behaviour you should set the `ibexa.testing.override_configuration` parameter to `false`.
Behat might override some settings with values that are needed for testing. If you want to disable this behaviour you should set the `ibexa.behat.override_configuration` parameter to `false`.
8 changes: 4 additions & 4 deletions doc/getting_started.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Getting started

eZ Platform BehatBundle is a bundle created to make development of [Behat](https://behat.org/en/latest/) tests for eZ Platform easier and quicker. If you're new to Behat you can get familiar with it by browsing [Behat's documentation](https://docs.behat.org/en/latest/guides.html).
Ibexa/behat repository was created to make development of [Behat](https://behat.org/en/latest/) tests for Ibexa DXP easier and quicker. If you're new to Behat you can get familiar with it by browsing [Behat's documentation](https://docs.behat.org/en/latest/guides.html).

# How can I use BehatBundle in my project?
# How can I use Behat in my project?

This bundle has higher testing levels (system testing and acceptance testing) in mind. You can use it to:
This repository has higher testing levels (system testing and acceptance testing) in mind. You can use it to:
* put your system under test in the desired state
- create necessary Content Types, Content items, Users etc.
- create required YAML configuration using code
Expand All @@ -15,7 +15,7 @@ This bundle has higher testing levels (system testing and acceptance testing) in

# More reading

eZ Platform uses following libraries for Behat Development:
Ibexa uses following libraries for Behat Development:
- [Behat](https://behat.org/en/latest/) as a BDD framework for PHP
- [Mink](http://mink.behat.org/en/latest/) as browser driver abstraction
- [Faker](https://github.com/fzaninotto/Faker) for random data generation
Expand Down
30 changes: 14 additions & 16 deletions doc/running_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,42 @@

## Configuration

In order to use BehatBundle you need to use `behat` Symfony environment (which is defined in eZ Platform by default). It is also recommended to run in enabled debug mode, which gives you more detailed browser screenshots in case of failure.
In order to use ibexa/behat you need to use `behat` Symfony environment (which is defined in Ibexa by default). It is also recommended to run in enabled debug mode, which gives you more detailed browser screenshots in case of failure.

The standard behat configuration file is [behat.yml.dist](https://github.com/ezsystems/ezplatform/blob/2.5/behat.yml.dist), located in eZ Platform's main directory. There you can:
The standard behat configuration file is [behat_ibexa_oss.yaml](https://github.com/ibexa/behat/blob/4.6/behat_ibexa_oss.yaml), located in ibexa/behat directory. There you can:
- in the `Behat\MinkExtension` section:
- set the URL of your website for browser testing (`base_url` parameter)
- set driver configuration (for example `wd_host` for Selenium Server)
- see [MinkExtension documentation](https://github.com/Behat/MinkExtension/blob/master/doc/index.rst) for more information
- in the `Bex\Behat\ScreenshotExtension` section:
- set your Cloudinary account details (`cloud_name` and `preset` parameter) to specify where the screenshots are uploaded
- see [Cloudinary screenshot driver doc](https://github.com/ezsystems/behat-screenshot-image-driver-cloudinary/blob/master/README.md) for more details about the Cloudinary integration and [elvetemedve/behat-screenshot](https://github.com/elvetemedve/behat-screenshot) for other screenshots configuration options
- in the `Behat\Symfony2Extension` section:
- set Symfony environment (`env` parameter)
- enable Symfony debug (`debug` parameter)
- See [Symfony2Extension documentation](https://github.com/Behat/Symfony2Extension/blob/master/doc/index.rst) for more information

Behat profiles and suites are not defined in this file, but imported from files specified at the bottom.
Behat profiles and suites are not defined in this file, but imported from files specified at the top.

### Running browser tests

If you want to run browser tests you need to have Selenium Server runnning. One way of doing this is running our Docker stack, which has built-in support for it: see [eZ Platform Docker blueprints](https://github.com/ezsystems/ezplatform/blob/master/doc/docker/README.md#behat-and-selenium-use) documentation for more information.
If you want to run browser tests you need to have Selenium Server runnning. One way of doing this is running our Docker stack, which has built-in support for it: see [Ibexa Docker blueprints](https://github.com/ibexa/docker/blob/4.6/README.md#behat-and-selenium-use) documentation for more information.

Another way is to use the Selenium Server Docker container and setting it up manually. Look at [ezplatform's .env file](https://github.com/ezsystems/ezplatform/blob/master/.env#L17) for the currently used version.
Another way is to use the Selenium Server Docker container and setting it up manually. Look at [manifest.json file](https://github.com/ibexa/recipes-dev/blob/master/ibexa/docker/4.6/manifest.json#L23) for the currently used version.

It can be set up using:
`docker run -p 4444:4444 -p 5900:5900 --shm-size=1gb -d --name=containerName selenium/standalone-chrome-debug:3.141.59`
It can be set up using examples from [docker-selenium](https://github.com/SeleniumHQ/docker-selenium).

Example for Chrome would be:
`docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome:latest`

Where:
- 4444 is the port where Selenium Server will be accessible
- 5900 is the port where the VNC client is accessible (to preview running tests)
- shm-size is related to Chrome containers requiring more memory (see [Selenium container configuration](https://github.com/ezsystems/ezplatform/blob/master/doc/docker/selenium.yml#L16))
- shm-size is related to Chrome containers requiring more memory (see [Selenium container configuration](https://github.com/ibexa/docker/blob/4.6/docker/selenium.yml#L19))

After the container is set up correctly you need to adjust the configuration of `selenium2` driver in `behat.yml.dist` file
After the container is set up correctly you need to adjust the configuration of `selenium2` driver in `behat_ibexa_oss.yaml` file

## Running tests

### Running standard Behat tests

BehatBundle comes with a wrapper for the standard Behat runner: [ibexabehat](../bin/ibexabehat.sh) to make running tests in parallel easier.
Ibexa/behat comes with a wrapper for the standard Behat runner: [ibexabehat](https://github.com/ibexa/behat/blob/4.6/bin/ibexabehat) to make running tests in parallel easier.

Use:
```
Expand All @@ -57,10 +55,10 @@ Running Behat feature files in parallel (on the available number of CPUs) is the

## Existing test profiles and suites

By convention profiles and suites are defined in the `behat_suites.yml` file in each bundle, if they exist. See [BehatBundle suites](../behat_suites.yml) and [AdminUI suites](https://github.com/ezsystems/ezplatform-admin-ui/blob/master/behat_suites.yml) for examples.
By convention profiles and suites are defined in the `behat_suites.yml` file in each bundle, if they exist. See [Behat suites](../behat_suites.yml) and [AdminUI suites](https://github.com/ibexa/admin-ui/blob/4.6/behat_suites.yml) for examples.

In order to run them, execute:
- `bin/ibexabehat --profile=behat --suite=examples` (BehatBundle usage examples)
- `bin/ibexabehat --profile=behat --suite=examples` (behat usage examples)
- `bin/ibexabehat --profile=adminui --suite=adminui` (all AdminUI tests)

## Previewing browser tests
Expand Down
Loading