Skip to content

Commit 1cb1548

Browse files
committed
B2B-2404: Optimize Product Permissions in GraphQL resolver
1 parent 62d85bd commit 1cb1548

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function testBundleProductWithNotVisibleChildren()
206206
}
207207
$this->assertBundleBaseFields($bundleProduct, $response['products']['items'][0]);
208208

209-
$this->assertBundleProductOptions($bundleProduct, $response['products']['items'][0]);
209+
$this->assertBundleProductOptions($bundleProduct, $response['products']['items'][0], false);
210210
$this->assertNotEmpty(
211211
$response['products']['items'][0]['items'],
212212
"Precondition failed: 'items' must not be empty"
@@ -236,8 +236,9 @@ private function assertBundleBaseFields($product, $actualResponse)
236236
/**
237237
* @param ProductInterface $product
238238
* @param array $actualResponse
239+
* @param bool $isChildVisible
239240
*/
240-
private function assertBundleProductOptions($product, $actualResponse)
241+
private function assertBundleProductOptions($product, $actualResponse, $isChildVisible = true)
241242
{
242243
$this->assertNotEmpty(
243244
$actualResponse['items'],
@@ -273,19 +274,27 @@ private function assertBundleProductOptions($product, $actualResponse)
273274
'position' => $bundleProductLink->getPosition(),
274275
'is_default' => (bool)$bundleProductLink->getIsDefault(),
275276
'price_type' => self::KEY_PRICE_TYPE_FIXED,
276-
'can_change_quantity' => $bundleProductLink->getCanChangeQuantity(),
277-
'label' => $childProduct->getName()
277+
'can_change_quantity' => $bundleProductLink->getCanChangeQuantity()
278278
]
279279
);
280-
$this->assertResponseFields(
281-
$actualResponse['items'][0]['options'][0]['product'],
282-
[
283-
'id' => $childProduct->getId(),
284-
'name' => $childProduct->getName(),
285-
'type_id' => $childProduct->getTypeId(),
286-
'sku' => $bundleProductLink->getSku()
287-
]
280+
$this->assertEquals(
281+
$isChildVisible ? $childProduct->getName() : null,
282+
$actualResponse['items'][0]['options'][0]['label']
288283
);
284+
if ($isChildVisible) {
285+
$this->assertResponseFields(
286+
$actualResponse['items'][0]['options'][0]['product'],
287+
[
288+
'id' => $childProduct->getId(),
289+
'name' => $childProduct->getName(),
290+
'type_id' => $childProduct->getTypeId(),
291+
'sku' => $childProduct->getSku()
292+
]
293+
);
294+
} else {
295+
$this->assertNull($actualResponse['items'][0]['options'][0]['product']);
296+
}
297+
289298
}
290299

291300
/**

0 commit comments

Comments
 (0)