feat: 更新手机号输入框逻辑,确保手动输入值在执行步骤前被保存,避免被旧状态覆盖
This commit is contained in:
@@ -136,10 +136,57 @@ test('sidepanel html exposes phone verification toggle and multi-provider SMS ro
|
||||
|
||||
test('sidepanel source wires runtime signup phone field to background sync messages', () => {
|
||||
assert.match(sidepanelSource, /function getRuntimeSignupPhoneValue\(state = latestState\)/);
|
||||
assert.match(sidepanelSource, /function shouldPreserveSignupPhoneInputValue\(stateSignupPhone = ''\)/);
|
||||
assert.match(sidepanelSource, /function syncSignupPhoneInputFromState\(state = latestState\)/);
|
||||
assert.match(sidepanelSource, /async function persistSignupPhoneInputForAction\(\)/);
|
||||
assert.match(sidepanelSource, /type:\s*'SET_SIGNUP_PHONE_STATE'/);
|
||||
assert.match(sidepanelSource, /type:\s*'SAVE_SIGNUP_PHONE'/);
|
||||
assert.match(sidepanelSource, /final \? 'SAVE_SIGNUP_PHONE' : 'SET_SIGNUP_PHONE_STATE'/);
|
||||
assert.match(sidepanelSource, /message\.payload\.signupPhoneNumber !== undefined/);
|
||||
assert.match(sidepanelSource, /await persistSignupPhoneInputForAction\(\);\s*await saveSettings/);
|
||||
assert.match(sidepanelSource, /async function handleSkipStep\(step\)[\s\S]*await persistCurrentSettingsForAction\(\);/);
|
||||
assert.match(sidepanelSource, /inputSignupPhone\.addEventListener\('input'[\s\S]*signupPhoneInputDirty = true/);
|
||||
});
|
||||
|
||||
test('runtime signup phone sync preserves active manual input until it is saved', () => {
|
||||
const api = new Function(`
|
||||
let latestState = { signupMethod: 'phone', phoneVerificationEnabled: true, signupPhoneNumber: '+441111111111' };
|
||||
let signupPhoneInputDirty = true;
|
||||
let signupPhoneInputFocused = true;
|
||||
const inputSignupPhone = { value: '+442222222222' };
|
||||
const rowSignupPhone = { style: { display: 'none' } };
|
||||
const inputPhoneVerificationEnabled = { checked: true };
|
||||
const document = { activeElement: inputSignupPhone };
|
||||
function getSelectedSignupMethod() { return 'phone'; }
|
||||
${extractFunction('normalizeSignupMethod')}
|
||||
${extractFunction('getRuntimeSignupPhoneValue')}
|
||||
${extractFunction('getSignupPhoneInputValue')}
|
||||
${extractFunction('shouldPreserveSignupPhoneInputValue')}
|
||||
${extractFunction('syncSignupPhoneInputFromState')}
|
||||
return {
|
||||
inputSignupPhone,
|
||||
rowSignupPhone,
|
||||
syncSignupPhoneInputFromState,
|
||||
getDirty: () => signupPhoneInputDirty,
|
||||
setFocused: (value) => { signupPhoneInputFocused = Boolean(value); document.activeElement = value ? inputSignupPhone : null; },
|
||||
};
|
||||
`)();
|
||||
|
||||
api.syncSignupPhoneInputFromState({
|
||||
signupMethod: 'phone',
|
||||
phoneVerificationEnabled: true,
|
||||
signupPhoneNumber: '+441111111111',
|
||||
});
|
||||
assert.equal(api.inputSignupPhone.value, '+442222222222');
|
||||
assert.equal(api.rowSignupPhone.style.display, '');
|
||||
assert.equal(api.getDirty(), true);
|
||||
|
||||
api.setFocused(false);
|
||||
api.syncSignupPhoneInputFromState({
|
||||
signupMethod: 'phone',
|
||||
phoneVerificationEnabled: true,
|
||||
signupPhoneNumber: '+441111111111',
|
||||
});
|
||||
assert.equal(api.inputSignupPhone.value, '+441111111111');
|
||||
});
|
||||
|
||||
test('hero sms country helpers keep empty summary state and expose removable order handling', () => {
|
||||
|
||||
Reference in New Issue
Block a user