Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0fba8c8
Order history and order detail
alexvuong Jul 4, 2025
58a5946
minor adjustment
alexvuong Jul 4, 2025
5c11ae7
minor adjustment
alexvuong Jul 4, 2025
a753372
revert checkout
alexvuong Jul 4, 2025
78fd619
fix style
alexvuong Jul 4, 2025
e570c77
fix style
alexvuong Jul 4, 2025
9484e4c
fix style
alexvuong Jul 4, 2025
8fe2d25
Fix dnt modal
alexvuong Jul 4, 2025
3fd98c4
Fix dnt modal
alexvuong Jul 4, 2025
483bb8e
remove console
alexvuong Jul 4, 2025
94055f0
fix dnt
alexvuong Jul 4, 2025
9ce187a
Fix dnt tests
alexvuong Jul 4, 2025
4994899
fix header theme
alexvuong Jul 4, 2025
accded0
fix header behavior
alexvuong Jul 4, 2025
cc033c2
fix header behavior
alexvuong Jul 4, 2025
6b5d9ed
fix header behavior
alexvuong Jul 4, 2025
db3edec
use onClick on header
alexvuong Jul 8, 2025
b939c68
Merge branch 'feature/chakra-ui-upgrade-v3' into chakra-ui-order-history
alexvuong Jul 8, 2025
d2b105a
minor fix
alexvuong Jul 8, 2025
5251e1c
fix tests
alexvuong Jul 8, 2025
c34d898
fix tests
alexvuong Jul 8, 2025
74c405c
fix invalid props React warning
alexvuong Jul 8, 2025
90de11f
remove only
alexvuong Jul 8, 2025
4291e2f
enable account addresses
alexvuong Jul 8, 2025
10538d4
Merge branch 'feature/chakra-ui-upgrade-v3' into chakra-ui-order-history
alexvuong Jul 10, 2025
1ed07c5
PR feedback
alexvuong Jul 10, 2025
10ac07d
clean up
alexvuong Jul 10, 2025
6f1ba24
PR feedback
alexvuong Jul 10, 2025
2cd1e65
Merge branch 'feature/chakra-ui-upgrade-v3' into chakra-ui-order-history
alexvuong Jul 10, 2025
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
5 changes: 4 additions & 1 deletion packages/extension-chakra-storefront/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ module.exports = {
// createTestGlob('pages/registration'), // TODO: enable after Account page has been migrated
'<rootDir>/src/pages/checkout/partials/contact-info.test.js',
'<rootDir>/src/pages/checkout/partials/login-state.test.js',
'<rootDir>/src/pages/account/orders.test.js',
'<rootDir>/src/pages/account/orders-history.test.js',
'<rootDir>/src/utils/responsive-image.test.js',
'<rootDir>/src/hooks/use-toast.test.js',
'<rootDir>/src/pages/product-detail/metadata.test.js',
'<rootDir>/src/pages/product-list/metadata.test.js',
'<rootDir>/src/hooks/use-toast.test.js'
'<rootDir>/src/hooks/use-toast.test.js',
'<rootDir>/src/hooks/use-dnt-notification.test.js'
// '<rootDir>/src/hooks/use-auth-modal.test.js' // TODO: enable after Account page has been migrated
],
moduleNameMapper: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const Field = ({
const _inputProps =
typeof inputProps === 'function' ? inputProps({value, onChange}) : inputProps

const {endElement, ...restOfInputProps} = _inputProps || {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will address the warning.

console.error
    Warning: React does not recognize the `endElement` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `endelement` instead. If you accidentally passed it from a parent component, remove it from the DOM element.


return (
<ChakraField.Root id={name} invalid={!!error}>
{!['checkbox', 'radio', 'hidden'].includes(type) &&
Expand All @@ -77,7 +79,7 @@ const Field = ({
<PasswordIcon color="gray.500" boxSize={6} />
</IconButton>
) : (
_inputProps?.endElement
endElement
)
}
>
Expand All @@ -92,7 +94,7 @@ const Field = ({
type={inputType}
placeholder={placeholder}
autoComplete={autoComplete}
{..._inputProps}
{...restOfInputProps}
/>
{children}
</>
Expand Down
220 changes: 86 additions & 134 deletions packages/extension-chakra-storefront/src/components/header/index.jsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ test('renders Header with event handlers', async () => {
})
const menu = screen.getByLabelText('Menu')
const logo = screen.getByLabelText('Logo')
const account = screen.getByLabelText(/Open account menu/i)
const account = screen.getByLabelText(/My Account/i)
const cart = screen.getByLabelText(/My cart, number of items: 2/)

await act(async () => {
fireEvent.click(menu)
})
Expand All @@ -121,13 +120,7 @@ test('renders Header with event handlers', async () => {
expect(onMyCartClick).toHaveBeenCalledTimes(1)

await act(async () => {
fireEvent.mouseEnter(account)
})
// The onClick handler is on the AccountIcon inside the button,
// so we need to find and click that
const accountIcon = account.querySelector('svg[aria-label="account"]')
await act(async () => {
fireEvent.click(accountIcon)
fireEvent.click(account)
})
expect(onMyAccountClick).toHaveBeenCalledTimes(1)
})
Expand Down Expand Up @@ -174,34 +167,18 @@ test('renders cart badge when basket is loaded', async () => {
test('route to account page when an authenticated users click on account icon', async () => {
const history = createMemoryHistory()
history.push = jest.fn()
renderWithProviders(<MockedComponent history={history} />)
const {user} = renderWithProviders(<MockedComponent history={history} />)

await waitFor(() => {
// Look for account button
const accountTrigger = screen.getByLabelText(/Open account menu/)
const accountTrigger = screen.getByLabelText(/My account/)
expect(accountTrigger).toBeInTheDocument()
})

const accountButton = screen.getByLabelText(/Open account menu/)

await act(async () => {
// Use mouseEnter to open the popover, then click on the AccountIcon inside
fireEvent.mouseEnter(accountButton)
})

// The onClick handler is on the AccountIcon inside the button,
// so we need to find and click that
const accountIcon = accountButton.querySelector('svg[aria-label="account"]')
await act(async () => {
fireEvent.click(accountIcon)
})
await waitFor(() => {
expect(history.push).toHaveBeenCalledWith(createPathWithDefaults('/account'))
})
const accountButton = screen.getByLabelText(/My account/)

// Test keyDown on the AccountIcon
await act(async () => {
fireEvent.keyDown(accountIcon, {key: 'Enter', code: 'Enter'})
await user.click(accountButton)
})
await waitFor(() => {
expect(history.push).toHaveBeenCalledWith(createPathWithDefaults('/account'))
Expand All @@ -228,41 +205,3 @@ test('route to wishlist page when an authenticated users click on wishlist icon'
expect(history.push).toHaveBeenCalledWith(createPathWithDefaults('/account/wishlist'))
})
})

test('shows dropdown menu when an authenticated users hover on the account icon', async () => {
global.server.use(
rest.post('*/customers/action/login', (req, res, ctx) => {
return res(ctx.delay(0), ctx.status(200), ctx.json(mockedRegisteredCustomer))
})
)
const history = createMemoryHistory()
history.push = jest.fn()

await act(async () => {
renderWithProviders(<MockedComponent history={history} />)
})

await waitFor(() => {
// Look for account button
const accountTrigger = screen.getByLabelText(/Open account menu/i)
expect(accountTrigger).toBeInTheDocument()
})

const accountButton = screen.getByLabelText(/Open account menu/i)

// Use mouseEnter to open the popover/dropdown
await act(async () => {
fireEvent.mouseEnter(accountButton)
})

// Now check that the dropdown menu items are visible
await waitFor(() => {
expect(screen.getByText(/account details/i)).toBeInTheDocument()
expect(screen.getByText(/addresses/i)).toBeInTheDocument()
expect(screen.getByText(/wishlist/i)).toBeInTheDocument()
expect(screen.getByText(/order history/i)).toBeInTheDocument()
const logOutIcon = screen.getByLabelText('signout')
expect(logOutIcon).toBeInTheDocument()
expect(logOutIcon).toHaveAttribute('aria-hidden', 'true')
})
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a typo, it should be colorPalette="red"

Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const CartItems = ({basket}) => {
</Box>
<Accordion.ItemIndicator />
</Accordion.ItemTrigger>
<Accordion.ItemContent px={0} py={4}>
<Stack gap={5} align="flex-start" separator={<Separator />}>
<Accordion.ItemContent px="0" py="4">
<Stack gap="5" alignItems="flex-start" separator={<Separator w="full" />}>
{basket.productItems?.map((product, idx) => {
const variant = {
...product,
Expand All @@ -72,8 +72,8 @@ const CartItems = ({basket}) => {
variant={variant}
>
<Flex width="full" alignItems="flex-start">
<CartItemVariantImage width="80px" mr={2} />
<Stack width="full" gap={1} marginTop="-3px">
<CartItemVariantImage width="80px" mr="2" />
<Stack width="full" gap="1" marginTop="-3px">
<CartItemVariantName />
<CartItemVariantAttributes includeQuantity />
<CartItemVariantPrice
Expand All @@ -86,11 +86,13 @@ const CartItems = ({basket}) => {
)
})}

<Button as={Link} to="/cart" variant="link-blue" width="full">
<FormattedMessage
defaultMessage="Edit cart"
id="order_summary.cart_items.link.edit_cart"
/>
<Button asChild to="/cart" variant="link-blue" width="full">
<Link>
<FormattedMessage
defaultMessage="Edit cart"
id="order_summary.cart_items.link.edit_cart"
/>
</Link>
</Button>
</Stack>
</Accordion.ItemContent>
Expand Down Expand Up @@ -119,17 +121,15 @@ const OrderSummary = ({
const hasShippingPromos = shippingItem?.priceAdjustments?.length > 0

return (
<Stack data-testid="sf-order-summary" gap={5}>
<Heading fontSize={fontSize} pt={1} id="order-summary-heading">
<Stack data-testid="sf-order-summary" gap="5">
<Heading fontSize={fontSize} pt="1" id="order-summary-heading">
<FormattedMessage
defaultMessage="Order Summary"
id="order_summary.heading.order_summary"
/>
</Heading>

<Stack gap={4} align="flex-start" role="region" aria-labelledby="order-summary-heading">
<Stack gap="4" align="flex-start" role="region" aria-labelledby="order-summary-heading">
{showCartItems && <CartItems basket={basket} />}

<Stack w="full">
<Flex justifyContent="space-between" aria-live="polite" aria-atomic="true">
<Text fontWeight="bold" fontSize={fontSize}>
Expand Down Expand Up @@ -246,10 +246,9 @@ const OrderSummary = ({
<PromoCode {...promoCodeProps} />
</Box>
) : (
<Separator />
<Separator w="full" />
)}

<Stack gap={4} w="full">
<Stack gap="4" w="full">
<Flex
w="full"
justifyContent="space-between"
Expand Down Expand Up @@ -282,7 +281,7 @@ const OrderSummary = ({

{basket.couponItems?.length > 0 && (
<Stack
p={4}
p="4"
border="1px solid"
borderColor="gray.100"
borderRadius="base"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Section = ({title, subtitle, actions, maxWidth, children, ...props}) => {
<Box as="section" paddingBottom="16" {...props}>
<Stack gap={6} as={Container} maxW={sectionMaxWidth} textAlign="center">
{title && (
<Heading as="h2" fontSize={40} textAlign="center" fontWeight="bold">
<Heading as="h2" fontSize={40} textAlign="center">
{title}
</Heading>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
Flex,
Heading,
Spinner,

//hooks
useDisclosure,
useSlotRecipe,
useToken
Expand Down Expand Up @@ -55,7 +57,7 @@ import {useExtensionConfig, useCurrentCustomer, useCurrentBasket} from '../../ho
import {watchOnlineStatus, flatten} from '../../utils/utils'
import useActiveData from '../../hooks/use-active-data'
import useMultiSite from '../../hooks/use-multi-site'
// import {DntNotification, useDntNotification} from '../../hooks/use-dnt-notification'
import {DntNotification, useDntNotification} from '../../hooks/use-dnt-notification'

import {UserConfig} from '../../types/config'

Expand Down Expand Up @@ -118,13 +120,17 @@ const withLayout = <P extends object>(WrappedComponent: React.ComponentType<P>)
const history = useHistory()
const location = useLocation()
const authModal = useAuthModal()
// const dntNotification = useDntNotification()
const dntNotification = useDntNotification()
const {site, locale, buildUrl} = useMultiSite()
const [isOnline, setIsOnline] = useState<boolean>(true)

// https://www.chakra-ui.com/docs/theming/overview#tokens-1
const [themeColor] = useToken('colors.blue', '600')
const {open, onOpen, onClose} = useDisclosure()
const {
open: isDrawerMenuOpen,
onOpen: onDrawerMenuOpen,
onClose: onDrawerMenuClose
} = useDisclosure()

// Used to conditionally render header/footer for checkout page
const isCheckout = /\/checkout$/.test(location?.pathname)
Expand Down Expand Up @@ -179,7 +185,7 @@ const withLayout = <P extends object>(WrappedComponent: React.ComponentType<P>)
useEffect(() => {
// Lets automatically close the mobile navigation when the
// location path is changed.
onClose()
onDrawerMenuClose()
}, [location])

const onLogoClick = () => {
Expand All @@ -191,15 +197,15 @@ const withLayout = <P extends object>(WrappedComponent: React.ComponentType<P>)
history.push(path)

// Close the drawer.
onClose()
onDrawerMenuClose()
}

const onCartClick = () => {
const path = buildUrl('/cart', site.id, locale.id)
history.push(path)

// Close the drawer.
onClose()
onDrawerMenuClose()
}

const onAccountClick = () => {
Expand Down Expand Up @@ -283,7 +289,7 @@ const withLayout = <P extends object>(WrappedComponent: React.ComponentType<P>)
<>
<AboveHeader />
<Header
onMenuClick={onOpen}
onMenuClick={onDrawerMenuOpen}
onLogoClick={onLogoClick}
onMyCartClick={onCartClick}
onMyAccountClick={onAccountClick}
Expand All @@ -292,8 +298,8 @@ const withLayout = <P extends object>(WrappedComponent: React.ComponentType<P>)
{/* TODO: mobile menu */}
<HideOnDesktop>
<DrawerMenu
isOpen={open}
onClose={onClose}
isOpen={isDrawerMenuOpen}
onClose={onDrawerMenuClose}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open and onClose were set above so I think this part can remain unchanged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the name to make it clearer since we have a lot open/close state on the _app config.

onLogoClick={onLogoClick}
root={categories?.[CAT_MENU_DEFAULT_ROOT_CATEGORY]}
itemsKey="categories"
Expand Down Expand Up @@ -343,7 +349,7 @@ const withLayout = <P extends object>(WrappedComponent: React.ComponentType<P>)

{!isCheckout ? <Footer /> : <CheckoutFooter />}
<AuthModal {...(authModal as any)} />
{/*<DntNotification {...dntNotification} />*/}
<DntNotification {...dntNotification} />
</AddToCartModalProvider>
</Box>
{(config.activeDataEnabled as boolean) && (
Expand Down
Loading
Loading