fix: detect contact-verification 500 when resend disconnects
This commit is contained in:
@@ -5888,6 +5888,77 @@ test('signup phone verification cancels activation when resend lands on contact-
|
||||
assert.equal(currentState.signupPhoneActivation, null);
|
||||
});
|
||||
|
||||
test('signup phone verification cancels activation when resend lands on contact-verification 500 page but content script drops', async () => {
|
||||
const requests = [];
|
||||
const tabSnapshots = [];
|
||||
let currentState = {
|
||||
heroSmsApiKey: 'demo-key',
|
||||
heroSmsCountryId: 52,
|
||||
heroSmsCountryLabel: 'Thailand',
|
||||
verificationResendCount: 0,
|
||||
phoneCodeWaitSeconds: 60,
|
||||
phoneCodeTimeoutWindows: 2,
|
||||
phoneCodePollIntervalSeconds: 1,
|
||||
phoneCodePollMaxRounds: 1,
|
||||
signupPhoneActivation: {
|
||||
activationId: '930001',
|
||||
phoneNumber: '66953330002',
|
||||
provider: 'hero-sms',
|
||||
countryId: 52,
|
||||
countryLabel: 'Thailand',
|
||||
},
|
||||
};
|
||||
|
||||
const helpers = api.createPhoneVerificationHelpers({
|
||||
addLog: async () => {},
|
||||
fetchImpl: async (url) => {
|
||||
const parsedUrl = new URL(url);
|
||||
requests.push(parsedUrl);
|
||||
const action = parsedUrl.searchParams.get('action');
|
||||
const id = parsedUrl.searchParams.get('id');
|
||||
if (action === 'getStatus') {
|
||||
return { ok: true, text: async () => 'STATUS_WAIT_CODE' };
|
||||
}
|
||||
if (action === 'setStatus') {
|
||||
return { ok: true, text: async () => `STATUS_UPDATED:${id}` };
|
||||
}
|
||||
throw new Error(`Unexpected HeroSMS action: ${action}`);
|
||||
},
|
||||
getState: async () => ({ ...currentState }),
|
||||
readAuthTabSnapshot: async () => {
|
||||
tabSnapshots.push('read');
|
||||
return {
|
||||
url: 'https://auth.openai.com/contact-verification',
|
||||
title: 'auth.openai.com',
|
||||
text: "This page isn't working auth.openai.com is currently unable to handle this request. HTTP ERROR 500",
|
||||
};
|
||||
},
|
||||
sendToContentScriptResilient: async (_source, message) => {
|
||||
if (message.type === 'RESEND_VERIFICATION_CODE') {
|
||||
throw new Error('Could not establish connection. Receiving end does not exist.');
|
||||
}
|
||||
throw new Error(`Unexpected content-script message: ${message.type}`);
|
||||
},
|
||||
setState: async (updates) => {
|
||||
currentState = { ...currentState, ...updates };
|
||||
},
|
||||
sleepWithStop: async () => {},
|
||||
throwIfStopped: () => {},
|
||||
});
|
||||
|
||||
await assert.rejects(
|
||||
() => helpers.completeSignupPhoneVerificationFlow(1, { state: currentState }),
|
||||
(error) => {
|
||||
assert.match(error.message, /^PHONE_RESEND_SERVER_ERROR::This page isn't working/);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
assert.equal(tabSnapshots.length >= 1, true);
|
||||
assert.equal(currentState.signupPhoneActivation, null);
|
||||
assert.equal(requests.filter((request) => request.searchParams.get('action') === 'getStatus').length, 1);
|
||||
});
|
||||
|
||||
test('phone verification helper skips page resend for 5sim timeouts and rotates number directly', async () => {
|
||||
const requests = [];
|
||||
const messages = [];
|
||||
|
||||
Reference in New Issue
Block a user