Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PWA-2227] Use sample data with personalized content #3670

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e0b7ae2
PWA-2163 Create DynamicBlock component + Create config for PageBuilde…
Nov 29, 2021
d3f92f1
PWA-2169 Make feature EE only + Refetch data if user signs in + Updat…
Nov 30, 2021
8fab7de
Merge remote-tracking branch 'origin/develop' into mikhaelbois/PWA-21…
Nov 30, 2021
7a6ec15
PWA-2169 Fix GraphQl call
Nov 30, 2021
fc92e2b
PWA-2169 Fix lint error
Nov 30, 2021
19cbff2
Merge remote-tracking branch 'origin/develop' into mikhaelbois/PWA-21…
Dec 1, 2021
b18c78a
Merge remote-tracking branch 'origin/develop' into mikhaelbois/PWA-21…
Dec 3, 2021
65a9dff
PWA-2169 Clean snapshots
Dec 3, 2021
b5b3d2f
PWA-2169 Fix file name issue
Dec 3, 2021
daac452
PWA-2169 Avoid loading broken block
Dec 6, 2021
9d7b398
PWA-2169 Update Cypress test
Dec 6, 2021
c4a2e22
PWA-2169 Avoid rendering component if no uids is provided
Dec 6, 2021
550eb8a
Merge remote-tracking branch 'origin/develop' into mikhaelbois/PWA-21…
Dec 6, 2021
bbbb288
Merge branch 'mikhaelbois/PWA-2169-dynamic-blocks' into jcharron/PWA-…
Dec 15, 2021
7fdf613
Merge branch 'develop' into jcharron/PWA-2227-use-sample-data-with-pe…
Dec 15, 2021
185b9af
Merge remote-tracking branch 'origin/develop' into mikhaelbois/PWA-21…
Dec 16, 2021
53bc6ed
PWA-2169 Fix cache clear + Add dynamic blocks in customer cache clear…
Dec 17, 2021
4342dfb
Merge branch 'mikhaelbois/PWA-2169-dynamic-blocks' into jcharron/PWA-…
Dec 17, 2021
3026a33
PWA-2227 Edit homepage styling for dynamic blocks
Dec 22, 2021
c6c04aa
PWA-2227 Add label from discount data in price summary of cart
Jan 4, 2022
5b61515
Merged develop into PWA-2227
Jan 27, 2022
6c8e6f6
PWA-2227 Yarn Prettier for test
Jan 27, 2022
951d61e
Merge branch 'develop' into jcharron/PWA-2227-use-sample-data-with-pe…
michaelyu0123 Jan 31, 2022
784ad75
Merge branch 'develop' into jcharron/PWA-2227-use-sample-data-with-pe…
Feb 7, 2022
77f24e3
Merge branch 'develop' into jcharron/PWA-2227-use-sample-data-with-pe…
Feb 16, 2022
135bec2
Merge branch 'develop' into jcharron/PWA-2227-use-sample-data-with-pe…
Feb 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders "Discount applied" label if label data is empty 1`] = `
Array [
<span
className="lineItemLabel"
>
Discounts applied
</span>,
<span
className="price"
>
-
<span>
$
</span>
<span>
1
</span>
<span>
.
</span>
<span>
00
</span>
</span>,
]
`;

exports[`renders accumulated discount value 1`] = `
Array [
<span
className="lineItemLabel"
>
<mock-FormattedMessage
defaultMessage="Discounts applied"
id="discountSummary.lineItemLabel"
/>
Discounts applied
</span>,
<span
className="price"
Expand All @@ -30,15 +54,39 @@ Array [
]
`;

exports[`renders discount label value from data 1`] = `
Array [
<span
className="lineItemLabel"
>
Rebate
</span>,
<span
className="price"
>
-
<span>
$
</span>
<span>
1
</span>
<span>
.
</span>
<span>
00
</span>
</span>,
]
`;

exports[`renders discount summary line item correctly 1`] = `
Array [
<span
className="lineItemLabel"
>
<mock-FormattedMessage
defaultMessage="Discounts applied"
id="discountSummary.lineItemLabel"
/>
Special rebate
</span>,
<span
className="price"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const defaultProps = {
amount: {
value: 10,
currency: 'USD'
}
},
label: 'Special rebate'
}
]
};
Expand Down Expand Up @@ -82,3 +83,38 @@ test('renders nothing if discount value is "0"', () => {

expect(tree.toJSON()).toMatchSnapshot();
});

test('renders discount label value from data ', () => {
const props = {
...defaultProps,
data: [
{
amount: {
value: 1,
currency: 'USD'
},
label: 'Rebate'
}
]
};
const tree = createTestInstance(<DiscountSummary {...props} />);

expect(tree.toJSON()).toMatchSnapshot();
});

test('renders "Discount applied" label if label data is empty', () => {
const props = {
...defaultProps,
data: [
{
amount: {
value: 1,
currency: 'USD'
}
}
]
};
const tree = createTestInstance(<DiscountSummary {...props} />);

expect(tree.toJSON()).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Fragment } from 'react';
import { FormattedMessage } from 'react-intl';
import { useIntl } from 'react-intl';
import Price from '@magento/venia-ui/lib/components/Price';

import { useStyle } from '../../../classify';
Expand All @@ -22,6 +22,7 @@ const getDiscount = (discounts = []) => {
return DEFAULT_AMOUNT;
} else {
return {
label: discounts[0].label,
currency: discounts[0].amount.currency,
value: discounts.reduce(
(acc, discount) => acc + discount.amount.value,
Expand All @@ -40,17 +41,22 @@ const getDiscount = (discounts = []) => {
const DiscountSummary = props => {
const classes = useStyle({}, props.classes);
const discount = getDiscount(props.data);
const { formatMessage } = useIntl();

const label = discount.label
? discount.label
: formatMessage({
id: 'discountSummary.lineItemLabel',
defaultMessage: 'Discounts applied'
});
michaelyu0123 marked this conversation as resolved.
Show resolved Hide resolved

return discount.value ? (
<Fragment>
<span
className={classes.lineItemLabel}
data-cy="PriceSummary-DiscountSummary-label"
>
<FormattedMessage
id={'discountSummary.lineItemLabel'}
defaultMessage={'Discounts applied'}
/>
{label}
</span>
<span
data-cy="DiscountSummary-discountValue"
Expand Down
12 changes: 12 additions & 0 deletions packages/venia-ui/lib/components/HomePage/homePage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,15 @@
:global(.venia-home-products .slick-slider .slick-dots .slick-active > button) {
background-color: hsl(205 004% 048%) !important;
}

:global(.venia-home-banner-text > div) {
flex-direction: unset !important;
justify-content: normal !important;
}

@media (max-width: 960px) {
:global(.venia-home-banner-text > div) {
flex-direction: column !important;
justify-content: center !important;
}
}
michaelyu0123 marked this conversation as resolved.
Show resolved Hide resolved