From cb16d680604ea9a62dae41cf6c6b7dc9eac7d5dc Mon Sep 17 00:00:00 2001 From: dominik-zeglen Date: Tue, 27 Aug 2019 11:35:54 +0200 Subject: [PATCH] Fix snapshot testing --- .babelrc | 34 -- babel.config.js | 42 ++ package-lock.json | 13 - package.json | 7 +- .../CollectionProducts/CollectionProducts.tsx | 13 +- .../HomeNotificationTable.tsx | 202 +++++---- .../OrderFulfillment/OrderFulfillment.tsx | 4 +- src/pages/components/PageInfo/PageInfo.tsx | 2 +- .../ProductUpdatePage/ProductUpdatePage.tsx | 4 + .../__snapshots__/Stories.test.ts.snap | 383 +++++++++--------- src/storybook/stories/home/HomePage.tsx | 8 +- 11 files changed, 346 insertions(+), 366 deletions(-) delete mode 100644 .babelrc create mode 100644 babel.config.js diff --git a/.babelrc b/.babelrc deleted file mode 100644 index e25d8f3b8..000000000 --- a/.babelrc +++ /dev/null @@ -1,34 +0,0 @@ -{ - "presets": [ - [ - "@babel/preset-env", - { - "corejs": "3.2.1", - "modules": false, - "useBuiltIns": "usage" - } - ], - "@babel/preset-react", - "@babel/preset-typescript" - ], - "plugins": [ - "@babel/plugin-proposal-numeric-separator", - "@babel/plugin-proposal-class-properties", - [ - "@babel/plugin-proposal-decorators", - { - "decoratorsBeforeExport": true - } - ], - "@babel/plugin-proposal-object-rest-spread", - "react-intl-auto", - [ - "react-intl", - { - "extractFromFormatMessageCall": true, - "messagesDir": "build/locale/" - } - ] - ], - "ignore": ["**/*.test.ts", "**/*.test.tsx", "src/storybook"] -} diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 000000000..9ebdb1c97 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,42 @@ +module.exports = api => { + const isTest = api.env("test"); + + const ignore = isTest + ? [] + : ["**/*.test.ts", "**/*.test.tsx", "src/storybook"]; + + return { + presets: [ + [ + "@babel/preset-env", + { + corejs: "3.2.1", + modules: isTest ? "auto" : false, + useBuiltIns: "usage" + } + ], + "@babel/preset-react", + "@babel/preset-typescript" + ], + plugins: [ + "@babel/plugin-proposal-numeric-separator", + "@babel/plugin-proposal-class-properties", + [ + "@babel/plugin-proposal-decorators", + { + decoratorsBeforeExport: true + } + ], + "@babel/plugin-proposal-object-rest-spread", + "react-intl-auto", + [ + "react-intl", + { + extractFromFormatMessageCall: true, + messagesDir: "build/locale/" + } + ] + ], + ignore + }; +}; diff --git a/package-lock.json b/package-lock.json index a3b8d9fa2..97f41e770 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19629,19 +19629,6 @@ } } }, - "ts-loader": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-5.4.5.tgz", - "integrity": "sha512-XYsjfnRQCBum9AMRZpk2rTYSVpdZBpZK+kDh0TeT3kxmQNBDVIeUjdPjY5RZry4eIAb8XHc4gYSUiUWPYvzSRw==", - "dev": true, - "requires": { - "chalk": "^2.3.0", - "enhanced-resolve": "^4.0.0", - "loader-utils": "^1.0.2", - "micromatch": "^3.1.4", - "semver": "^5.0.1" - } - }, "ts-node": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.3.0.tgz", diff --git a/package.json b/package.json index 8663c5f9d..e82b33d49 100644 --- a/package.json +++ b/package.json @@ -139,13 +139,8 @@ "fsevents": "^1.2.9" }, "jest": { - "globals": { - "ts-jest": { - "tsConfig": "tsconfig.json" - } - }, "transform": { - "^.+\\.tsx?$": "ts-jest", + "^.+\\.(jsx?|tsx?)$": "babel-jest", "^.+\\.(png|svg|jpe?g)$": "jest-file" }, "testRegex": ".*\\.test\\.tsx?$", diff --git a/src/collections/components/CollectionProducts/CollectionProducts.tsx b/src/collections/components/CollectionProducts/CollectionProducts.tsx index 06be723e1..2fb889616 100644 --- a/src/collections/components/CollectionProducts/CollectionProducts.tsx +++ b/src/collections/components/CollectionProducts/CollectionProducts.tsx @@ -91,10 +91,15 @@ const CollectionProducts = withStyles(styles, { name: "CollectionProducts" })( collection.name, "...") + } + ) ) : ( ) diff --git a/src/home/components/HomeNotificationTable/HomeNotificationTable.tsx b/src/home/components/HomeNotificationTable/HomeNotificationTable.tsx index 0262142a2..cf63c5597 100644 --- a/src/home/components/HomeNotificationTable/HomeNotificationTable.tsx +++ b/src/home/components/HomeNotificationTable/HomeNotificationTable.tsx @@ -12,7 +12,7 @@ import TableRow from "@material-ui/core/TableRow"; import Typography from "@material-ui/core/Typography"; import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"; import React from "react"; -import { FormattedMessage, useIntl } from "react-intl"; +import { FormattedMessage } from "react-intl"; import Skeleton from "@saleor/components/Skeleton"; @@ -46,108 +46,104 @@ const HomeNotificationTable = withStyles(styles, { ordersToCapture, ordersToFulfill, productsOutOfStock - }: HomeNotificationTableProps) => { - const intl = useIntl(); - - return ( - - - - - - {ordersToFulfill === undefined ? ( - - ) : ordersToFulfill === 0 ? ( - - - - ) : ( - - - - )} - - - - - - - - {ordersToCapture === undefined ? ( - - ) : ordersToCapture === 0 ? ( - - - - ) : ( - - - - )} - - - - - - - - {productsOutOfStock === undefined ? ( - - ) : productsOutOfStock === 0 ? ( - - - - ) : ( - - - - )} - - - - - - -
-
- ); - } + }: HomeNotificationTableProps) => ( + + + + + + {ordersToFulfill === undefined ? ( + + ) : ordersToFulfill === 0 ? ( + + + + ) : ( + + + + )} + + + + + + + + {ordersToCapture === undefined ? ( + + ) : ordersToCapture === 0 ? ( + + + + ) : ( + + + + )} + + + + + + + + {productsOutOfStock === undefined ? ( + + ) : productsOutOfStock === 0 ? ( + + + + ) : ( + + + + )} + + + + + + +
+
+ ) ); HomeNotificationTable.displayName = "HomeNotificationTable"; export default HomeNotificationTable; diff --git a/src/orders/components/OrderFulfillment/OrderFulfillment.tsx b/src/orders/components/OrderFulfillment/OrderFulfillment.tsx index 45ffb159b..8c35c4a49 100644 --- a/src/orders/components/OrderFulfillment/OrderFulfillment.tsx +++ b/src/orders/components/OrderFulfillment/OrderFulfillment.tsx @@ -86,8 +86,8 @@ const OrderFulfillment = withStyles(styles, { name: "OrderFulfillment" })( const lines = maybe(() => fulfillment.lines); const status = maybe(() => fulfillment.status); const quantity = lines - .map(line => line.quantity) - .reduce((prev, curr) => prev + curr, 0); + ? lines.map(line => line.quantity).reduce((prev, curr) => prev + curr, 0) + : "..."; return ( diff --git a/src/pages/components/PageInfo/PageInfo.tsx b/src/pages/components/PageInfo/PageInfo.tsx index a07e92408..955aa6892 100644 --- a/src/pages/components/PageInfo/PageInfo.tsx +++ b/src/pages/components/PageInfo/PageInfo.tsx @@ -3,7 +3,7 @@ import CardContent from "@material-ui/core/CardContent"; import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles"; import TextField from "@material-ui/core/TextField"; import React from "react"; -import { FormattedMessage, useIntl } from "react-intl"; +import { useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import FormSpacer from "@saleor/components/FormSpacer"; diff --git a/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx b/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx index 155d79de2..acd0f4c70 100644 --- a/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx +++ b/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx @@ -263,6 +263,10 @@ export const ProductUpdatePage: React.FC = ({ loading={disabled} onClick={onSeoClick} onChange={change} + helperText={intl.formatMessage({ + defaultMessage: + "Add search engine title and description to make this product easier to find" + })} />
diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index e5c03d122..9c7dbc8f6 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -76,7 +76,7 @@ exports[`Storyshots Generics / AddressEdit default 1`] = ` class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - First name + First Name
- Last name + Last Name
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse -
- malesuada lacus ex, sit amet blandit leo lobortis eget. + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.

@@ -5340,9 +5338,7 @@ exports[`Storyshots Generics / Timeline with order notes 1`] = `

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse -
- malesuada lacus ex, sit amet blandit leo lobortis eget. + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.

@@ -12456,7 +12452,7 @@ exports[`Storyshots Views / Categories / Category list default 1`] = ` class="MuiTableCell-root-id MuiTableCell-head-id CategoryList-colProducts-id" scope="col" > - No. Products + No. of Products @@ -12869,7 +12865,7 @@ exports[`Storyshots Views / Categories / Category list empty 1`] = ` class="MuiTableCell-root-id MuiTableCell-head-id CategoryList-colProducts-id" scope="col" > - No. Products + No. of Products @@ -13104,7 +13100,7 @@ exports[`Storyshots Views / Categories / Category list loading 1`] = ` class="MuiTableCell-root-id MuiTableCell-head-id CategoryList-colProducts-id" scope="col" > - No. Products + No. of Products @@ -13338,7 +13334,7 @@ exports[`Storyshots Views / Categories / Create category When loading 1`] = ` class="MuiFormLabel-root-id MuiFormLabel-disabled-id MuiInputLabel-disabled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-outlined-id" data-shrink="false" > - Name + Category Name
- Description + Category Description
- Name + Category Name
- Description + Category Description
- Name + Category Name
- Description + Category Description
- Optional + (Optional)

@@ -15080,7 +15076,7 @@ Ctrl + K" class="MuiTableCell-root-id MuiTableCell-head-id CategoryList-colProducts-id" scope="col" > - No. Products + No. of Products @@ -15242,7 +15238,7 @@ exports[`Storyshots Views / Categories / Update category loading 1`] = ` class="MuiFormLabel-root-id MuiFormLabel-disabled-id MuiInputLabel-disabled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-outlined-id" data-shrink="false" > - Name + Category Name
- Description + Category Description
- No. Products + No. of Products @@ -15985,7 +15981,7 @@ exports[`Storyshots Views / Categories / Update category no background 1`] = ` class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - Name + Category Name
- Description + Category Description
- Optional + (Optional)

@@ -16817,7 +16813,7 @@ Ctrl + K" class="MuiTableCell-root-id MuiTableCell-head-id CategoryList-colProducts-id" scope="col" > - No. Products + No. of Products @@ -16974,7 +16970,7 @@ exports[`Storyshots Views / Categories / Update category no products 1`] = ` class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - Name + Category Name
- Description + Category Description
- Optional + (Optional)

@@ -17992,7 +17988,7 @@ exports[`Storyshots Views / Categories / Update category no subcategories 1`] = class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - Name + Category Name
- Description + Category Description
- Optional + (Optional)

@@ -18824,7 +18820,7 @@ Ctrl + K" class="MuiTableCell-root-id MuiTableCell-head-id CategoryList-colProducts-id" scope="col" > - No. Products + No. of Products @@ -18981,7 +18977,7 @@ exports[`Storyshots Views / Categories / Update category products 1`] = ` class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - Name + Category Name
- Description + Category Description
- Optional + (Optional)

@@ -20586,7 +20582,7 @@ exports[`Storyshots Views / Collections / Collection details default 1`] = ` - General information + General Informations
@@ -21310,7 +21306,7 @@ Ctrl + K"

- Optional + (Optional)

@@ -22033,7 +22029,7 @@ exports[`Storyshots Views / Collections / Collection details loading 1`] = ` - General information + General Informations
@@ -22447,7 +22443,7 @@ Ctrl + K" >
- General information + General Informations
@@ -23713,7 +23709,7 @@ Ctrl + K"

- Optional + (Optional)

@@ -24152,7 +24148,7 @@ exports[`Storyshots Views / Collections / Collection list default 1`] = ` class="MuiTableCell-root-id MuiTableCell-head-id CollectionList-colProducts-id" scope="col" > - No. Products + No. of Products - No. Products + No. of Products - General information + General Informations
@@ -25517,7 +25513,7 @@ exports[`Storyshots Views / Collections / Create collection loading 1`] = ` - General information + General Informations
@@ -26415,7 +26411,7 @@ exports[`Storyshots Views / Configuration default 1`] = `

- Manage how you ship out orders. + Manage how you ship out orders

@@ -27017,7 +27013,7 @@ exports[`Storyshots Views / Customers / Address Book default 1`] = `
- Tom Cooper Address Book + Tom Cooper's Address Book
- Delete + Remove
@@ -27282,7 +27278,7 @@ exports[`Storyshots Views / Customers / Address Book default 1`] = ` - Delete + Remove
@@ -27306,12 +27302,7 @@ exports[`Storyshots Views / Customers / Address Book loading 1`] = `
- - ‌ - + ...'s Address Book
- Delete + Remove
@@ -27637,7 +27628,7 @@ exports[`Storyshots Views / Customers / Create customer default 1`] = ` class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-outlined-id" data-shrink="false" > - Email address + E-mail Address
- First name + First Name
- Last name + Last Name
- Email address + E-mail Address
- First name + First Name
- Last name + Last Name
- Email address + E-mail Address
- First name + First Name
- Last name + Last Name
- General Information + General Informations @@ -29898,7 +29889,7 @@ exports[`Storyshots Views / Customers / Customer details default 1`] = ` class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - E-mail + E-mail Address
- General Information + General Informations @@ -30405,7 +30396,7 @@ exports[`Storyshots Views / Customers / Customer details different addresses 1`] class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - E-mail + E-mail Address
- General Information + General Informations @@ -30959,7 +30950,7 @@ exports[`Storyshots Views / Customers / Customer details form errors 1`] = ` class="MuiFormLabel-root-id MuiFormLabel-error-id MuiInputLabel-error-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - E-mail + E-mail Address
- General Information + General Informations - E-mail + E-mail Address
- General Information + General Informations @@ -31965,7 +31956,7 @@ exports[`Storyshots Views / Customers / Customer details never logged 1`] = ` class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - E-mail + E-mail Address
- General Information + General Informations @@ -32466,7 +32457,7 @@ exports[`Storyshots Views / Customers / Customer details never placed order 1`] class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - E-mail + E-mail Address
- General Information + General Informations @@ -32967,7 +32958,7 @@ exports[`Storyshots Views / Customers / Customer details no address at all 1`] = class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - E-mail + E-mail Address
- General Information + General Informations @@ -33449,7 +33440,7 @@ exports[`Storyshots Views / Customers / Customer details no default billing addr class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - E-mail + E-mail Address
- General Information + General Informations @@ -33956,7 +33947,7 @@ exports[`Storyshots Views / Customers / Customer details no default shipping add class="MuiFormLabel-root-id MuiFormLabel-filled-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id" data-shrink="true" > - E-mail + E-mail Address
- Add customer + Add customer - Add customer + Add customer - Add customer + Add customer - General Information + General Informations
- General Information + General Informations
- General Information + General Informations
- General Information + General Informations
- General Information + General Informations
- General Information + General Informations
- General Information + General Informations
- General Information + General Informations
- Product name + Product Name - Add sale + Add Sale
- Usage Limit + Usage Limit
- General Information + General Informations
- Usage Limit + Usage Limit
- General Information + General Informations
- Usage Limit + Usage Limit
- General Information + General Informations
- Usage Limit + Usage Limit
- General Information + General Informations
- Usage Limit + Usage Limit
- - 1 Orders - - are ready to fulfill + One order are ready to fulfill

- 1 Orders + One ordered

- - 1 Orders - - are ready to fulfill + One order are ready to fulfill

  • - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - Add Menu + Add Menu
    - Cancelled (1) + Fulfilled (1)

    @@ -51719,7 +51704,7 @@ exports[`Storyshots Views / Orders / Order details cancelled 1`] = `

    - Cancelled (1) + Fulfilled (1)

    @@ -65106,7 +65091,7 @@ exports[`Storyshots Views / Orders / Order draft default 1`] = ` - Order details + Order Details

    - Order details + Order Details
    - Order details + Order Details
    - Create order + Create order
    - General Information + General Informations
    - General Information + General Informations
    - Information + General Informations
    - Information + General Informations
    - Information + General Informations
    - Information + General Informations
    - Information + General Informations
    - Information + General Informations
    - Information + General Informations
    - Product types + Product Types
    - Product types + Product Types
    - General information + General Informations
    - General information + General Informations
    - General information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General information + General Informations
    - General information + General Informations
    - General information + General Informations
    - General information + General Informations
    - All photos + All Photos
    - All photos + All Photos
    - Add product + Add Product
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - General Information + General Informations
    - E-mail + E-mail Address
    - E-mail + E-mail Address
    - E-mail + E-mail Address
    - E-mail + E-mail Address
    - Staff members + Staff Members
    - Staff members + Staff Members
    = { +const homePageProps: Omit = { activities: shop.activities.edges.map(edge => edge.node), onOrdersToCaptureClick: () => undefined, onOrdersToFulfillClick: () => undefined, @@ -26,10 +26,10 @@ const HomePageProps: Omit = { storiesOf("Views / HomePage", module) .addDecorator(Decorator) - .add("default", () => ) + .add("default", () => ) .add("loading", () => ( )) .add("no data", () => ( - + ));