From 12c5cf5e66e400752fb6557b3628a6259122b4bd Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Tue, 26 May 2026 11:58:26 +0300 Subject: [PATCH] =?UTF-8?q?fix(web-test):=20TDZ=20=D0=B2=20selectValue=20(?= =?UTF-8?q?detectNewForm)=20+=20missing=20import=20clipboardWarnLogged?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. В selectValue локальный const detectNewForm = () => ... объявлялся ниже composite-type ветки, которая его вызывала → TDZ ReferenceError "Cannot access 'detectNewForm' before initialization". Хелпер поднят в начало функции, дубликат-объявление убрано. 2. clipboardWarnLogged читается в restoreClipboard (line 92), но не был в списке импортов из core/state.mjs (импортировался только setter). ReferenceError срабатывал только когда clipboard.read() возвращал ошибку — в первом A-регрессе ветка не активировалась случайно. Регресс 18/19 (одна flake в 11-report — readSpreadsheet timing). Co-Authored-By: Claude Opus 4.7 (1M context) --- .claude/skills/web-test/scripts/browser.mjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.claude/skills/web-test/scripts/browser.mjs b/.claude/skills/web-test/scripts/browser.mjs index 4bfd5d55..64f03f11 100644 --- a/.claude/skills/web-test/scripts/browser.mjs +++ b/.claude/skills/web-test/scripts/browser.mjs @@ -26,7 +26,7 @@ import { import { browser, page, sessionPrefix, seanceId, recorder, lastCaptions, lastRecordingDuration, highlightMode, - persistentUserDataDir, preserveClipboard, + persistentUserDataDir, preserveClipboard, clipboardWarnLogged, contexts, activeContextName, activeMode, setBrowser, setPage, setSessionPrefix, setSeanceId, setRecorder, setLastCaptions, setLastRecordingDuration, setHighlightMode, @@ -2113,6 +2113,11 @@ export async function selectValue(fieldName, searchText, { type } = {}) { const formNum = await page.evaluate(detectFormScript()); if (formNum === null) throw new Error(`selectValue: no form found`); + // Detect any new form opened above this one (broad — includes type dialogs). + // Hoisted to the top so the composite-type branch can call it before its + // original declaration site further below. + const detectNewForm = () => helperDetectNewForm(formNum); + // 1. Find DLB button (fallback to CB — ERP uses Choose Button instead of DLB for some fields) let btn = await page.evaluate(findFieldButtonScript(formNum, fieldName, 'DLB')); if (btn?.error === 'button_not_found') { @@ -2219,9 +2224,7 @@ export async function selectValue(fieldName, searchText, { type } = {}) { })()`); } - // Helper: detect any new form (broad — finds type dialogs whose a.press - // buttons have empty IDs). Looks for any visible element with id="form{N}_*". - const detectNewForm = () => helperDetectNewForm(formNum); + // detectNewForm is hoisted at the top of selectValue (see above). // Helper: open selection form and pick value async function openFormAndPick() {