-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from RevelioStartup/hotfix/payment-error
[FIX] update payment error message display
- Loading branch information
Showing
11 changed files
with
115 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import '@testing-library/jest-dom' | ||
import { render, waitFor } from '@testing-library/react' | ||
import PaymentPage from '@/app/payment/page' | ||
|
||
jest.mock('next/navigation', () => ({ | ||
useSearchParams: jest.fn(() => ({ | ||
get: jest.fn(() => 'test_order_id'), | ||
})), | ||
})) | ||
|
||
jest.mock('@/redux/api/paymentApi', () => ({ | ||
useLazyGetTransactionQuery: jest.fn(() => [ | ||
jest.fn(), | ||
{ | ||
data: null, | ||
isLoading: false, | ||
error: { | ||
data: { | ||
error: | ||
'Midtrans API is returning API error. HTTP status code: `401`. API response: `{"status_code":"401","status_message":"Unknown Merchant server_key/id","id":"c8f11ee1-1ed5-4efe-bcfb-65a24876371e"}`', | ||
}, | ||
}, | ||
}, | ||
]), | ||
})) | ||
|
||
describe('Payment Detail Page Returns Error', () => { | ||
beforeAll(() => { | ||
jest.spyOn(window, 'open').mockImplementation() | ||
}) | ||
|
||
it('renders transaction detail with error message', async () => { | ||
const { queryByTestId, getByText } = render(<PaymentPage />) | ||
await waitFor(() => { | ||
expect(queryByTestId('loader')).not.toBeInTheDocument() | ||
}) | ||
|
||
expect(getByText('Oops... something went wrong')).toBeInTheDocument() | ||
expect(getByText('Unknown Merchant server_key/id')).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ jest.mock('@/redux/api/paymentApi', () => ({ | |
}, | ||
}, | ||
isLoading: false, | ||
error: null, | ||
}, | ||
]), | ||
})) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const LOGGER_ENDPOINTS_WHITELIST = [ | ||
'createTimeline', | ||
'createTimeline', | ||
'askSuggestion', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters