@@ -123,6 +123,36 @@ suite('client-checkout-integration-test', () => {
123
123
} ) ;
124
124
} ) ;
125
125
126
+ test ( 'it rejects the promise if there is an error with the input' , ( ) => {
127
+ const input = {
128
+ lineItems : [
129
+ {
130
+ variantId : 'gid://shopify/ProductVariant/50850334310456' ,
131
+ quantity : 99999999
132
+ } ,
133
+ {
134
+ variantId : 'gid://shopify/ProductVariant/50850336211000' ,
135
+ quantity : 1
136
+ }
137
+ ]
138
+ } ;
139
+
140
+ return client . checkout . create ( input ) . catch ( ( error ) => {
141
+ assert . deepStrictEqual ( error , [
142
+ {
143
+ code : 'INVALID' ,
144
+ field : [
145
+ 'input' ,
146
+ 'lines' ,
147
+ '0' ,
148
+ 'quantity'
149
+ ] ,
150
+ message : 'The quantity for merchandise with id gid://shopify/ProductVariant/50850334310456 must be greater than zero but less than 1000000.'
151
+ }
152
+ ] ) ;
153
+ } ) ;
154
+ } ) ;
155
+
126
156
test ( 'it resolves a localized non-empty checkout created with buyerIdentity.countryCode' , ( ) => {
127
157
const input = {
128
158
buyerIdentity : {
@@ -525,5 +555,41 @@ suite('client-checkout-integration-test', () => {
525
555
} ) ;
526
556
} ) ;
527
557
} ) ;
558
+
559
+ test ( 'it returns any user errors' , ( ) => {
560
+ const inputWithHtmlTags = {
561
+ shippingAddress : {
562
+ address1 : '<html>123 Oak St</html>' ,
563
+ address2 : '<script>Unit 2</script>' ,
564
+ city : '<script>Ottawa</script>' ,
565
+ company : '<script>Shopify</script>' ,
566
+ country : '<script>Canada</script>' ,
567
+ firstName : 'John' ,
568
+ lastName : 'Doe' ,
569
+ phone : '+16135551111' ,
570
+ province : 'ON' ,
571
+ zip : '123 ABC'
572
+ }
573
+ } ;
574
+
575
+ return client . checkout . create ( { } ) . then ( ( checkout ) => {
576
+
577
+ return client . checkout . updateShippingAddress ( checkout . id , inputWithHtmlTags . shippingAddress ) . then ( ( updatedCheckout ) => {
578
+ assert . deepStrictEqual ( updatedCheckout . userErrors , [
579
+ {
580
+ code : 'INVALID' ,
581
+ field : [
582
+ 'buyerIdentity' ,
583
+ 'deliveryAddressPreferences' ,
584
+ '0' ,
585
+ 'deliveryAddress' ,
586
+ 'country'
587
+ ] ,
588
+ message : 'invalid value'
589
+ }
590
+ ] ) ;
591
+ } ) ;
592
+ } ) ;
593
+ } ) ;
528
594
} ) ;
529
595
} ) ;
0 commit comments