Skip to content

Commit d8b7fe2

Browse files
committed
B2B-2469: Improve category children loading
- codestyle fix:
1 parent 0679008 commit d8b7fe2

File tree

1 file changed

+17
-65
lines changed

1 file changed

+17
-65
lines changed

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

Lines changed: 17 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -963,16 +963,19 @@ public function testQueryParentCategoriesProductCount()
963963
}
964964

965965
/**
966-
* @magentoApiDataFixture Magento/Catalog/_files/categories.php
966+
* Get categoryList query for page.
967+
*
968+
* @param int $page
969+
* @return string
967970
*/
968-
public function testCategoryListPaginationLimitsNotAppliedToChildren()
971+
private function getQueryForPage(int $page)
969972
{
970-
$query = <<<QUERY
973+
return <<<QUERY
971974
{
972975
categoryList(
973976
filters: {parent_id: {in: ["2"]}}
974977
pageSize: 1
975-
currentPage: 1
978+
currentPage: {$page}
976979
){
977980
id
978981
name
@@ -996,7 +999,14 @@ public function testCategoryListPaginationLimitsNotAppliedToChildren()
996999
}
9971000
}
9981001
QUERY;
999-
$response = $this->graphQlQuery($query);
1002+
}
1003+
1004+
/**
1005+
* @magentoApiDataFixture Magento/Catalog/_files/categories.php
1006+
*/
1007+
public function testCategoryListPaginationLimitsNotAppliedToChildren()
1008+
{
1009+
$response = $this->graphQlQuery($this->getQueryForPage(1));
10001010
$this->assertArrayNotHasKey('errors', $response);
10011011
$this->assertArrayHasKey('categoryList', $response);
10021012
$baseCategory = $response['categoryList'][0];
@@ -1006,72 +1016,14 @@ public function testCategoryListPaginationLimitsNotAppliedToChildren()
10061016
$this->assertEquals('Category 1.2', $baseCategory['children'][1]['name']);
10071017
$this->assertEquals('Category 1.1.1', $baseCategory['children'][0]['children'][0]['name']);
10081018

1009-
$query2 = <<<QUERY
1010-
{
1011-
categoryList(
1012-
filters: {parent_id: {in: ["2"]}}
1013-
pageSize: 1
1014-
currentPage: 2
1015-
){
1016-
id
1017-
name
1018-
level
1019-
children{
1020-
name
1021-
level
1022-
children{
1023-
name
1024-
level
1025-
children{
1026-
name
1027-
level
1028-
children {
1029-
name
1030-
level
1031-
}
1032-
}
1033-
}
1034-
}
1035-
}
1036-
}
1037-
QUERY;
1038-
$response = $this->graphQlQuery($query2);
1019+
$response = $this->graphQlQuery($this->getQueryForPage(2));
10391020
$this->assertArrayNotHasKey('errors', $response);
10401021
$this->assertArrayHasKey('categoryList', $response);
10411022
$baseCategory = $response['categoryList'][0];
10421023
$this->assertEquals('Category 2', $baseCategory['name']);
10431024
$this->assertCount(0, $baseCategory['children']);
10441025

1045-
$query3 = <<<QUERY
1046-
{
1047-
categoryList(
1048-
filters: {parent_id: {in: ["2"]}}
1049-
pageSize: 1
1050-
currentPage: 3
1051-
){
1052-
id
1053-
name
1054-
level
1055-
children{
1056-
name
1057-
level
1058-
children{
1059-
name
1060-
level
1061-
children{
1062-
name
1063-
level
1064-
children {
1065-
name
1066-
level
1067-
}
1068-
}
1069-
}
1070-
}
1071-
}
1072-
}
1073-
QUERY;
1074-
$response = $this->graphQlQuery($query3);
1026+
$response = $this->graphQlQuery($this->getQueryForPage(3));
10751027
$this->assertArrayNotHasKey('errors', $response);
10761028
$this->assertArrayHasKey('categoryList', $response);
10771029
$baseCategory = $response['categoryList'][0];

0 commit comments

Comments
 (0)