Merge branch '1.2' into 1.3

* 1.2:
  fix dashboard context
  extends friends of behat page
  remove double 'When'
  some changes after code review
  Accessing a product which does not exist
  redirecting on login after being logout from administration dashboard
  improve behat sentences and fix 403 title to be more explicit
  add error page interface
  [Behat] viewing errors
This commit is contained in:
Łukasz Chruściel 2018-11-23 11:12:14 +01:00
commit 46f2f811f2
No known key found for this signature in database
GPG key ID: 428B9D810DB2ACDF
14 changed files with 168 additions and 3 deletions

View file

@ -0,0 +1 @@
{% include '@SyliusShop/error403.html.twig' %}

View file

@ -0,0 +1,14 @@
@administrator_login
Feature: Redirecting on login page
In order to access on my admin dashboard
As a logged out Administrator
I need to be redirected on login page
Background:
Given the store operates on a single channel in "United States"
And I have been logged out from administration
@ui
Scenario: Redirecting on login page after being logout
When I try to open administration dashboard
Then I should be on login page

View file

@ -0,0 +1,13 @@
@viewing_products
Feature: Accessing a product which does not exist
In order to have a good navigation
As a visitor
I want to be able to be informed that a product does not exits
Background:
Given the store operates on a single channel in "United States"
@ui
Scenario: Accessing a product which does not exist
When I try to reach unexistent product
Then I should be informed that the product does not exist

View file

@ -71,4 +71,14 @@ final class AdminSecurityContext implements Context
$this->sharedStorage->set('administrator', $user);
}
/**
* @Given I have been logged out from administration
*/
public function iHaveBeenLoggedOutFromAdministration()
{
$this->securityService->logOut();
$this->sharedStorage->set('administrator', null);
}
}

View file

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Ui\Admin;
use Behat\Behat\Context\Context;
use FriendsOfBehat\PageObjectExtension\Page\UnexpectedPageException;
use Sylius\Behat\Page\Admin\DashboardPageInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Webmozart\Assert\Assert;
@ -29,11 +30,14 @@ final class DashboardContext implements Context
}
/**
* @When I open administration dashboard
* @When I (try to )open administration dashboard
*/
public function iOpenAdministrationDashboard()
{
$this->dashboardPage->open();
try {
$this->dashboardPage->open();
} catch (UnexpectedPageException $e) {
}
}
/**

View file

@ -82,6 +82,14 @@ final class LoginContext implements Context
Assert::false($this->dashboardPage->isOpen());
}
/**
* @Given I should be on login page
*/
public function iShouldBeOnLoginPage()
{
Assert::true($this->loginPage->isOpen());
}
/**
* @Then I should be notified about bad credentials
*/

View file

@ -15,6 +15,7 @@ namespace Sylius\Behat\Context\Ui\Shop;
use Behat\Behat\Context\Context;
use Behat\Mink\Element\NodeElement;
use Sylius\Behat\Page\ErrorPageInterface;
use Sylius\Behat\Page\Shop\Product\IndexPageInterface;
use Sylius\Behat\Page\Shop\Product\ShowPageInterface;
use Sylius\Behat\Page\Shop\ProductReview\IndexPageInterface as ProductReviewIndexPageInterface;
@ -33,14 +34,19 @@ final class ProductContext implements Context
/** @var ProductReviewIndexPageInterface */
private $productReviewsIndexPage;
/** @var ErrorPageInterface */
private $errorPage;
public function __construct(
ShowPageInterface $showPage,
IndexPageInterface $indexPage,
ProductReviewIndexPageInterface $productReviewsIndexPage
ProductReviewIndexPageInterface $productReviewsIndexPage,
ErrorPageInterface $errorPage
) {
$this->showPage = $showPage;
$this->indexPage = $indexPage;
$this->productReviewsIndexPage = $productReviewsIndexPage;
$this->errorPage = $errorPage;
}
/**
@ -85,6 +91,17 @@ final class ProductContext implements Context
]);
}
/**
* @When I try to reach unexistent product
*/
public function iTryToReachUnexistentProductPage($localeCode = 'en_US')
{
$this->showPage->tryToOpen([
'slug' => 'unexisten_product',
'_locale' => $localeCode,
]);
}
/**
* @Then /^I should not be able to view (this product) in the ("([^"]+)" locale)$/
*/
@ -500,6 +517,14 @@ final class ProductContext implements Context
Assert::true($this->indexPage->hasProductsInOrder($productNames));
}
/**
* @Then I should be informed that the product does not exist
*/
public function iShouldBeInformedThatTheProductDoesNotExist()
{
Assert::eq($this->errorPage->getTitle(), 'The "product" has not been found');
}
/**
* @param string $productName
* @param string $productAssociationName

View file

@ -0,0 +1,46 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Behat\Page;
use FriendsOfBehat\PageObjectExtension\Page\Page;
class ErrorPage extends Page implements ErrorPageInterface
{
/**
* {@inheritdoc}
*/
protected function getUrl(array $urlParameters = []): string
{
// This page does not have any url
return '';
}
/**
* {@inheritdoc}
*/
public function getTitle(): string
{
return $this->getElement('title')->getText();
}
/**
* {@inheritdoc}
*/
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
'title' => 'h1.exception-message',
]);
}
}

