From ecba33f021273012d53f304c2ac8432477b3630a Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Wed, 13 May 2026 14:13:41 +0800 Subject: [PATCH] Fix sidepanel latestState bootstrap order --- sidepanel/sidepanel.js | 2 +- tests/sidepanel-plus-payment-method.test.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sidepanel/sidepanel.js b/sidepanel/sidepanel.js index c71804e..9e29c62 100644 --- a/sidepanel/sidepanel.js +++ b/sidepanel/sidepanel.js @@ -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', diff --git a/tests/sidepanel-plus-payment-method.test.js b/tests/sidepanel-plus-payment-method.test.js index 6adba6f..78134f7 100644 --- a/tests/sidepanel-plus-payment-method.test.js +++ b/tests/sidepanel-plus-payment-method.test.js @@ -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\(/);