Skip to content

Commit eaf2edb

Browse files
Refine ramps circuit breaker user message
1 parent 10bb077 commit eaf2edb

7 files changed

Lines changed: 22 additions & 7 deletions

File tree

app/components/UI/Ramp/hooks/useRampsCountries.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ describe('useRampsCountries', () => {
138138
wrapper: wrapper(store),
139139
});
140140

141-
expect(result.current.error).toBe('fiat_on_ramp.payment_error');
141+
expect(result.current.error).toBe('fiat_on_ramp.circuit_breaker_open');
142142
});
143143
});
144144
});

app/components/UI/Ramp/hooks/useRampsPaymentMethods.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe('useRampsPaymentMethods', () => {
251251
expect(result.current.status).toBe('error');
252252
});
253253

254-
expect(result.current.error).toBe('fiat_on_ramp.payment_error');
254+
expect(result.current.error).toBe('fiat_on_ramp.circuit_breaker_open');
255255
});
256256

257257
it('calls Engine.context.RampsController.setSelectedPaymentMethod with full payment method object', () => {

app/components/UI/Ramp/hooks/useRampsProviders.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ describe('useRampsProviders', () => {
220220
wrapper: wrapper(store),
221221
});
222222

223-
expect(result.current.error).toBe('fiat_on_ramp.payment_error');
223+
expect(result.current.error).toBe('fiat_on_ramp.circuit_breaker_open');
224224
});
225225
});
226226

app/components/UI/Ramp/hooks/useRampsTokens.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe('useRampsTokens', () => {
135135
wrapper: wrapper(store),
136136
});
137137

138-
expect(result.current.error).toBe('fiat_on_ramp.payment_error');
138+
expect(result.current.error).toBe('fiat_on_ramp.circuit_breaker_open');
139139
});
140140
});
141141

app/components/UI/Ramp/utils/parseUserFacingError.test.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
jest.mock('../../../../../locales/i18n', () => ({
2+
strings: (key: string) =>
3+
key === 'fiat_on_ramp.circuit_breaker_open'
4+
? 'This service is temporarily unavailable. Please try again in about 30 minutes.'
5+
: key,
6+
}));
7+
18
import { parseUserFacingError } from './parseUserFacingError';
29

310
const FALLBACK = 'Something went wrong';
@@ -79,7 +86,9 @@ describe('parseUserFacingError', () => {
7986
{ errorKey: 'CIRCUIT_BREAKER_OPEN' },
8087
);
8188

82-
expect(parseUserFacingError(circuitBreakerError, FALLBACK)).toBe(FALLBACK);
89+
expect(parseUserFacingError(circuitBreakerError, FALLBACK)).toBe(
90+
'This service is temporarily unavailable. Please try again in about 30 minutes.',
91+
);
8392
});
8493

8594
it('returns fallback for resource-like circuit breaker errors', () => {
@@ -91,7 +100,9 @@ describe('parseUserFacingError', () => {
91100
},
92101
FALLBACK,
93102
),
94-
).toBe(FALLBACK);
103+
).toBe(
104+
'This service is temporarily unavailable. Please try again in about 30 minutes.',
105+
);
95106
});
96107

97108
it('handles JSON body where error.message is empty', () => {

app/components/UI/Ramp/utils/parseUserFacingError.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import { strings } from '../../../../../locales/i18n';
2+
13
const CIRCUIT_BREAKER_OPEN_ERROR_KEY = 'CIRCUIT_BREAKER_OPEN';
4+
const CIRCUIT_BREAKER_OPEN_MESSAGE_KEY = 'fiat_on_ramp.circuit_breaker_open';
25

36
function getErrorKey(error: unknown): string | null {
47
if (typeof error !== 'object' || error === null || !('errorKey' in error)) {
@@ -40,7 +43,7 @@ function getRawMessage(error: unknown): string {
4043
*/
4144
export function parseUserFacingError(error: unknown, fallback: string): string {
4245
if (getErrorKey(error) === CIRCUIT_BREAKER_OPEN_ERROR_KEY) {
43-
return fallback;
46+
return strings(CIRCUIT_BREAKER_OPEN_MESSAGE_KEY);
4447
}
4548

4649
const rawMessage = getRawMessage(error);

locales/languages/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5245,6 +5245,7 @@
52455245
"pay_with": "Pay with",
52465246
"buying_via": "Buying via {{providerName}}.",
52475247
"change_provider": "Change provider.",
5248+
"circuit_breaker_open": "This service is temporarily unavailable. Please try again in about 30 minutes.",
52485249
"payment_error": "Something went wrong. Please try again.",
52495250
"no_payment_methods_available": "No payment methods are available.",
52505251
"error_fetching_quotes": "Something went wrong. Please try again.",

0 commit comments

Comments
 (0)