Skip to content

Commit 2e7f4e0

Browse files
committed
ACQE-8551: [Web API Automation] - AC-8424
- Add GraphQL automation test for null second street field handling.
1 parent 6e13440 commit 2e7f4e0

File tree

1 file changed

+112
-2
lines changed

1 file changed

+112
-2
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CheckoutEndToEndTest.php

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
6+
67
declare(strict_types=1);
78

89
namespace Magento\GraphQl\Quote\Guest;
@@ -86,6 +87,29 @@ public function testCheckoutWorkflow()
8687
$this->placeOrder($cartId);
8788
}
8889

90+
/**
91+
* Test checkout workflow with null second street in shipping address
92+
* Validates that null values in street array are properly filtered and don't cause errors
93+
*
94+
* @magentoConfigFixture default_store checkout/options/guest_checkout 1
95+
* @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php
96+
*/
97+
public function testCheckoutWithNullSecondStreetInShippingAddress()
98+
{
99+
$quantity = 1;
100+
$sku = $this->findProduct();
101+
$cartId = $this->createEmptyCart();
102+
$this->setGuestEmailOnCart($cartId);
103+
$this->addProductToCart($cartId, $quantity, $sku);
104+
105+
$shippingMethod = $this->setShippingAddressWithNullSecondStreet($cartId);
106+
107+
$this->setBillingAddress($cartId);
108+
$paymentMethod = $this->setShippingMethod($cartId, $shippingMethod);
109+
$this->setPaymentMethod($cartId, $paymentMethod);
110+
$this->placeOrder($cartId);
111+
}
112+
89113
/**
90114
* @return string
91115
*/
@@ -397,6 +421,92 @@ private function placeOrder(string $cartId): void
397421
self::assertNotEmpty($response['placeOrder']['order']['order_number']);
398422
}
399423

424+
/**
425+
* Set shipping address with null second street in address
426+
*
427+
* @param string $cartId
428+
* @return array
429+
*/
430+
private function setShippingAddressWithNullSecondStreet(string $cartId): array
431+
{
432+
$query = <<<QUERY
433+
mutation {
434+
setShippingAddressesOnCart(
435+
input: {
436+
cart_id: "$cartId"
437+
shipping_addresses: [
438+
{
439+
address: {
440+
firstname: "B"
441+
lastname: "C"
442+
street: ["Lorem ipsum dolor sit ame", null]
443+
city: "PARIS"
444+
postcode: "56590"
445+
country_code: "FR"
446+
telephone: "0601020304"
447+
save_in_address_book: false
448+
}
449+
}
450+
]
451+
}
452+
) {
453+
cart {
454+
shipping_addresses {
455+
firstname
456+
lastname
457+
company
458+
street
459+
city
460+
postcode
461+
country {
462+
code
463+
label
464+
}
465+
telephone
466+
available_shipping_methods {
467+
carrier_code
468+
method_code
469+
amount {
470+
value
471+
}
472+
}
473+
}
474+
}
475+
}
476+
}
477+
QUERY;
478+
479+
$response = $this->graphQlMutation($query);
480+
481+
self::assertArrayHasKey('setShippingAddressesOnCart', $response);
482+
self::assertArrayHasKey('cart', $response['setShippingAddressesOnCart']);
483+
self::assertArrayHasKey('shipping_addresses', $response['setShippingAddressesOnCart']['cart']);
484+
self::assertCount(1, $response['setShippingAddressesOnCart']['cart']['shipping_addresses']);
485+
486+
$shippingAddress = current($response['setShippingAddressesOnCart']['cart']['shipping_addresses']);
487+
488+
self::assertEquals('B', $shippingAddress['firstname']);
489+
self::assertEquals('C', $shippingAddress['lastname']);
490+
self::assertNull($shippingAddress['company']);
491+
self::assertEquals(['Lorem ipsum dolor sit ame'], $shippingAddress['street']);
492+
self::assertEquals('PARIS', $shippingAddress['city']);
493+
self::assertEquals('56590', $shippingAddress['postcode']);
494+
self::assertEquals('FR', $shippingAddress['country']['code']);
495+
self::assertEquals('FR', $shippingAddress['country']['label']);
496+
self::assertEquals('0601020304', $shippingAddress['telephone']);
497+
498+
self::assertArrayHasKey('available_shipping_methods', $shippingAddress);
499+
self::assertGreaterThan(0, count($shippingAddress['available_shipping_methods']));
500+
501+
$availableShippingMethod = current($shippingAddress['available_shipping_methods']);
502+
self::assertArrayHasKey('carrier_code', $availableShippingMethod);
503+
self::assertNotEmpty($availableShippingMethod['carrier_code']);
504+
self::assertArrayHasKey('method_code', $availableShippingMethod);
505+
self::assertNotEmpty($availableShippingMethod['method_code']);
506+
507+
return $availableShippingMethod;
508+
}
509+
400510
protected function tearDown(): void
401511
{
402512
$this->deleteQuote();

0 commit comments

Comments
 (0)