Skip to content

Commit

Permalink
Merge pull request #599 from reactioncommerce/refactor-kieckhafer-rem…
Browse files Browse the repository at this point in the history
…oveDeprecatedField

refactor: remove deprecated api field
  • Loading branch information
aldeed authored Nov 6, 2019
2 parents c115759 + c125a5f commit f7d2996
Show file tree
Hide file tree
Showing 23 changed files with 82 additions and 65 deletions.
4 changes: 0 additions & 4 deletions src/components/CartPopover/CartPopover.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ class CartPopover extends Component {
*/
value: PropTypes.string
})),
/**
* Current stock quantity of item
*/
currentQuantity: PropTypes.number,
/**
* Image url of chosen item
*/
Expand Down
1 change: 0 additions & 1 deletion src/components/CartPopover/CartPopover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const cartItem = {
value: "Summer"
}
],
currentQuantity: 10,
imageUrl: "//placehold.it/100",
isLowInventoryQuantity: false,
price: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/CheckoutSummary/CheckoutSummary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ const testCart = {
compareAtPrice: {
displayAmount: "$45.00"
},
currentQuantity: 3,
imageURLs: {
small: "//placehold.it/150",
thumbnail: "//placehold.it/100"
},
currentQuantity: 3,
isLowQuantity: true,
price: {
displayAmount: "$20.00"
Expand All @@ -48,11 +48,11 @@ const testCart = {
{ label: "Color", value: "Black" },
{ label: "Size", value: "10" }
],
currentQuantity: 500,
imageURLs: {
small: "//placehold.it/150",
thumbnail: "//placehold.it/100"
},
currentQuantity: 30,
isLowQuantity: false,
price: {
displayAmount: "$78.00"
Expand Down
2 changes: 0 additions & 2 deletions src/components/MediaGallery/MediaGallery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import MediaGallery from "./MediaGallery";

const mediaItems = [
{
toGrid: 1,
priority: 0,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
variantId: "cmVhY3Rpb24vcHJvZHVjdDo2cWlxUHdCa2VKZHRkUWM0Rw==",
Expand All @@ -17,7 +16,6 @@ const mediaItems = [
}
},
{
toGrid: 1,
priority: 0,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
variantId: "cmVhY3Rpb24vcHJvZHVjdDo2cWlxUHdCa2VKZHRkUWM0Rw==",
Expand Down
1 change: 0 additions & 1 deletion src/components/MediaGalleryItem/MediaGalleryItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import renderer from "react-test-renderer";
import MediaGalleryItem from "./MediaGalleryItem";

const media = {
toGrid: 1,
priority: 0,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
variantId: "cmVhY3Rpb24vcHJvZHVjdDo2cWlxUHdCa2VKZHRkUWM0Rw==",
Expand Down
4 changes: 2 additions & 2 deletions src/components/OrderCard/OrderCard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const order = {
compareAtPrice: {
displayAmount: "$45.00"
},
currentQuantity: 3,
imageURLs: {
small: "//placehold.it/150",
thumbnail: "//placehold.it/100"
},
inventoryAvailableToSell: 3,
isLowQuantity: true,
price: {
displayAmount: "$20.00"
Expand All @@ -50,11 +50,11 @@ const order = {
{
_id: "456",
attributes: [{ label: "Color", value: "Black" }, { label: "Size", value: "10" }],
currentQuantity: 500,
imageURLs: {
small: "//placehold.it/150",
thumbnail: "//placehold.it/100"
},
inventoryAvailableToSell: 30,
isLowQuantity: false,
price: {
displayAmount: "$78.00"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,19 @@ class OrderCardFulfillmentGroup extends Component {
const { classes, fulfillmentGroup } = this.props;

if (fulfillmentGroup && Array.isArray(fulfillmentGroup.items.nodes)) {
const items = fulfillmentGroup.items.nodes.map((item) => ({
...item,
// Backwards compatibility until all component library components are updated
// to accept `inventoryAvailableToSell`.
currentQuantity: item.currentQuantity || item.inventoryAvailableToSell
}));

return (
<Grid className={classes.fulfillmentGroupDetails} item xs={12} md={12}>
<CartItems
isMiniCart
isReadOnly
items={fulfillmentGroup.items.nodes}
items={items}
/>
</Grid>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const testFulfillmentGroup = {
compareAtPrice: {
displayAmount: "$45.00"
},
currentQuantity: 3,
imageURLs: {
small: "//placehold.it/150",
thumbnail: "//placehold.it/100"
},
inventoryAvailableToSell: 3,
isLowQuantity: true,
price: {
displayAmount: "$20.00"
Expand All @@ -40,11 +40,11 @@ const testFulfillmentGroup = {
{
_id: "456",
attributes: [{ label: "Color", value: "Black" }, { label: "Size", value: "10" }],
currentQuantity: 500,
imageURLs: {
small: "//placehold.it/150",
thumbnail: "//placehold.it/100"
},
inventoryAvailableToSell: 30,
isLowQuantity: false,
price: {
displayAmount: "$78.00"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class OrderFulfillmentGroup extends Component {
const { classes, fulfillmentGroup, hasMoreCartItems, loadMoreCartItems } = this.props;

if (fulfillmentGroup && Array.isArray(fulfillmentGroup.items.nodes)) {
const items = fulfillmentGroup.items.nodes.map((item) => ({
...item,
// Backwards compatibility until all component library components are updated
// to accept `inventoryAvailableToSell`.
currentQuantity: item.currentQuantity || item.inventoryAvailableToSell
}));

return (
<div className={classes.fulfillmentDetails}>
<Grid item xs={12}>
Expand All @@ -75,7 +82,7 @@ class OrderFulfillmentGroup extends Component {
isReadOnly
hasMoreCartItems={hasMoreCartItems}
onLoadMoreCartItems={loadMoreCartItems}
items={fulfillmentGroup.items.nodes}
items={items}
onChangeCartItemQuantity={this.handleItemQuantityChange}
onRemoveItemFromCart={this.handleRemoveItem}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const testFulfillmentGroup = {
compareAtPrice: {
displayAmount: "$45.00"
},
currentQuantity: 3,
imageURLs: {
small: "//placehold.it/150",
thumbnail: "//placehold.it/100"
},
inventoryAvailableToSell: 3,
isLowQuantity: true,
price: {
displayAmount: "$20.00"
Expand All @@ -40,11 +40,11 @@ const testFulfillmentGroup = {
{
_id: "456",
attributes: [{ label: "Color", value: "Black" }, { label: "Size", value: "10" }],
currentQuantity: 500,
imageURLs: {
small: "//placehold.it/150",
thumbnail: "//placehold.it/100"
},
inventoryAvailableToSell: 30,
isLowQuantity: false,
price: {
displayAmount: "$78.00"
Expand Down
2 changes: 0 additions & 2 deletions src/components/OrderSummary/OrderSummary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const testFulfillmentGroup = {
compareAtPrice: {
displayAmount: "$45.00"
},
currentQuantity: 3,
imageURLs: {
small: "//placehold.it/150",
thumbnail: "//placehold.it/100"
Expand All @@ -40,7 +39,6 @@ const testFulfillmentGroup = {
{
_id: "456",
attributes: [{ label: "Color", value: "Black" }, { label: "Size", value: "10" }],
currentQuantity: 500,
imageURLs: {
small: "//placehold.it/150",
thumbnail: "//placehold.it/100"
Expand Down
14 changes: 9 additions & 5 deletions src/components/ProductDetail/ProductDetail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from "react";
import renderer from "react-test-renderer";
import { MuiThemeProvider } from "@material-ui/core/styles";
import { Provider } from "mobx-react";
import { ComponentsProvider } from "@reactioncommerce/components-context";
import components from "custom/componentsContext";
import theme from "custom/reactionTheme";
import ProductDetail from "./ProductDetail";
import sampleData from "./__mocks__/productData.mock";
Expand Down Expand Up @@ -43,11 +45,13 @@ const uiStore = {

test("basic snapshot", () => {
const component = renderer.create((
<MuiThemeProvider theme={theme}>
<Provider primaryShopId="J8Bhq3uTtdgwZx3rz" routingStore={routingStore} tags={tags} uiStore={uiStore}>
<ProductDetail product={sampleData} shop={shop} currencyCode={"USD"} />
</Provider>
</MuiThemeProvider>
<ComponentsProvider value={components}>
<MuiThemeProvider theme={theme}>
<Provider primaryShopId="J8Bhq3uTtdgwZx3rz" routingStore={routingStore} tags={tags} uiStore={uiStore}>
<ProductDetail product={sampleData} shop={shop} currencyCode={"USD"} />
</Provider>
</MuiThemeProvider>
</ComponentsProvider>
));
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
Expand Down
8 changes: 0 additions & 8 deletions src/components/ProductDetail/__mocks__/productData.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export default {
],
media: [
{
toGrid: 1,
priority: 0,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
variantId: "cmVhY3Rpb24vcHJvZHVjdDo2cWlxUHdCa2VKZHRkUWM0Rw==",
Expand All @@ -181,7 +180,6 @@ export default {
}
},
{
toGrid: 1,
priority: 0,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
variantId: "cmVhY3Rpb24vcHJvZHVjdDo2cWlxUHdCa2VKZHRkUWM0Rw==",
Expand All @@ -194,7 +192,6 @@ export default {
}
},
{
toGrid: 1,
priority: 0,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
variantId: "cmVhY3Rpb24vcHJvZHVjdDpTTXI0cmhERm5ZdkZNdERUWA==",
Expand All @@ -207,7 +204,6 @@ export default {
}
},
{
toGrid: 1,
priority: 0,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
variantId: "cmVhY3Rpb24vcHJvZHVjdDpDSm9SQm05dlJyb3JjOW14Wg==",
Expand All @@ -220,7 +216,6 @@ export default {
}
},
{
toGrid: 1,
priority: 2,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
variantId: "cmVhY3Rpb24vcHJvZHVjdDo2cWlxUHdCa2VKZHRkUWM0Rw==",
Expand All @@ -233,7 +228,6 @@ export default {
}
},
{
toGrid: 1,
priority: 3,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
variantId: "cmVhY3Rpb24vcHJvZHVjdDo2cWlxUHdCa2VKZHRkUWM0Rw==",
Expand All @@ -246,7 +240,6 @@ export default {
}
},
{
toGrid: 1,
priority: 4,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
variantId: "cmVhY3Rpb24vcHJvZHVjdDo2cWlxUHdCa2VKZHRkUWM0Rw==",
Expand All @@ -259,7 +252,6 @@ export default {
}
},
{
toGrid: 1,
priority: 5,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
variantId: "cmVhY3Rpb24vcHJvZHVjdDo2cWlxUHdCa2VKZHRkUWM0Rw==",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`basic snapshot 1`] = `
.c7 {
width: 1.125em;
height: 1.125em;
}
.c2 {
position: relative;
opacity: 0.5;
}
.c3 {
position: relative;
}
.c5 {
-webkit-font-smoothing: antialiased;
-webkit-align-items: center;
Expand Down Expand Up @@ -68,15 +82,6 @@ exports[`basic snapshot 1`] = `
fill: #ffffff;
}
.c2 {
position: relative;
opacity: 0.5;
}
.c3 {
position: relative;
}
.c4 {
-webkit-font-smoothing: antialiased;
color: #cd3f4c;
Expand Down Expand Up @@ -921,7 +926,37 @@ Details can be added below the image for more specific product information.
"width": 0,
}
}
/>
>
<svg
className="c7"
height="40px"
style={
Object {
"enableBackground": "new 0 0 50 50",
}
}
version="1.1"
viewBox="0 0 50 50"
width="40px"
x="0px"
y="0px"
>
<path
d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z"
fill="#000"
>
<animateTransform
attributeName="transform"
attributeType="xml"
dur="1s"
from="0 25 25"
repeatCount="indefinite"
to="360 25 25"
type="rotate"
/>
</path>
</svg>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const cartItem = {
value: "Summer"
}
],
currentQuantity: 10,
imageUrl: "//placehold.it/100",
isLowInventoryQuantity: false,
price: {
Expand Down
2 changes: 0 additions & 2 deletions src/components/ProductGrid/__mocks__/products.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default [
isSoldOut: true,
isBackorder: false,
primaryImage: {
toGrid: 1,
priority: 0,
productId: "cmVhY3Rpb24vcHJvZHVjdDpqbmE5NWthOWFOa015dG14aA==",
URLs: {
Expand Down Expand Up @@ -57,7 +56,6 @@ export default [
isSoldOut: false,
isBackorder: false,
primaryImage: {
toGrid: 1,
priority: 0,
productId: "cmVhY3Rpb24vcHJvZHVjdDpCQ1RNWjZIVHhGU3BwSkVTaw==",
URLs: {
Expand Down
Loading

0 comments on commit f7d2996

Please sign in to comment.