Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions packages/extension-chakra-storefront/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = {
'<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/profile.test.js',
'<rootDir>/src/utils/responsive-image.test.js',
'<rootDir>/src/hooks/use-errors.test.js',
'<rootDir>/src/hooks/use-toast.test.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const ProfileFields = ({form, prefix = ''}) => {
})

return (
<Stack spacing={5} aria-label={intl.formatMessage(formTitleAriaLabel)}>
<SimpleGrid columns={[1, 1, 1, 2]} spacing={5}>
<Stack gap="5" aria-label={intl.formatMessage(formTitleAriaLabel)}>
<SimpleGrid columns={[1, 1, 1, 2]} gap="5">
<Field {...fields.firstName} />
<Field {...fields.lastName} />
</SimpleGrid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import Seo from '../../components/seo'
import Link from '../../components/link'
import {ChevronDownIcon, SignoutIcon} from '../../components/icons'
// import AccountDetail from '../../pages/account/profile'
import AccountDetail from '../../pages/account/profile'
import AccountAddresses from '../../pages/account/addresses'
import AccountOrders from '../../pages/account/orders'
// import AccountWishlist from '../../pages/account/wishlist/index'
Expand Down Expand Up @@ -218,9 +218,9 @@ const Account = () => {
</Flex>
</Stack>
<Switch>
{/*<Route exact path={path}>*/}
{/* <AccountDetail />*/}
{/*</Route>*/}
<Route exact path={path}>
<AccountDetail />
</Route>
{/*<Route exact path={`${path}/wishlist`}>*/}
{/* <AccountWishlist />*/}
{/*</Route>*/}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import useToast from '../../hooks/use-toast'
*/
// eslint-disable-next-line react/prop-types
const Skeleton = forwardRef(({children, height, width, ...rest}, ref) => {
const {data: customer} = useCurrentCustomer()
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be isPending. React query 5 has changed isLoading to isPending. TanStack/query#6297

const {data: customer, isPending} = useCurrentCustomer()
const {isRegistered} = customer
const size = !isRegistered
? {
Expand All @@ -50,7 +50,7 @@ const Skeleton = forwardRef(({children, height, width, ...rest}, ref) => {
}
: {}
return (
<ChakraSkeleton ref={ref} isLoaded={!customer.isLoading} {...rest} {...size}>
<ChakraSkeleton ref={ref} loading={isPending} {...rest} {...size}>
{children}
</ChakraSkeleton>
)
Expand Down Expand Up @@ -146,14 +146,18 @@ const ProfileCard = ({allowPasswordChange = false}) => {
<ToggleCardEdit>
<Container variant="form">
<form onSubmit={form.handleSubmit(submit)}>
<Stack spacing={6}>
<Stack gap="6">
{form.formState.errors?.global && (
<Alert status="error">
<AlertIcon color="red.500" boxSize={4} />
<Text fontSize="sm" ml={3}>
{form.formState.errors.global.message}
</Text>
</Alert>
<Alert.Root status="error">
<Alert.Indicator>
<AlertIcon color="red.500" boxSize="4" />
</Alert.Indicator>
<Alert.Content>
<Text fontSize="sm">
{form.formState.errors.global.message}
</Text>
</Alert.Content>
</Alert.Root>
)}
<ProfileFields form={form} />
<FormActionButtons
Expand All @@ -168,9 +172,9 @@ const ProfileCard = ({allowPasswordChange = false}) => {
</Container>
</ToggleCardEdit>
<ToggleCardSummary>
<SimpleGrid columns={{base: 1, lg: 3}} spacing={4}>
<SimpleGrid columns={{base: 1, lg: 3}} gap="4">
<Box>
<Skeleton height="21px" width="84px" marginBottom={2}>
<Skeleton height="21px" width="84px" marginBottom="2">
<Text fontSize="sm" fontWeight="bold">
<FormattedMessage
defaultMessage="Full Name"
Expand All @@ -186,7 +190,7 @@ const ProfileCard = ({allowPasswordChange = false}) => {
</Skeleton>
</Box>
<Box>
<Skeleton height="21px" width="120px" marginBottom={2}>
<Skeleton height="21px" width="120px" marginBottom="2">
<Text fontSize="sm" fontWeight="bold">
<FormattedMessage
defaultMessage="Email"
Expand All @@ -200,7 +204,7 @@ const ProfileCard = ({allowPasswordChange = false}) => {
</Skeleton>
</Box>
<Box>
<Skeleton height="21px" width="80px" marginBottom={2}>
<Skeleton height="21px" width="80px" marginBottom="2">
<Text fontSize="sm" fontWeight="bold">
<FormattedMessage
defaultMessage="Phone Number"
Expand Down Expand Up @@ -285,14 +289,18 @@ const PasswordCard = () => {
<ToggleCardEdit>
<Container variant="form">
<form onSubmit={form.handleSubmit(submit)}>
<Stack spacing={6}>
<Stack gap="6">
{form.formState.errors?.root?.global && (
<Alert data-testid="password-update-error" status="error">
<AlertIcon color="red.500" boxSize={4} />
<Text fontSize="sm" ml={3}>
{form.formState.errors.root.global.message}
</Text>
</Alert>
<Alert.Root data-testid="password-update-error" status="error">
<Alert.Indicator>
<AlertIcon color="red.500" boxSize="4" />
</Alert.Indicator>
<Alert.Content>
<Text fontSize="sm">
{form.formState.errors.root.global.message}
</Text>
</Alert.Content>
</Alert.Root>
)}
<UpdatePasswordFields form={form} />
<FormActionButtons
Expand All @@ -307,9 +315,9 @@ const PasswordCard = () => {
</Container>
</ToggleCardEdit>
<ToggleCardSummary>
<SimpleGrid columns={{base: 1, lg: 3}} spacing={4}>
<SimpleGrid columns={{base: 1, lg: 3}} gap="4">
<Box>
<Skeleton height="21px" width="84px" marginBottom={2}>
<Skeleton height="21px" width="84px" marginBottom="2">
<Text fontSize="sm" fontWeight="bold">
<FormattedMessage
defaultMessage="Password"
Expand Down Expand Up @@ -340,15 +348,15 @@ const AccountDetail = () => {
const {isExternal} = useCustomerType()

return (
<Stack data-testid="account-detail-page" spacing={6}>
<Stack data-testid="account-detail-page" gap="6">
<Heading as="h1" fontSize="24px" tabIndex="0" ref={headingRef}>
<FormattedMessage
defaultMessage="Account Details"
id="account_detail.title.account_details"
/>
</Heading>

<Stack spacing={4}>
<Stack gap="4">
<ProfileCard allowPasswordChange={!isExternal} />
{!isExternal && <PasswordCard />}
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ import {createPathWithDefaults, renderWithProviders} from '../../utils/test-util
import {rest} from 'msw'
import AccountDetail from '../../pages/account/profile'
import {mockedRegisteredCustomerWithNoNumber, mockedRegisteredCustomer} from '../../mocks/mock-data'
import Toaster, {toaster} from '../../components/toaster'

import {Route, Switch} from 'react-router-dom'
import mockConfig from '../../mock-config'
import * as sdk from '@salesforce/commerce-sdk-react'

const MockedComponent = () => {
return (
<Switch>
<Route path={createPathWithDefaults('/account')}>
<AccountDetail />
</Route>
</Switch>
<>
<Switch>
<Route path={createPathWithDefaults('/account')}>
<AccountDetail />
</Route>
</Switch>
<Toaster toaster={toaster} />
</>
)
}

Expand Down Expand Up @@ -78,10 +82,12 @@ test('Allows customer to edit phone number', async () => {
res(ctx.delay(0), ctx.status(200), ctx.json(mockedRegisteredCustomer))
)
)

await user.click(screen.getByText(/^Save$/i))

await waitFor(() => {
expect(screen.getByText(/Profile updated/i)).toBeInTheDocument()
// Toast messages are rendered in a portal, so we need to search within document.body
expect(within(document.body).getByText(/Profile updated/i)).toBeInTheDocument()
expect(screen.getByText(/555-1234/i)).toBeInTheDocument()
})
})
Expand Down
Loading