mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-10 13:33:21 +03:00
refactor(web-test): form-state переехал из core/ в forms/
getFormState — высокоуровневая операция «прочитать состояние формы», семантически в forms/ ближе чем в core/ (foundational плумбинг движка). engine/core/form-state.mjs → engine/forms/state.mjs Все 11 importer'ов обновлены. Внутри state.mjs пути исправлены: './state.mjs' → '../core/state.mjs', './errors.mjs' → '../core/errors.mjs'. 03-fillfields регресс зелёный. 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
ab10761667
commit
8bdcb9e664
@@ -5,7 +5,7 @@ import { page, recorder, ensureConnected } from '../core/state.mjs';
|
||||
import { detectFormScript } from '../../dom.mjs';
|
||||
import { dismissPendingErrors, checkForErrors, detectPlatformDialogs, closePlatformDialogs } from '../core/errors.mjs';
|
||||
import { waitForStable } from '../core/wait.mjs';
|
||||
import { getFormState } from '../core/form-state.mjs';
|
||||
import { getFormState } from './state.mjs';
|
||||
|
||||
/**
|
||||
* Close the current form/dialog via Escape.
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
isTypeDialog, pickFromTypeDialog,
|
||||
} from './select-value.mjs';␍
|
||||
import { pasteText } from '../core/clipboard.mjs';
|
||||
import { getFormState } from '../core/form-state.mjs';
|
||||
import { getFormState } from './state.mjs';
|
||||
|
||||
/** Fill fields on the current form via Playwright page.fill(). Returns fill results + updated form. */
|
||||
export async function fillFields(fields) {
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
detectNewForm as helperDetectNewForm,
|
||||
} from '../core/helpers.mjs';␍
|
||||
import { pasteText } from '../core/clipboard.mjs';
|
||||
import { getFormState } from '../core/form-state.mjs';
|
||||
import { getFormState } from './state.mjs';
|
||||
|
||||
/**
|
||||
* Scan visible grid rows for a text match (exact → startsWith → includes).
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// web-test engine/forms/state v1.17 — central form-state reader.
|
||||
// Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
//
|
||||
// getFormState — the canonical "what's on the screen right now" call. Combines:
|
||||
// 1. DOM script (getFormStateScript) → form structure (fields, buttons, tables, openForms, ...)
|
||||
// 2. checkForErrors → state.errors + state.confirmation hint
|
||||
// 3. detectPlatformDialogs → state.platformDialogs (About / Support Info / Error Report)
|
||||
//
|
||||
// Returned by virtually every action-function as the "after" snapshot.
|
||||
|
||||
import { page, ensureConnected } from '../core/state.mjs';
|
||||
import { getFormStateScript } from '../../dom.mjs';
|
||||
import { checkForErrors, detectPlatformDialogs } from '../core/errors.mjs';
|
||||
|
||||
/** Read current form state. Single evaluate call via combined script. */
|
||||
export async function getFormState() {
|
||||
ensureConnected();
|
||||
const state = await page.evaluate(getFormStateScript());
|
||||
const err = await checkForErrors();
|
||||
if (err) {
|
||||
state.errors = err;
|
||||
if (err.confirmation) {
|
||||
state.confirmation = err.confirmation;
|
||||
state.hint = 'Call web_click with a button name (e.g. "Да", "Нет", "Отмена") to respond';
|
||||
}
|
||||
}
|
||||
// Detect platform-level dialogs (About, Support Info, Error Report)
|
||||
// These are NOT 1C forms — invisible to detectForms() and not closeable via Escape.
|
||||
const pd = await detectPlatformDialogs();
|
||||
if (pd.length) state.platformDialogs = pd;
|
||||
return state;
|
||||
}
|
||||
Reference in New Issue
Block a user