mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-20 01:20:59 +03:00
refactor(web-test): этап B.5.5 — ввести returnFormState (выборочно применить)
core/helpers.mjs: returnFormState(extras) — стандартный хвост action-функций: getFormState + Object.assign(extras) + checkForErrors → state.errors. Унифицирует ~15 hand-written копий и закрывает R1/R2/R3 (state.errors теперь добавляется автоматически у любого пользователя хелпера). В этом коммите конвертированы только 2 простейших P1-сайта (openCommand, второй handle в navigateLink) — без extras между getFormState и err-проверкой. Остальные 30+ сайтов сложнее (state.X между, разные return-shape, wrapped fillFields) — будут мигрированы органически при переносе clickElement/ selectValue/closeForm в forms/* на этапе C. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
e215957344
commit
9ac0cb3b87
@@ -143,7 +143,7 @@ import {
|
||||
_detectPlatformDialogs, _closePlatformDialogs,
|
||||
} from './core/errors.mjs';
|
||||
import {
|
||||
safeClick, findFieldInputId, readEdd,
|
||||
safeClick, findFieldInputId, readEdd, returnFormState,
|
||||
detectNewForm as helperDetectNewForm,
|
||||
} from './core/helpers.mjs';
|
||||
// Re-export only what was publicly exported before the refactor.
|
||||
@@ -215,10 +215,7 @@ export async function openCommand(name) {
|
||||
if (result?.error) throw new Error(`openCommand: "${name}" not found. Available: ${result.available?.join(', ') || 'none'}`);
|
||||
|
||||
await waitForStable(formBefore);
|
||||
const state = await getFormState();
|
||||
const err = await checkForErrors();
|
||||
if (err) state.errors = err;
|
||||
return state;
|
||||
return await returnFormState();
|
||||
}
|
||||
|
||||
/** Switch to an open tab by name (fuzzy match). Returns updated form state. */
|
||||
@@ -390,10 +387,7 @@ export async function navigateLink(url) {
|
||||
}
|
||||
|
||||
await waitForStable(formBefore);
|
||||
const state = await getFormState();
|
||||
const err = await checkForErrors();
|
||||
if (err) state.errors = err;
|
||||
return state;
|
||||
return await returnFormState();
|
||||
}
|
||||
|
||||
/** Read current form state. Single evaluate call via combined script. */
|
||||
|
||||
Reference in New Issue
Block a user