Skip to content

Commit 1814eb7

Browse files
committed
remove redundancy
1 parent c5bc7a2 commit 1814eb7

File tree

3 files changed

+3
-28
lines changed

3 files changed

+3
-28
lines changed

packages/template-retail-react-app/app/components/cancel-order-modal/index.test.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,25 @@ afterEach(() => {
4242

4343
test('renders cancel order modal when open', async () => {
4444
renderWithProviders(<CancelOrderModal isOpen={true} onClose={jest.fn()} order={mockOrder} />)
45-
46-
// Check modal content
4745
expect(screen.getByRole('dialog')).toBeInTheDocument()
4846
expect(screen.getAllByText(/request cancellation/i)).toHaveLength(2)
4947
})
5048

5149
test('does not render modal when closed', () => {
5250
renderWithProviders(<MockedComponent order={mockOrder} />)
53-
54-
// Modal should not be visible initially
5551
expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
5652
expect(screen.queryByText(/request cancellation/i)).not.toBeInTheDocument()
5753
})
5854

5955
test('renders modal with correct header text', async () => {
6056
renderWithProviders(<CancelOrderModal isOpen={true} onClose={jest.fn()} order={mockOrder} />)
61-
62-
// Check header text specifically - look for the modal header within the dialog
6357
const dialog = screen.getByRole('dialog')
6458
expect(dialog).toBeInTheDocument()
65-
expect(screen.getAllByText(/request cancellation/i)).toHaveLength(2) // Header and button
59+
expect(screen.getAllByText(/request cancellation/i)).toHaveLength(2)
6660
})
6761

6862
test('renders modal with correct body content', async () => {
6963
const user = userEvent.setup()
70-
7164
renderWithProviders(<MockedComponent order={mockOrder} />)
7265

7366
// Open the modal
@@ -80,7 +73,6 @@ test('renders modal with correct body content', async () => {
8073

8174
test('renders request cancellation button', async () => {
8275
const user = userEvent.setup()
83-
8476
renderWithProviders(<MockedComponent order={mockOrder} />)
8577

8678
// Open the modal
@@ -94,25 +86,23 @@ test('renders request cancellation button', async () => {
9486

9587
test('renders close button (X)', async () => {
9688
const user = userEvent.setup()
97-
9889
renderWithProviders(<MockedComponent order={mockOrder} />)
9990

10091
// Open the modal
10192
const trigger = screen.getByText(/open cancel modal/i)
10293
await user.click(trigger)
10394

104-
// Check for close button (usually has aria-label or is recognizable by role)
95+
// Check for close button
10596
const closeButton = screen.getByRole('button', {name: /close/i})
10697
expect(closeButton).toBeInTheDocument()
10798
})
10899

109100
test('calls onClose when close button is clicked', async () => {
110101
const user = userEvent.setup()
111102
const onClose = jest.fn()
112-
113103
renderWithProviders(<MockedComponent order={mockOrder} onClose={onClose} />)
114104

115-
// Open the modal manually by setting isOpen to true
105+
// Open the modal
116106
renderWithProviders(<CancelOrderModal isOpen={true} onClose={onClose} order={mockOrder} />)
117107

118108
// Click close button

packages/template-retail-react-app/app/pages/account/order-detail.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ const AccountOrderDetail = () => {
112112
const history = useHistory()
113113
const {formatMessage, formatDate} = useIntl()
114114

115-
// Modal state for cancel order
116115
const {
117116
isOpen: isCancelModalOpen,
118117
onOpen: onCancelModalOpen,
@@ -172,7 +171,6 @@ const AccountOrderDetail = () => {
172171
id="account_order_detail.title.order_details"
173172
/>
174173
</Heading>
175-
{/* Cancel Order Button */}
176174
<Button variant="link" size="sm" onClick={onCancelModalOpen}>
177175
<FormattedMessage
178176
defaultMessage="Cancel order"
@@ -417,7 +415,6 @@ const AccountOrderDetail = () => {
417415
</Stack>
418416
</Stack>
419417

420-
{/* Cancel Order Modal */}
421418
<CancelOrderModal
422419
isOpen={isCancelModalOpen}
423420
onClose={onCancelModalClose}

packages/template-retail-react-app/app/pages/account/orders.test.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,6 @@ describe('Cancel Order Button and Modal', () => {
270270
})
271271

272272
test('should open cancel order modal when button is clicked', async () => {
273-
expect(await screen.findByTestId('account-order-details-page')).toBeInTheDocument()
274-
275273
const cancelButton = screen.getByRole('button', {name: /cancel order/i})
276274
await user.click(cancelButton)
277275

@@ -284,8 +282,6 @@ describe('Cancel Order Button and Modal', () => {
284282
})
285283

286284
test('should close modal when close button is clicked', async () => {
287-
expect(await screen.findByTestId('account-order-details-page')).toBeInTheDocument()
288-
289285
// Open modal
290286
const cancelButton = screen.getByRole('button', {name: /cancel order/i})
291287
await user.click(cancelButton)
@@ -302,8 +298,6 @@ describe('Cancel Order Button and Modal', () => {
302298
})
303299

304300
test('should close modal when request cancellation button is clicked', async () => {
305-
expect(await screen.findByTestId('account-order-details-page')).toBeInTheDocument()
306-
307301
// Open modal
308302
const cancelButton = screen.getByRole('button', {name: /cancel order/i})
309303
await user.click(cancelButton)
@@ -313,7 +307,6 @@ describe('Cancel Order Button and Modal', () => {
313307
const requestCancellationButtons = screen.getAllByRole('button', {
314308
name: /request cancellation/i
315309
})
316-
// Find the button inside the modal (not the one that opens it)
317310
const modalButton = requestCancellationButtons.find((button) =>
318311
button.closest('[role="dialog"]')
319312
)
@@ -326,8 +319,6 @@ describe('Cancel Order Button and Modal', () => {
326319
})
327320

328321
test('should call onRequestCancellation when request cancellation button is clicked', async () => {
329-
expect(await screen.findByTestId('account-order-details-page')).toBeInTheDocument()
330-
331322
// Open modal
332323
const cancelButton = screen.getByRole('button', {name: /cancel order/i})
333324
await user.click(cancelButton)
@@ -340,10 +331,7 @@ describe('Cancel Order Button and Modal', () => {
340331
const modalButton = requestCancellationButtons.find((button) =>
341332
button.closest('[role="dialog"]')
342333
)
343-
344-
// Check that the callback would be called (we can't easily test the actual callback without mocking)
345334
expect(modalButton).toBeInTheDocument()
346-
347335
await user.click(modalButton)
348336

349337
// Modal should close after action

0 commit comments

Comments
 (0)