Skip to content

Commit 25b2948

Browse files
W 18998603 Route 'Order Status' 'footer link to a new Order Status Page (#2795)
* Initial empty commit for order-management-plugin * Order Status footer link routes to a new Order Status Page
1 parent c563f2d commit 25b2948

File tree

5 files changed

+92
-11
lines changed

5 files changed

+92
-11
lines changed

packages/template-retail-react-app/app/components/footer/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const Footer = ({...otherProps}) => {
104104
})}
105105
links={[
106106
{
107-
href: '/',
107+
href: '/order-status',
108108
text: intl.formatMessage({
109109
id: 'footer.link.order_status',
110110
defaultMessage: 'Order Status'

packages/template-retail-react-app/app/components/footer/index.test.js

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,56 @@
55
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import React from 'react'
8-
import {screen} from '@testing-library/react'
9-
8+
import {screen, within} from '@testing-library/react'
109
import Footer from '@salesforce/retail-react-app/app/components/footer/index'
1110
import {renderWithProviders} from '@salesforce/retail-react-app/app/utils/test-utils'
11+
import {useBreakpointValue} from '@chakra-ui/react'
1212

13-
test('renders component', () => {
14-
renderWithProviders(<Footer />)
15-
expect(screen.getByRole('link', {name: 'Privacy Policy'})).toBeInTheDocument()
16-
})
13+
// Mock the Chakra UI hook
14+
jest.mock('@chakra-ui/react', () => ({
15+
...jest.requireActual('@chakra-ui/react'),
16+
useBreakpointValue: jest.fn()
17+
}))
18+
19+
describe('Footer', () => {
20+
beforeEach(() => {
21+
jest.resetAllMocks()
22+
})
23+
24+
test('renders component', () => {
25+
renderWithProviders(<Footer />)
26+
expect(screen.getByRole('link', {name: 'Privacy Policy'})).toBeInTheDocument()
27+
})
28+
29+
test('renders mobile version by default', () => {
30+
renderWithProviders(<Footer />)
31+
// This link is hidden initially, but would be shown for desktop
32+
expect(screen.getByRole('link', {name: 'About Us', hidden: true})).toBeInTheDocument()
33+
})
34+
35+
test('renders desktop version (desktop links visible)', () => {
36+
// Mock for desktop view - force all content to be visible
37+
useBreakpointValue.mockImplementation(() => true)
38+
39+
renderWithProviders(<Footer />)
40+
41+
// Get footer element and search within it
42+
const footer = screen.getByRole('contentinfo')
43+
const orderStatusLink = within(footer).getByText('Order Status')
44+
45+
expect(orderStatusLink).toBeInTheDocument()
46+
expect(orderStatusLink).toHaveAttribute('href', '/uk/en-GB/order-status')
47+
expect(screen.getAllByText(/privacy policy/i)[0]).toBeInTheDocument()
48+
})
49+
50+
test('renders mobile version (only mobile links visible)', () => {
51+
// Mock for mobile view - hide desktop content
52+
useBreakpointValue.mockImplementation(() => false)
53+
54+
renderWithProviders(<Footer />)
1755

18-
test('renders mobile version by default', () => {
19-
renderWithProviders(<Footer />)
20-
// This link is hidden initially, but would be shown for desktop
21-
expect(screen.getByRole('link', {name: 'About Us', hidden: true})).toBeInTheDocument()
56+
// Verify desktop elements are hidden
57+
expect(screen.queryByRole('link', {name: /order status/i})).not.toBeInTheDocument()
58+
expect(screen.getAllByText(/privacy policy/i)[0]).toBeInTheDocument()
59+
})
2260
})
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2024, salesforce.com, inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
8+
import React from 'react'
9+
import {Box, Heading} from '@chakra-ui/react'
10+
11+
const OrderStatusPage = () => {
12+
return (
13+
<Box data-testid="order-status-page" minH="100vh" bg="gray.50" pt={24}>
14+
<Heading as="h1" size="lg" textAlign="center">
15+
Order Status
16+
</Heading>
17+
</Box>
18+
)
19+
}
20+
21+
export default OrderStatusPage
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2025, Salesforce, Inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
import React from 'react'
8+
import {render, screen} from '@testing-library/react'
9+
import OrderStatusPage from '@salesforce/retail-react-app/app/pages/order-status/index.jsx'
10+
11+
describe('OrderStatusPage', () => {
12+
it('renders the order status page', () => {
13+
render(<OrderStatusPage />)
14+
expect(screen.getByTestId('order-status-page')).toBeTruthy()
15+
expect(screen.getByRole('heading', {name: /order status/i})).toBeInTheDocument()
16+
})
17+
})

packages/template-retail-react-app/app/routes.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const StoreLocator = loadable(() => import('./pages/store-locator'), {
5454
const Wishlist = loadable(() => import('./pages/account/wishlist'), {
5555
fallback
5656
})
57+
const OrderStatus = loadable(() => import('./pages/order-status'), {fallback})
5758
const PageNotFound = loadable(() => import('./pages/page-not-found'))
5859

5960
export const routes = [
@@ -135,6 +136,10 @@ export const routes = [
135136
path: '/store-locator',
136137
component: StoreLocator
137138
},
139+
{
140+
path: '/order-status',
141+
component: OrderStatus
142+
},
138143
{
139144
path: '*',
140145
component: PageNotFound

0 commit comments

Comments
 (0)