View file

@ -0,0 +1,24 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Behat\Page;
interface ErrorPageInterface
{
/**
* @return string
*
* @throws \Behat\Mink\Exception\ElementNotFoundException
*/
public function getTitle(): string;
}

View file

@ -445,6 +445,7 @@
<argument type="service" id="sylius.behat.page.shop.product.show" />
<argument type="service" id="sylius.behat.page.shop.product.index" />
<argument type="service" id="sylius.behat.page.shop.product_reviews.index" />
<argument type="service" id="sylius.behat.page.error" />
<tag name="fob.context_service" />
</service>

View file

@ -17,6 +17,10 @@
<import resource="pages/shop.xml" />
</imports>
<parameters>
<parameter key="sylius.behat.page.error.class">Sylius\Behat\Page\ErrorPage</parameter>
</parameters>
<services>
<defaults public="true" />
@ -28,6 +32,8 @@
<argument type="service" id="__symfony_shared__.router" />
</service>
<service id="sylius.behat.page.error" class="%sylius.behat.page.error.class%" parent="sylius.behat.page" public="false" />
<service id="sylius.behat.page.external.paypal_checkout_express" class="Sylius\Behat\Page\External\PaypalExpressCheckoutPage" parent="sylius.behat.page" public="false" >
<argument type="service" id="__symfony__.sylius.repository.payment_security_token" />
</service>

View file

@ -10,9 +10,11 @@ default:
- sylius.behat.context.transform.user
- sylius.behat.context.setup.channel
- sylius.behat.context.setup.admin_security
- sylius.behat.context.setup.admin_user
- sylius.behat.context.setup.user
- sylius.behat.context.ui.admin.dashboard
- sylius.behat.context.ui.admin.login
filters:
tags: "@administrator_login && @ui"

View file

@ -0,0 +1,10 @@
{% extends '@SyliusShop/layout.html.twig' %}
{% block content %}
<h2 class="ui center aligned icon header">
<img src="{{ asset('assets/shop/img/logo.png') }}" alt="Sylius logo" class="ui small image" />
<br/><br/>
{{ 'sylius.ui.the_page_you_are_looking_for_is_forbidden'|trans }}
</h2>
{% endblock %}

View file

@ -785,6 +785,7 @@ sylius:
theme: 'Theme'
the_instructions_below_will_be_displayed_to_the_customer: 'The instructions below will be displayed to the customer'
the_page_you_are_looking_for_does_not_exist: 'The page you are looking for does not exist.'
the_page_you_are_looking_for_is_forbidden: 'The page you are looking for is forbidden.'
there_are_no_attributes_configured: 'There are no attributes configured'
there_are_no_blocks_to_display: 'There are no blocks to display'
there_are_no_channels_configured: 'There are no channels configured'