Skip to content

Commit

Permalink
Cart tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdixon committed Feb 9, 2024
1 parent 45b36db commit f7cba95
Show file tree
Hide file tree
Showing 20 changed files with 671 additions and 502 deletions.
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,22 +299,6 @@ client.cart.updateNote(cartId, note).then((cart) => {
}
```
### Updating Cart Selected Delivery Options
```javascript
const cartId = 'gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSE5WWTAyVjlETjFDNVowVFZEWVMwMVJR';
const selectedDeliveryOptions = [
{
deliveryGroupId: '',
deliveryOptionHandle: ''
}
];

client.cart.updateSelectedDeliveryOptions(cartId, selectedDeliveryOptions).then((cart) => {
// Do something with the updated cart
}
```
### Redirecting to Checkout
To complete the purchase, redirect customers to the `checkoutUrl` property attached to the cart.
Expand Down
18 changes: 18 additions & 0 deletions fixtures/cart-line-items-add-fixture-with-user-errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default {
data: {
cartLinesAdd: {
cart: null,
userErrors: [
{
field: [
'lines',
'0',
'merchandiseId'
],
message: 'The merchandise with id gid://shopify/ProductVariant/invalid-id does not exist.',
code: 'INVALID'
}
]
}
}
}
81 changes: 81 additions & 0 deletions fixtures/cart-line-items-add-fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
export default {
data: {
cartLinesAdd: {
cart: {
id: 'gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSFA1UFBYVE1ZTkRBVkFHMlNIQ1RENE0y',
createdAt: '2024-02-09T01:11:32Z',
updatedAt: '2024-02-09T01:11:33Z',
lines: {
pageInfo: {
hasNextPage: false,
hasPreviousPage: false
},
edges: [
{
node: {
__typename: 'CartLine',
id: 'gid://shopify/CartLine/ff20f2b0-a16f-4127-8f5c-3ae00596fcb9?cart=Z2NwLXVzLWVhc3QxOjAxSFA1UFBYVE1ZTkRBVkFHMlNIQ1RENE0y',
merchandise: {
id: 'gid://shopify/ProductVariant/13666012889144'
},
quantity: 2,
attributes: [],
cost: {
totalAmount: {
amount: '10.3',
currencyCode: 'AUD'
},
subtotalAmount: {
amount: '10.3',
currencyCode: 'AUD'
},
amountPerQuantity: {
amount: '5.15',
currencyCode: 'AUD'
},
compareAtAmountPerQuantity: null
},
discountAllocations: [],
sellingPlanAllocation: null
}
}
]
},
attributes: [],
cost: {
totalAmount: {
amount: '10.2',
currencyCode: 'AUD'
},
subtotalAmount: {
amount: '10.3',
currencyCode: 'AUD'
},
totalTaxAmount: {
amount: '0.93',
currencyCode: 'AUD'
},
totalDutyAmount: null
},
checkoutUrl: 'https://myshopify.com/cart/c/Z2NwLXVzLWVhc3QxOjAxSFA1UFBYVE1ZTkRBVkFHMlNIQ1RENE0y?key=239090a4dea9c74475cd0b63d8561d39',
discountCodes: [],
buyerIdentity: {
countryCode: null,
walletPreferences: [],
email: null,
phone: null,
customer: null
},
deliveryGroups: {
pageInfo: {
hasNextPage: false,
hasPreviousPage: false
},
edges: []
},
note: ''
},
userErrors: []
}
}
}
49 changes: 49 additions & 0 deletions fixtures/cart-line-items-remove-fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export default {
data: {
cartLinesRemove: {
cart: {
id: 'gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSFA1UFBYVE1ZTkRBVkFHMlNIQ1RENE0y',
createdAt: '2024-02-09T04:22:51Z',
updatedAt: '2024-02-09T04:22:52Z',
lines: {
pageInfo: {
hasNextPage: false,
hasPreviousPage: false
},
edges: []
},
attributes: [],
cost: {
totalAmount: {
amount: '0.0',
currencyCode: 'AUD'
},
subtotalAmount: {
amount: '0.0',
currencyCode: 'AUD'
},
totalTaxAmount: null,
totalDutyAmount: null
},
checkoutUrl: 'https://myshopify.com/cart/c/Z2NwLXVzLWVhc3QxOjAxSFA2MU44Mk1ZM0tTVjBHOUJZVFA1MTIx?key=fcf02f7c1e176bf0c999aabfcc660c3f',
discountCodes: [],
buyerIdentity: {
countryCode: null,
walletPreferences: [],
email: null,
phone: null,
customer: null
},
deliveryGroups: {
pageInfo: {
hasNextPage: false,
hasPreviousPage: false
},
edges: []
},
note: ''
},
userErrors: []
}
}
}
18 changes: 18 additions & 0 deletions fixtures/cart-line-items-update-fixture-with-user-errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default {
data: {
cartLinesUpdate: {
cart: null,
userErrors: [
{
field: [
'lines',
'0',
'merchandiseId'
],
message: 'The merchandise with id gid://shopify/ProductVariant/invalid-id does not exist.',
code: 'INVALID'
}
]
}
}
}
81 changes: 81 additions & 0 deletions fixtures/cart-line-items-update-fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
export default {
data: {
cartLinesUpdate: {
cart: {
id: 'gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSFA1UFBYVE1ZTkRBVkFHMlNIQ1RENE0y',
createdAt: '2024-02-09T01:11:32Z',
updatedAt: '2024-02-09T01:11:33Z',
lines: {
pageInfo: {
hasNextPage: false,
hasPreviousPage: false
},
edges: [
{
node: {
__typename: 'CartLine',
id: 'gid://shopify/CartLine/ff20f2b0-a16f-4127-8f5c-3ae00596fcb9?cart=Z2NwLXVzLWVhc3QxOjAxSFA1UFBYVE1ZTkRBVkFHMlNIQ1RENE0y',
merchandise: {
id: 'gid://shopify/ProductVariant/13666012889144'
},
quantity: 2,
attributes: [],
cost: {
totalAmount: {
amount: '10.3',
currencyCode: 'AUD'
},
subtotalAmount: {
amount: '10.3',
currencyCode: 'AUD'
},
amountPerQuantity: {
amount: '5.15',
currencyCode: 'AUD'
},
compareAtAmountPerQuantity: null
},
discountAllocations: [],
sellingPlanAllocation: null
}
}
]
},
attributes: [],
cost: {
totalAmount: {
amount: '10.2',
currencyCode: 'AUD'
},
subtotalAmount: {
amount: '10.3',
currencyCode: 'AUD'
},
totalTaxAmount: {
amount: '0.93',
currencyCode: 'AUD'
},
totalDutyAmount: null
},
checkoutUrl: 'https://myshopify.com/cart/c/Z2NwLXVzLWVhc3QxOjAxSFA1UFBYVE1ZTkRBVkFHMlNIQ1RENE0y?key=239090a4dea9c74475cd0b63d8561d39',
discountCodes: [],
buyerIdentity: {
countryCode: null,
walletPreferences: [],
email: null,
phone: null,
customer: null
},
deliveryGroups: {
pageInfo: {
hasNextPage: false,
hasPreviousPage: false
},
edges: []
},
note: ''
},
userErrors: []
}
}
}
17 changes: 17 additions & 0 deletions fixtures/cart-update-buyer-identity-fixture-with-user-errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
data: {
cartBuyerIdentityUpdate: {
cart: null,
userErrors: [
{
field: [
'buyerIdentity',
'email'
],
message: 'Email is invalid',
code: 'INVALID'
}
]
}
}
}
82 changes: 82 additions & 0 deletions fixtures/cart-update-buyer-identity-fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
export default {
data: {
cartBuyerIdentityUpdate: {
cart: {
id: 'gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSFA1SlNWOEQ5TUdaTkNaWEZZTk5LRE5T',
createdAt: '2024-02-09T00:03:13Z',
updatedAt: '2024-02-09T00:03:14Z',
lines: {
pageInfo: {
hasNextPage: false,
hasPreviousPage: false
},
edges: [
{
node: {
__typename: 'CartLine',
id: 'gid://shopify/CartLine/c6a616d3-64cc-493d-8328-a92b1215fb4b?cart=Z2NwLXVzLWVhc3QxOjAxSFA1SlNWOEQ5TUdaTkNaWEZZTk5LRE5T',
merchandise: {
id: 'gid://shopify/ProductVariant/13666012889144'
},
quantity: 1,
attributes: [],
cost: {
totalAmount: {
amount: '5.15',
currencyCode: 'AUD'
},
subtotalAmount: {
amount: '5.15',
currencyCode: 'AUD'
},
amountPerQuantity: {
amount: '5.15',
currencyCode: 'AUD'
},
compareAtAmountPerQuantity: null
},
discountAllocations: [],
sellingPlanAllocation: null
}
}
]
},
attributes: [],
cost: {
totalAmount: {
amount: '5.09',
currencyCode: 'AUD'
},
subtotalAmount: {
amount: '5.15',
currencyCode: 'AUD'
},
totalTaxAmount: {
amount: '0.46',
currencyCode: 'AUD'
},
totalDutyAmount: null
},
checkoutUrl: 'https://myshopify.com/cart/c/Z2NwLXVzLWVhc3QxOjAxSFA1SlNWOEQ5TUdaTkNaWEZZTk5LRE5T?key=f031e84cff5ad3935d96d0cc708a97b8',
discountCodes: [],
buyerIdentity: {
countryCode: null,
walletPreferences: [],
email: '[email protected]',
phone: null,
customer: null,
deliveryAddressPreferences: []
},
deliveryGroups: {
pageInfo: {
hasNextPage: false,
hasPreviousPage: false
},
edges: []
},
note: ''
},
userErrors: []
}
}
}
Loading

0 comments on commit f7cba95

Please sign in to comment.