Skip to content

Commit 9ad5a2c

Browse files
author
Valeriy Nayda
committed
GraphQL-175: Improve graphql product pagination
-- Update API-functional tests
1 parent 2e3d4b0 commit 9ad5a2c

File tree

1 file changed

+16
-32
lines changed

1 file changed

+16
-32
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchTest.php

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ public function testQueryProductsInCurrentPageSortedByPriceASC()
552552
* Verify the items in the second page is correct after sorting their name in ASC order
553553
*
554554
* @magentoApiDataFixture Magento/Catalog/_files/multiple_mixed_products_2.php
555-
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
556555
*/
557556
public function testFilterProductsInNextPageSortedByNameASC()
558557
{
@@ -562,58 +561,43 @@ public function testFilterProductsInNextPageSortedByNameASC()
562561
products(
563562
filter:
564563
{
565-
price:{gt: "5", lt: "50"}
566-
or:
567-
{
568-
sku:{eq:"simple1"}
569-
name:{like:"configurable%"}
570-
}
564+
sku:{in:["simple2", "simple1"]}
571565
}
572-
pageSize:4
566+
pageSize:1
573567
currentPage:2
574568
sort:
575569
{
576-
name:ASC
570+
name:ASC
577571
}
578572
)
579573
{
580574
items
581575
{
582576
sku
583-
price {
584-
minimalPrice {
585-
amount {
586-
value
587-
currency
588-
}
589-
}
590-
}
591577
name
592-
type_id
593-
... on PhysicalProductInterface {
594-
weight
595-
}
596-
attribute_set_id
597-
}
598-
total_count
599-
page_info
600-
{
578+
}
579+
total_count
580+
page_info
581+
{
601582
page_size
602-
}
583+
current_page
584+
}
603585
}
604586
}
605587
QUERY;
606588
/**
607589
* @var ProductRepositoryInterface $productRepository
608590
*/
609591
$productRepository = ObjectManager::getInstance()->get(ProductRepositoryInterface::class);
610-
$product = $productRepository->get('simple1');
611-
$filteredProducts = [$product];
592+
$product = $productRepository->get('simple2');
612593

613594
$response = $this->graphQlQuery($query);
614-
$this->assertEquals(1, $response['products']['total_count']);
615-
$this->assertProductItems($filteredProducts, $response);
616-
$this->assertEquals(4, $response['products']['page_info']['page_size']);
595+
$this->assertEquals(2, $response['products']['total_count']);
596+
$this->assertEquals(['page_size' => 1, 'current_page' => 2], $response['products']['page_info']);
597+
$this->assertEquals(
598+
[['sku' => $product->getSku(), 'name' => $product->getName()]],
599+
$response['products']['items']
600+
);
617601
}
618602

619603
/**

0 commit comments

Comments
 (0)