Skip to content

Commit ab85e0a

Browse files
committed
fix: fixes for currentQuantity removal
Signed-off-by: Eric Dobbertin <[email protected]>
1 parent 4006ee1 commit ab85e0a

File tree

10 files changed

+177
-399
lines changed

10 files changed

+177
-399
lines changed

src/components/CheckoutSummary/CheckoutSummary.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const testCart = {
3232
small: "//placehold.it/150",
3333
thumbnail: "//placehold.it/100"
3434
},
35+
currentQuantity: 3,
3536
isLowQuantity: true,
3637
price: {
3738
displayAmount: "$20.00"
@@ -51,6 +52,7 @@ const testCart = {
5152
small: "//placehold.it/150",
5253
thumbnail: "//placehold.it/100"
5354
},
55+
currentQuantity: 30,
5456
isLowQuantity: false,
5557
price: {
5658
displayAmount: "$78.00"

src/components/OrderCard/OrderCard.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const order = {
3737
small: "//placehold.it/150",
3838
thumbnail: "//placehold.it/100"
3939
},
40+
inventoryAvailableToSell: 3,
4041
isLowQuantity: true,
4142
price: {
4243
displayAmount: "$20.00"
@@ -53,6 +54,7 @@ const order = {
5354
small: "//placehold.it/150",
5455
thumbnail: "//placehold.it/100"
5556
},
57+
inventoryAvailableToSell: 30,
5658
isLowQuantity: false,
5759
price: {
5860
displayAmount: "$78.00"

src/components/OrderCardFulfillmentGroup/OrderCardFulfillmentGroup.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,19 @@ class OrderCardFulfillmentGroup extends Component {
7070
const { classes, fulfillmentGroup } = this.props;
7171

7272
if (fulfillmentGroup && Array.isArray(fulfillmentGroup.items.nodes)) {
73+
const items = fulfillmentGroup.items.nodes.map((item) => ({
74+
...item,
75+
// Backwards compatibility until all component library components are updated
76+
// to accept `inventoryAvailableToSell`.
77+
currentQuantity: item.currentQuantity || item.inventoryAvailableToSell
78+
}));
79+
7380
return (
7481
<Grid className={classes.fulfillmentGroupDetails} item xs={12} md={12}>
7582
<CartItems
7683
isMiniCart
7784
isReadOnly
78-
items={fulfillmentGroup.items.nodes}
85+
items={items}
7986
/>
8087
</Grid>
8188
);

src/components/OrderCardFulfillmentGroup/OrderCardFulfillmentGroup.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const testFulfillmentGroup = {
2727
small: "//placehold.it/150",
2828
thumbnail: "//placehold.it/100"
2929
},
30+
inventoryAvailableToSell: 3,
3031
isLowQuantity: true,
3132
price: {
3233
displayAmount: "$20.00"
@@ -43,6 +44,7 @@ const testFulfillmentGroup = {
4344
small: "//placehold.it/150",
4445
thumbnail: "//placehold.it/100"
4546
},
47+
inventoryAvailableToSell: 30,
4648
isLowQuantity: false,
4749
price: {
4850
displayAmount: "$78.00"

src/components/OrderFulfillmentGroup/OrderFulfillmentGroup.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ class OrderFulfillmentGroup extends Component {
6767
const { classes, fulfillmentGroup, hasMoreCartItems, loadMoreCartItems } = this.props;
6868

6969
if (fulfillmentGroup && Array.isArray(fulfillmentGroup.items.nodes)) {
70+
const items = fulfillmentGroup.items.nodes.map((item) => ({
71+
...item,
72+
// Backwards compatibility until all component library components are updated
73+
// to accept `inventoryAvailableToSell`.
74+
currentQuantity: item.currentQuantity || item.inventoryAvailableToSell
75+
}));
76+
7077
return (
7178
<div className={classes.fulfillmentDetails}>
7279
<Grid item xs={12}>
@@ -75,7 +82,7 @@ class OrderFulfillmentGroup extends Component {
7582
isReadOnly
7683
hasMoreCartItems={hasMoreCartItems}
7784
onLoadMoreCartItems={loadMoreCartItems}
78-
items={fulfillmentGroup.items.nodes}
85+
items={items}
7986
onChangeCartItemQuantity={this.handleItemQuantityChange}
8087
onRemoveItemFromCart={this.handleRemoveItem}
8188
/>

src/components/OrderFulfillmentGroup/OrderFulfillmentGroup.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const testFulfillmentGroup = {
2727
small: "//placehold.it/150",
2828
thumbnail: "//placehold.it/100"
2929
},
30+
inventoryAvailableToSell: 3,
3031
isLowQuantity: true,
3132
price: {
3233
displayAmount: "$20.00"
@@ -43,6 +44,7 @@ const testFulfillmentGroup = {
4344
small: "//placehold.it/150",
4445
thumbnail: "//placehold.it/100"
4546
},
47+
inventoryAvailableToSell: 30,
4648
isLowQuantity: false,
4749
price: {
4850
displayAmount: "$78.00"

src/components/ProductDetail/ProductDetail.test.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from "react";
22
import renderer from "react-test-renderer";
33
import { MuiThemeProvider } from "@material-ui/core/styles";
44
import { Provider } from "mobx-react";
5+
import { ComponentsProvider } from "@reactioncommerce/components-context";
6+
import components from "custom/componentsContext";
57
import theme from "custom/reactionTheme";
68
import ProductDetail from "./ProductDetail";
79
import sampleData from "./__mocks__/productData.mock";
@@ -43,11 +45,13 @@ const uiStore = {
4345

4446
test("basic snapshot", () => {
4547
const component = renderer.create((
46-
<MuiThemeProvider theme={theme}>
47-
<Provider primaryShopId="J8Bhq3uTtdgwZx3rz" routingStore={routingStore} tags={tags} uiStore={uiStore}>
48-
<ProductDetail product={sampleData} shop={shop} currencyCode={"USD"} />
49-
</Provider>
50-
</MuiThemeProvider>
48+
<ComponentsProvider value={components}>
49+
<MuiThemeProvider theme={theme}>
50+
<Provider primaryShopId="J8Bhq3uTtdgwZx3rz" routingStore={routingStore} tags={tags} uiStore={uiStore}>
51+
<ProductDetail product={sampleData} shop={shop} currencyCode={"USD"} />
52+
</Provider>
53+
</MuiThemeProvider>
54+
</ComponentsProvider>
5155
));
5256
const tree = component.toJSON();
5357
expect(tree).toMatchSnapshot();

src/components/ProductDetail/__snapshots__/ProductDetail.test.js.snap

Lines changed: 11 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`basic snapshot 1`] = `
4-
.c5 {
5-
-webkit-font-smoothing: antialiased;
6-
-webkit-align-items: center;
7-
-webkit-box-align: center;
8-
-ms-flex-align: center;
9-
align-items: center;
10-
background-color: #1999dd;
11-
border-color: #1999dd;
12-
border-style: solid;
13-
border-width: 1px;
14-
border-radius: 2px;
15-
box-sizing: border-box;
16-
color: #ffffff;
17-
cursor: pointer;
18-
display: -webkit-box;
19-
display: -webkit-flex;
20-
display: -ms-flexbox;
21-
display: flex;
22-
font-family: "Source Sans Pro","Helvetica Neue",Helvetica,sans-serif;
23-
-webkit-box-pack: center;
24-
-webkit-justify-content: center;
25-
-ms-flex-pack: center;
26-
justify-content: center;
27-
margin: 0;
28-
min-width: 100px;
29-
outline: none;
30-
padding-left: 20px;
31-
padding-right: 20px;
32-
padding-top: 10px;
33-
padding-bottom: 10px;
34-
position: relative;
35-
text-align: center;
36-
-webkit-user-select: none;
37-
-moz-user-select: none;
38-
-ms-user-select: none;
39-
user-select: none;
40-
width: 100%;
41-
}
42-
43-
.c5:hover {
44-
background-color: #25b0f9;
45-
border-color: #25b0f9;
46-
color: #ffffff;
47-
}
48-
49-
.c5:active {
50-
background-color: #057dbe;
51-
border-color: #057dbe;
52-
color: #ffffff;
53-
}
54-
55-
.c6 {
56-
display: -webkit-box;
57-
display: -webkit-flex;
58-
display: -ms-flexbox;
59-
display: flex;
60-
overflow: hidden;
61-
padding-left: 20px;
62-
-webkit-transition: width 0.2s ease-out 0s,padding-left 0.2s ease-out 0s,opacity 0.2s ease-out 0.2s;
63-
transition: width 0.2s ease-out 0s,padding-left 0.2s ease-out 0s,opacity 0.2s ease-out 0.2s;
64-
}
65-
66-
.c6 svg path,
67-
.c6 svg rect {
68-
fill: #ffffff;
69-
}
70-
714
.c2 {
725
position: relative;
736
opacity: 0.5;
@@ -252,7 +185,7 @@ exports[`basic snapshot 1`] = `
252185
/>
253186
</div>
254187
<span
255-
className="MuiTouchRipple-root-250"
188+
className="MuiTouchRipple-root-235"
256189
/>
257190
</button>
258191
</div>
@@ -286,7 +219,7 @@ exports[`basic snapshot 1`] = `
286219
/>
287220
</div>
288221
<span
289-
className="MuiTouchRipple-root-250"
222+
className="MuiTouchRipple-root-235"
290223
/>
291224
</button>
292225
</div>
@@ -320,7 +253,7 @@ exports[`basic snapshot 1`] = `
320253
/>
321254
</div>
322255
<span
323-
className="MuiTouchRipple-root-250"
256+
className="MuiTouchRipple-root-235"
324257
/>
325258
</button>
326259
</div>
@@ -354,7 +287,7 @@ exports[`basic snapshot 1`] = `
354287
/>
355288
</div>
356289
<span
357-
className="MuiTouchRipple-root-250"
290+
className="MuiTouchRipple-root-235"
358291
/>
359292
</button>
360293
</div>
@@ -388,7 +321,7 @@ exports[`basic snapshot 1`] = `
388321
/>
389322
</div>
390323
<span
391-
className="MuiTouchRipple-root-250"
324+
className="MuiTouchRipple-root-235"
392325
/>
393326
</button>
394327
</div>
@@ -422,7 +355,7 @@ exports[`basic snapshot 1`] = `
422355
/>
423356
</div>
424357
<span
425-
className="MuiTouchRipple-root-250"
358+
className="MuiTouchRipple-root-235"
426359
/>
427360
</button>
428361
</div>
@@ -456,7 +389,7 @@ exports[`basic snapshot 1`] = `
456389
/>
457390
</div>
458391
<span
459-
className="MuiTouchRipple-root-250"
392+
className="MuiTouchRipple-root-235"
460393
/>
461394
</button>
462395
</div>
@@ -490,7 +423,7 @@ exports[`basic snapshot 1`] = `
490423
/>
491424
</div>
492425
<span
493-
className="MuiTouchRipple-root-250"
426+
className="MuiTouchRipple-root-235"
494427
/>
495428
</button>
496429
</div>
@@ -778,7 +711,7 @@ Details can be added below the image for more specific product information.
778711
/>
779712
</svg>
780713
<span
781-
className="MuiTouchRipple-root-250"
714+
className="MuiTouchRipple-root-235"
782715
/>
783716
</button>
784717
</div>
@@ -828,7 +761,7 @@ Details can be added below the image for more specific product information.
828761
/>
829762
</svg>
830763
<span
831-
className="MuiTouchRipple-root-250"
764+
className="MuiTouchRipple-root-235"
832765
/>
833766
</button>
834767
</div>
@@ -864,69 +797,11 @@ Details can be added below the image for more specific product information.
864797
Add to cart
865798
</span>
866799
<span
867-
className="MuiTouchRipple-root-250"
800+
className="MuiTouchRipple-root-235"
868801
/>
869802
</button>
870803
</div>
871804
</div>
872-
<div
873-
className="MuiPrivateHiddenCss-mdUp-242"
874-
>
875-
<div
876-
className="SkCartPopover-container-227 SkCartPopover-isContainerHidden-229"
877-
>
878-
<div
879-
className="MuiGrid-container-4 MuiGrid-spacing-xs-24-28 SkCartPopover-gridContainer-228"
880-
>
881-
<div
882-
className="MuiGrid-item-5 MuiGrid-grid-xs-12-44 SkCartPopover-containerItem-231"
883-
>
884-
<img
885-
alt="Item Title"
886-
className="SkCartPopover-addedToCartImg-232"
887-
src="//placehold.it/100"
888-
/>
889-
<span
890-
className="MuiTypography-root-121 MuiTypography-body2-129 SkCartPopover-addedToCartText-234"
891-
>
892-
10
893-
"
894-
<span
895-
className="SkCartPopover-addedToCartItemName-233"
896-
>
897-
Item Title
898-
</span>
899-
" added to cart
900-
</span>
901-
</div>
902-
<div
903-
className="MuiGrid-item-5 MuiGrid-grid-xs-12-44"
904-
>
905-
<div
906-
className="c5"
907-
onClick={[Function]}
908-
onKeyPress={[Function]}
909-
role="button"
910-
tabIndex={0}
911-
>
912-
<div>
913-
Checkout
914-
</div>
915-
<div
916-
className="c6"
917-
style={
918-
Object {
919-
"opacity": 0,
920-
"paddingLeft": 0,
921-
"width": 0,
922-
}
923-
}
924-
/>
925-
</div>
926-
</div>
927-
</div>
928-
</div>
929-
</div>
930805
</div>
931806
</div>
932807
`;

0 commit comments

Comments
 (0)