Skip to content

Commit

Permalink
Merge pull request #6645 from magento-tsg-csl3/2.4-develop-pr53
Browse files Browse the repository at this point in the history
[TSG-CSL3] For 2.4 (pr53)
  • Loading branch information
viktym authored Feb 23, 2021
2 parents 2e2af0a + 009b5b5 commit d3f202a
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertAdminProductFormAdvancedPricingAddTierPriceActionGroup" extends="AdminProductFormAdvancedPricingAddTierPriceActionGroup">
<annotations>
<description>Check tier price on Advanced Pricing dialog on the Admin Product creation/edit page.</description>
</annotations>
<remove keyForRemoval="selectWebsite"/>
<remove keyForRemoval="selectCustomerGroup"/>
<remove keyForRemoval="fillQuantity"/>
<remove keyForRemoval="selectPriceType"/>
<remove keyForRemoval="fillPriceAmount"/>
<remove keyForRemoval="waitCustomerGroupFilterAppears"/>
<remove keyForRemoval="selectCustomerGroupValue"/>
<executeJS function="return window.getComputedStyle(document.querySelector(&quot;{$priceAmountSelector}&quot;)).getPropertyValue('min-width')" after="waitPriceAmountFieldAppers" stepKey="priceMinWidth"/>
<assertEquals after="priceMinWidth" stepKey="assertWebsiteAmounts">
<actualResult type="string">$priceMinWidth</actualResult>
<expectedResult type="string">60px</expectedResult>
</assertEquals>
<click selector="{{AdminProductFormAdvancedPricingSection.customerGroupPriceDeleteButton}}" after="assertWebsiteAmounts" stepKey="clickCustomerGroupPriceDeleteButton"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<actionGroup ref="ResetProductGridToDefaultViewActionGroup" stepKey="resetGridToDefaultKeywordSearch"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
</after>

<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="loginAsAdmin"/>
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
<argument name="product" value="$$createSimpleProduct$$"/>
Expand All @@ -41,6 +41,10 @@
<argument name="product" value="$$createSimpleProduct$$"/>
</actionGroup>

<actionGroup ref="AdminProductFormOpenAdvancedPricingDialogActionGroup" stepKey="clickOnAdvancedPricingButtonForAssert"/>
<actionGroup ref="AssertAdminProductFormAdvancedPricingAddTierPriceActionGroup" stepKey="assertProductTierPriceInput"/>
<actionGroup ref="AdminProductFormDoneAdvancedPricingDialogActionGroup" stepKey="doneButtonAfterAssert"/>

<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="scrollToTopOfPage"/>
<actionGroup ref="AdminProductFormOpenAdvancedPricingDialogActionGroup" stepKey="clickOnAdvancedPricingButton"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCustomerGroupPriceAddButton"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
<element name="viewDropdown" type="button" selector=".admin__data-grid-action-bookmarks button.admin__action-dropdown"/>
<element name="viewBookmark" type="button" selector="//div[contains(@class, 'admin__data-grid-action-bookmarks')]/ul/li/div/a[text() = '{{label}}']" parameterized="true" timeout="30"/>
<element name="countryOptions" type="button" selector=".admin__data-grid-filters select[name=billing_country_id] option"/>
<element name="websiteOptions" type="button" selector=".admin__data-grid-filters select[name=website_id] option"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
</column>
<column name="website_id" class="Magento\Customer\Ui\Component\Listing\Column\Websites" component="Magento_Ui/js/grid/columns/select" sortOrder="110">
<settings>
<options class="Magento\Store\Model\ResourceModel\Website\Collection"/>
<filter>select</filter>
<editor>
<editorType>select</editorType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,25 @@ public function validate(HttpRequestInterface $request) : void
/** @var Http $request */
if (false === $request->isPost()) {
$query = $request->getParam('query', '');
$operationType = null;
$queryAst = \GraphQL\Language\Parser::parse(new \GraphQL\Language\Source($query ?: '', 'GraphQL'));
\GraphQL\Language\Visitor::visit(
$queryAst,
[
'leave' => [
NodeKind::OPERATION_DEFINITION => function (Node $node) use (&$operationType) {
$operationType = $node->operation;
}
if (!empty($query)) {
$operationType = null;
$queryAst = \GraphQL\Language\Parser::parse(new \GraphQL\Language\Source($query ?: '', 'GraphQL'));
\GraphQL\Language\Visitor::visit(
$queryAst,
[
'leave' => [
NodeKind::OPERATION_DEFINITION => function (Node $node) use (&$operationType) {
$operationType = $node->operation;
}
]
]
]
);

if (strtolower($operationType) === 'mutation') {
throw new GraphQlInputException(
new \Magento\Framework\Phrase('Mutation requests allowed only for POST requests')
);

if (strtolower($operationType) === 'mutation') {
throw new GraphQlInputException(
new \Magento\Framework\Phrase('Mutation requests allowed only for POST requests')
);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\GraphQl\Test\Unit\Controller\HttpRequestValidator;

use Magento\Framework\App\HttpRequestInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\GraphQl\Controller\HttpRequestValidator\HttpVerbValidator;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* Test HttpVerbValidator
*/
class HttpVerbValidatorTest extends TestCase
{
/**
* @var HttpVerbValidator|MockObject
*/
private $httpVerbValidator;

/**
* @var HttpRequestInterface|MockObject
*/
private $requestMock;

/**
* @inheritDoc
*/
protected function setup(): void
{
$objectManager = new ObjectManager($this);
$this->requestMock = $this->getMockBuilder(HttpRequestInterface::class)
->disableOriginalConstructor()
->onlyMethods(
[
'isPost',
]
)->addMethods(
[
'getParam',
]
)
->getMockForAbstractClass();

$this->httpVerbValidator = $objectManager->getObject(
HttpVerbValidator::class
);
}

/**
* Test for validate method
*
* @param string $query
* @param bool $needException
* @dataProvider validateDataProvider
*/
public function testValidate(string $query, bool $needException): void
{
$this->requestMock
->expects($this->once())
->method('isPost')
->willReturn(false);

$this->requestMock
->method('getParam')
->with('query', '')
->willReturn($query);

if ($needException) {
$this->expectExceptionMessage('Syntax Error: Unexpected <EOF>');
}

$this->httpVerbValidator->validate($this->requestMock);
}

/**
* @return array
*/
public function validateDataProvider(): array
{
return [
[
'query' => '',
'needException' => false,
],
[
'query' => ' ',
'needException' => true
],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@
.admin__field + .admin__field {
margin-left: @indent__s;
margin-top: 0;
.admin__field-control {
.admin__control-addon {
.admin__control-text {
min-width: 6rem;
}
}
}
}
}
}
Expand Down

0 comments on commit d3f202a

Please sign in to comment.