Skip to content

Commit 3cdf303

Browse files
author
Oleksandr Iegorov
committed
MC-43176: GraphQL returns the price ranges of a simple product on another store
1 parent 26597cf commit 3cdf303

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogGraphQl/PriceRangeTest.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\TestFramework\Helper\Bootstrap;
1212
use Magento\TestFramework\ObjectManager;
1313
use Magento\TestFramework\TestCase\GraphQlAbstract;
14+
use Magento\Tests\NamingConvention\true\string;
1415

1516
/**
1617
* Test class to verify catalog price rule is applied for
@@ -278,6 +279,83 @@ private function getProductSearchQuery(string $productSku): string
278279
}
279280
}
280281
}
282+
QUERY;
283+
}
284+
285+
/**
286+
* @magentoApiDataFixture Magento/Catalog/_files/product_configurable_in_multiple_websites_with_special_price.php
287+
*/
288+
public function testMinimalPriceForConfigurableProductWithSpecialPrice() : void
289+
{
290+
$query = $this->getProductsBySkuQuery();
291+
$response = $this->graphQlQuery(
292+
$query,
293+
[],
294+
'',
295+
$this->getCustomerAuthenticationHeader->execute('customer@example.com', 'password')
296+
);
297+
$this->assertNotEmpty($response['products']);
298+
$priceRange = $response['products']['items'][0]['price_range'];
299+
$this->assertEquals(10, $priceRange['minimum_price']['regular_price']['value']);
300+
$this->assertEquals(10, $priceRange['minimum_price']['final_price']['value']);
301+
$this->assertEquals(10, $priceRange['maximum_price']['regular_price']['value']);
302+
$this->assertEquals(10, $priceRange['maximum_price']['final_price']['value']);
303+
}
304+
305+
/**
306+
* Get a query which user filter for product sku and returns price_range
307+
*
308+
* @param string $productSku
309+
* @return string
310+
*/
311+
private function getProductsBySkuQuery() : string
312+
{
313+
return <<<QUERY
314+
query getProductsBySku {
315+
products(filter: { sku: { eq: "configurable" } }) {
316+
items {
317+
sku
318+
name
319+
price_range {
320+
minimum_price {
321+
regular_price {
322+
value
323+
currency
324+
}
325+
discount {
326+
amount_off
327+
percent_off
328+
}
329+
final_price {
330+
value
331+
currency
332+
}
333+
}
334+
maximum_price {
335+
regular_price {
336+
value
337+
currency
338+
}
339+
discount {
340+
amount_off
341+
percent_off
342+
}
343+
final_price {
344+
value
345+
currency
346+
}
347+
}
348+
}
349+
... on ConfigurableProduct {
350+
variants {
351+
product {
352+
sku
353+
}
354+
}
355+
}
356+
}
357+
}
358+
}
281359
QUERY;
282360
}
283361
}

0 commit comments

Comments
 (0)