Fix sidepanel latestState bootstrap order

This commit is contained in:
QLHazyCoder
2026-05-13 14:13:41 +08:00
parent d93cdfff9e
commit ecba33f021
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -518,6 +518,7 @@ const SIGNUP_METHOD_EMAIL = 'email';
const SIGNUP_METHOD_PHONE = 'phone';
const DEFAULT_SIGNUP_METHOD = SIGNUP_METHOD_EMAIL;
const DEFAULT_ACTIVE_FLOW_ID = 'openai';
let latestState = null;
let currentPlusModeEnabled = false;
let currentPlusPaymentMethod = DEFAULT_PLUS_PAYMENT_METHOD;
let currentSignupMethod = DEFAULT_SIGNUP_METHOD;
@@ -1123,7 +1124,6 @@ function validateCurrentRegistrationEmail(email = inputEmail.value.trim(), optio
return false;
}
let latestState = null;
let currentAutoRun = {
autoRunning: false,
phase: 'idle',
@@ -116,6 +116,15 @@ test('sidepanel normalizeSignupMethod stays independent from signup constants du
assert.doesNotMatch(source, /SIGNUP_METHOD_(PHONE|EMAIL)/);
});
test('sidepanel initializes latestState before bootstrapping shared step definitions', () => {
const latestStateIndex = sidepanelSource.indexOf('let latestState = null;');
const bootstrapIndex = sidepanelSource.indexOf('let stepDefinitions = getStepDefinitionsForMode(false, {');
assert.notEqual(latestStateIndex, -1);
assert.notEqual(bootstrapIndex, -1);
assert.ok(latestStateIndex < bootstrapIndex);
});
test('sidepanel signup method UI syncs shared step definitions with the selected signup method', () => {
const source = extractFunction('updateSignupMethodUI');
assert.match(source, /syncStepDefinitionsForMode\(/);