fix: avoid treating URL-only contact verification snapshots as 500
This commit is contained in:
@@ -1421,12 +1421,13 @@
|
|||||||
.join(' ')
|
.join(' ')
|
||||||
.replace(/\s+/g, ' ')
|
.replace(/\s+/g, ' ')
|
||||||
.trim();
|
.trim();
|
||||||
|
const titleText = String(snapshot?.title || '').replace(/\s+/g, ' ').trim();
|
||||||
if (!bodyText) {
|
if (!bodyText) {
|
||||||
return 'OpenAI contact-verification page returned HTTP ERROR 500 after resend.';
|
return isPhoneResendServerError(titleText) ? (titleText || 'OpenAI contact-verification page returned HTTP ERROR 500 after resend.') : '';
|
||||||
}
|
}
|
||||||
const combined = [
|
const combined = [
|
||||||
bodyText,
|
bodyText,
|
||||||
snapshot?.title,
|
titleText,
|
||||||
]
|
]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(' ')
|
.join(' ')
|
||||||
|
|||||||
@@ -5974,7 +5974,8 @@ test('signup phone verification cancels activation when resend lands on contact-
|
|||||||
assert.equal(requests.filter((request) => request.searchParams.get('action') === 'getStatus').length, 1);
|
assert.equal(requests.filter((request) => request.searchParams.get('action') === 'getStatus').length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('signup phone verification treats contact-verification URL-only snapshot as resend server error', async () => {
|
test('signup phone verification does not treat contact-verification URL-only snapshot as resend server error', async () => {
|
||||||
|
let resendAttempted = false;
|
||||||
let currentState = {
|
let currentState = {
|
||||||
heroSmsApiKey: 'demo-key',
|
heroSmsApiKey: 'demo-key',
|
||||||
heroSmsCountryId: 52,
|
heroSmsCountryId: 52,
|
||||||
@@ -6008,13 +6009,28 @@ test('signup phone verification treats contact-verification URL-only snapshot as
|
|||||||
throw new Error(`Unexpected HeroSMS action: ${action}`);
|
throw new Error(`Unexpected HeroSMS action: ${action}`);
|
||||||
},
|
},
|
||||||
getState: async () => ({ ...currentState }),
|
getState: async () => ({ ...currentState }),
|
||||||
readAuthTabSnapshot: async () => ({
|
readAuthTabSnapshot: async () => (
|
||||||
url: 'https://auth.openai.com/contact-verification',
|
resendAttempted
|
||||||
title: 'auth.openai.com',
|
? {
|
||||||
text: '',
|
url: 'https://auth.openai.com/contact-verification',
|
||||||
}),
|
title: 'auth.openai.com',
|
||||||
|
text: '',
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
url: 'https://auth.openai.com/phone-verification',
|
||||||
|
title: 'Verify your phone',
|
||||||
|
text: 'Enter the code sent to your phone.',
|
||||||
|
}
|
||||||
|
),
|
||||||
sendToContentScriptResilient: async (_source, message) => {
|
sendToContentScriptResilient: async (_source, message) => {
|
||||||
|
if (message.type === 'STEP8_GET_STATE') {
|
||||||
|
return {
|
||||||
|
phoneVerificationPage: true,
|
||||||
|
url: 'https://auth.openai.com/phone-verification',
|
||||||
|
};
|
||||||
|
}
|
||||||
if (message.type === 'RESEND_VERIFICATION_CODE') {
|
if (message.type === 'RESEND_VERIFICATION_CODE') {
|
||||||
|
resendAttempted = true;
|
||||||
throw new Error('Could not establish connection. Receiving end does not exist.');
|
throw new Error('Could not establish connection. Receiving end does not exist.');
|
||||||
}
|
}
|
||||||
throw new Error(`Unexpected content-script message: ${message.type}`);
|
throw new Error(`Unexpected content-script message: ${message.type}`);
|
||||||
@@ -6029,7 +6045,8 @@ test('signup phone verification treats contact-verification URL-only snapshot as
|
|||||||
await assert.rejects(
|
await assert.rejects(
|
||||||
() => helpers.completeSignupPhoneVerificationFlow(1, { state: currentState }),
|
() => helpers.completeSignupPhoneVerificationFlow(1, { state: currentState }),
|
||||||
(error) => {
|
(error) => {
|
||||||
assert.match(error.message, /^PHONE_RESEND_SERVER_ERROR::OpenAI contact-verification page returned HTTP ERROR 500 after resend\./);
|
assert.doesNotMatch(error.message, /^PHONE_RESEND_SERVER_ERROR::/);
|
||||||
|
assert.match(error.message, /等待手机验证码超时/);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user