Fix snapshot testing
This commit is contained in:
parent
94c0833766
commit
cb16d68060
11 changed files with 346 additions and 366 deletions
34
.babelrc
34
.babelrc
|
@ -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"]
|
|
||||||
}
|
|
42
babel.config.js
Normal file
42
babel.config.js
Normal file
|
@ -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
|
||||||
|
};
|
||||||
|
};
|
13
package-lock.json
generated
13
package-lock.json
generated
|
@ -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": {
|
"ts-node": {
|
||||||
"version": "8.3.0",
|
"version": "8.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.3.0.tgz",
|
||||||
|
|
|
@ -139,13 +139,8 @@
|
||||||
"fsevents": "^1.2.9"
|
"fsevents": "^1.2.9"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"globals": {
|
|
||||||
"ts-jest": {
|
|
||||||
"tsConfig": "tsconfig.json"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"transform": {
|
"transform": {
|
||||||
"^.+\\.tsx?$": "ts-jest",
|
"^.+\\.(jsx?|tsx?)$": "babel-jest",
|
||||||
"^.+\\.(png|svg|jpe?g)$": "jest-file"
|
"^.+\\.(png|svg|jpe?g)$": "jest-file"
|
||||||
},
|
},
|
||||||
"testRegex": ".*\\.test\\.tsx?$",
|
"testRegex": ".*\\.test\\.tsx?$",
|
||||||
|
|
|
@ -91,10 +91,15 @@ const CollectionProducts = withStyles(styles, { name: "CollectionProducts" })(
|
||||||
<CardTitle
|
<CardTitle
|
||||||
title={
|
title={
|
||||||
!!collection ? (
|
!!collection ? (
|
||||||
intl.formatMessage({
|
intl.formatMessage(
|
||||||
defaultMessage: "Products in {name}",
|
{
|
||||||
description: "products in collection"
|
defaultMessage: "Products in {name}",
|
||||||
})
|
description: "products in collection"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: maybe(() => collection.name, "...")
|
||||||
|
}
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<Skeleton />
|
<Skeleton />
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import TableRow from "@material-ui/core/TableRow";
|
||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight";
|
import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
|
||||||
import Skeleton from "@saleor/components/Skeleton";
|
import Skeleton from "@saleor/components/Skeleton";
|
||||||
|
|
||||||
|
@ -46,108 +46,104 @@ const HomeNotificationTable = withStyles(styles, {
|
||||||
ordersToCapture,
|
ordersToCapture,
|
||||||
ordersToFulfill,
|
ordersToFulfill,
|
||||||
productsOutOfStock
|
productsOutOfStock
|
||||||
}: HomeNotificationTableProps) => {
|
}: HomeNotificationTableProps) => (
|
||||||
const intl = useIntl();
|
<Card>
|
||||||
|
<Table>
|
||||||
return (
|
<TableBody className={classes.tableRow}>
|
||||||
<Card>
|
<TableRow hover={true} onClick={onOrdersToFulfillClick}>
|
||||||
<Table>
|
<TableCell>
|
||||||
<TableBody className={classes.tableRow}>
|
{ordersToFulfill === undefined ? (
|
||||||
<TableRow hover={true} onClick={onOrdersToFulfillClick}>
|
<Skeleton />
|
||||||
<TableCell>
|
) : ordersToFulfill === 0 ? (
|
||||||
{ordersToFulfill === undefined ? (
|
<Typography>
|
||||||
<Skeleton />
|
<FormattedMessage
|
||||||
) : ordersToFulfill === 0 ? (
|
defaultMessage="No orders ready to fulfill"
|
||||||
<Typography>
|
id="homeNotificationTableNoOrders"
|
||||||
<FormattedMessage
|
/>
|
||||||
defaultMessage="No orders ready to fulfill"
|
</Typography>
|
||||||
id="homeNotificationTableNoOrders"
|
) : (
|
||||||
/>
|
<Typography>
|
||||||
</Typography>
|
<FormattedMessage
|
||||||
) : (
|
defaultMessage="{amount, plural,
|
||||||
<Typography>
|
one {One order}
|
||||||
<FormattedMessage
|
other {{amount} Orders}
|
||||||
defaultMessage="{amount, plural,
|
} are ready to fulfill"
|
||||||
one {One order}
|
id="homeNotificationTableOrders"
|
||||||
other {{amount} Orders}
|
values={{
|
||||||
} are ready to fulfill"
|
amount: ordersToFulfill
|
||||||
id="homeNotificationTableOrders"
|
}}
|
||||||
values={{
|
/>
|
||||||
amount: ordersToFulfill
|
</Typography>
|
||||||
}}
|
)}
|
||||||
/>
|
</TableCell>
|
||||||
</Typography>
|
<TableCell className={classes.arrowIcon}>
|
||||||
)}
|
<KeyboardArrowRight />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.arrowIcon}>
|
</TableRow>
|
||||||
<KeyboardArrowRight />
|
<TableRow hover={true} onClick={onOrdersToCaptureClick}>
|
||||||
</TableCell>
|
<TableCell>
|
||||||
</TableRow>
|
{ordersToCapture === undefined ? (
|
||||||
<TableRow hover={true} onClick={onOrdersToCaptureClick}>
|
<Skeleton />
|
||||||
<TableCell>
|
) : ordersToCapture === 0 ? (
|
||||||
{ordersToCapture === undefined ? (
|
<Typography>
|
||||||
<Skeleton />
|
<FormattedMessage
|
||||||
) : ordersToCapture === 0 ? (
|
defaultMessage="No payments waiting for capture"
|
||||||
<Typography>
|
id="homeNotificationsNoPayments"
|
||||||
<FormattedMessage
|
/>
|
||||||
defaultMessage="No payments waiting for capture"
|
</Typography>
|
||||||
id="homeNotificationsNoPayments"
|
) : (
|
||||||
/>
|
<Typography>
|
||||||
</Typography>
|
<FormattedMessage
|
||||||
) : (
|
defaultMessage="{amount, plural,
|
||||||
<Typography>
|
one {One payment}
|
||||||
<FormattedMessage
|
other {{amount} Payments}
|
||||||
defaultMessage="{amount, plural,
|
} to capture"
|
||||||
one {One payment}
|
id="homeNotificationTablePayments"
|
||||||
other {{amount} Payments}
|
values={{
|
||||||
} to capture"
|
amount: ordersToCapture
|
||||||
id="homeNotificationTablePayments"
|
}}
|
||||||
values={{
|
/>
|
||||||
amount: ordersToCapture
|
</Typography>
|
||||||
}}
|
)}
|
||||||
/>
|
</TableCell>
|
||||||
</Typography>
|
<TableCell className={classes.arrowIcon}>
|
||||||
)}
|
<KeyboardArrowRight />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.arrowIcon}>
|
</TableRow>
|
||||||
<KeyboardArrowRight />
|
<TableRow hover={true} onClick={onProductsOutOfStockClick}>
|
||||||
</TableCell>
|
<TableCell>
|
||||||
</TableRow>
|
{productsOutOfStock === undefined ? (
|
||||||
<TableRow hover={true} onClick={onProductsOutOfStockClick}>
|
<Skeleton />
|
||||||
<TableCell>
|
) : productsOutOfStock === 0 ? (
|
||||||
{productsOutOfStock === undefined ? (
|
<Typography>
|
||||||
<Skeleton />
|
<FormattedMessage
|
||||||
) : productsOutOfStock === 0 ? (
|
defaultMessage="No products out of stock"
|
||||||
<Typography>
|
id="homeNotificationsTableNoProducts"
|
||||||
<FormattedMessage
|
/>
|
||||||
defaultMessage="No products out of stock"
|
</Typography>
|
||||||
id="homeNotificationsTableNoProducts"
|
) : (
|
||||||
/>
|
<Typography>
|
||||||
</Typography>
|
<FormattedMessage
|
||||||
) : (
|
defaultMessage="{amount, plural,
|
||||||
<Typography>
|
one {One product}
|
||||||
<FormattedMessage
|
other {{amount} Products}
|
||||||
defaultMessage="{amount, plural,
|
} out of stock"
|
||||||
one {One product}
|
id="homeNotificationTableProducts"
|
||||||
other {{amount} Products}
|
values={{
|
||||||
} out of stock"
|
amount: productsOutOfStock
|
||||||
id="homeNotificationTableProducts"
|
}}
|
||||||
values={{
|
/>
|
||||||
amount: productsOutOfStock
|
</Typography>
|
||||||
}}
|
)}
|
||||||
/>
|
</TableCell>
|
||||||
</Typography>
|
<TableCell className={classes.arrowIcon}>
|
||||||
)}
|
<KeyboardArrowRight />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.arrowIcon}>
|
</TableRow>
|
||||||
<KeyboardArrowRight />
|
</TableBody>
|
||||||
</TableCell>
|
</Table>
|
||||||
</TableRow>
|
</Card>
|
||||||
</TableBody>
|
)
|
||||||
</Table>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
HomeNotificationTable.displayName = "HomeNotificationTable";
|
HomeNotificationTable.displayName = "HomeNotificationTable";
|
||||||
export default HomeNotificationTable;
|
export default HomeNotificationTable;
|
||||||
|
|
|
@ -86,8 +86,8 @@ const OrderFulfillment = withStyles(styles, { name: "OrderFulfillment" })(
|
||||||
const lines = maybe(() => fulfillment.lines);
|
const lines = maybe(() => fulfillment.lines);
|
||||||
const status = maybe(() => fulfillment.status);
|
const status = maybe(() => fulfillment.status);
|
||||||
const quantity = lines
|
const quantity = lines
|
||||||
.map(line => line.quantity)
|
? lines.map(line => line.quantity).reduce((prev, curr) => prev + curr, 0)
|
||||||
.reduce((prev, curr) => prev + curr, 0);
|
: "...";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import CardContent from "@material-ui/core/CardContent";
|
||||||
import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
|
import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
|
||||||
import TextField from "@material-ui/core/TextField";
|
import TextField from "@material-ui/core/TextField";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
import CardTitle from "@saleor/components/CardTitle";
|
import CardTitle from "@saleor/components/CardTitle";
|
||||||
import FormSpacer from "@saleor/components/FormSpacer";
|
import FormSpacer from "@saleor/components/FormSpacer";
|
||||||
|
|
|
@ -263,6 +263,10 @@ export const ProductUpdatePage: React.FC<ProductUpdatePageProps> = ({
|
||||||
loading={disabled}
|
loading={disabled}
|
||||||
onClick={onSeoClick}
|
onClick={onSeoClick}
|
||||||
onChange={change}
|
onChange={change}
|
||||||
|
helperText={intl.formatMessage({
|
||||||
|
defaultMessage:
|
||||||
|
"Add search engine title and description to make this product easier to find"
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -9,7 +9,7 @@ import Decorator from "../../Decorator";
|
||||||
|
|
||||||
const shop = shopFixture(placeholderImage);
|
const shop = shopFixture(placeholderImage);
|
||||||
|
|
||||||
const HomePageProps: Omit<HomePageProps, "classes"> = {
|
const homePageProps: Omit<HomePageProps, "classes"> = {
|
||||||
activities: shop.activities.edges.map(edge => edge.node),
|
activities: shop.activities.edges.map(edge => edge.node),
|
||||||
onOrdersToCaptureClick: () => undefined,
|
onOrdersToCaptureClick: () => undefined,
|
||||||
onOrdersToFulfillClick: () => undefined,
|
onOrdersToFulfillClick: () => undefined,
|
||||||
|
@ -26,10 +26,10 @@ const HomePageProps: Omit<HomePageProps, "classes"> = {
|
||||||
|
|
||||||
storiesOf("Views / HomePage", module)
|
storiesOf("Views / HomePage", module)
|
||||||
.addDecorator(Decorator)
|
.addDecorator(Decorator)
|
||||||
.add("default", () => <HomePage {...HomePageProps} />)
|
.add("default", () => <HomePage {...homePageProps} />)
|
||||||
.add("loading", () => (
|
.add("loading", () => (
|
||||||
<HomePage
|
<HomePage
|
||||||
{...HomePageProps}
|
{...homePageProps}
|
||||||
activities={undefined}
|
activities={undefined}
|
||||||
orders={undefined}
|
orders={undefined}
|
||||||
ordersToCapture={undefined}
|
ordersToCapture={undefined}
|
||||||
|
@ -41,5 +41,5 @@ storiesOf("Views / HomePage", module)
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
.add("no data", () => (
|
.add("no data", () => (
|
||||||
<HomePage {...HomePageProps} topProducts={[]} activities={[]} />
|
<HomePage {...homePageProps} topProducts={[]} activities={[]} />
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in a new issue