feat(web-test): чтение и раскрытие сворачиваемых групп формы

getFormState().groups → [{name, title, collapsed}] для сворачиваемых
групп (оба варианта ControlRepresentation: заголовок-гиперссылка и
картинка-каретка #titleBtn). Обычные несворачиваемые группы не
попадают. Состояние — по display первого контент-сиблинга за #title_div
(переживает свободные элементы между группами: при обходе Form.xml дети
группы идут до следующего сиблинга).

clickElement(title, {expand}/{expand:false}/{toggle}) раскрывает/
сворачивает группу — единый словарь с грид-узлами/деревьями, клик по
#titleBtn (вариант «картинка») или заголовку-гиперссылке. Новый
kind:'formGroup' в findClickTargetScript + хендлер click-group.mjs.

Фикстура СтраницаНастроек расширена вариантами A/B + негатив (обычная
группа) + стресс-привязка (свободный элемент между группами); тест
25-decoration-form покрывает чтение и expand/collapse/toggle. Полный
регресс 29 passed.

Popup-группы: содержимое в отдельном слое, состояние пока не читается
надёжно (follow-up).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-07-18 12:56:55 +03:00
co-authored by Claude Opus 4.8
parent 86cddc8ec3
commit bd86ece90e
7 changed files with 167 additions and 5 deletions
@@ -1,4 +1,4 @@
// web-test core/click v1.23 — clickElement dispatcher: routes to spreadsheet / popup / grid-row / form-element / field-focus handlers by target kind.
// web-test core/click v1.24 — clickElement dispatcher: routes to spreadsheet / popup / form-group / grid-row / form-element / field-focus handlers by target kind.
// Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import { page, ensureConnected, highlightMode } from './state.mjs';
@@ -18,6 +18,7 @@ import {
clickConfirmationButton, tryClickPopupItem,
} from '../forms/click-popup.mjs';
import { clickFormTarget, focusFormField } from '../forms/click-form.mjs';
import { clickFormGroupTarget } from '../forms/click-group.mjs';
import {
clickSpreadsheetCell, findSpreadsheetCellByText,
} from '../spreadsheet/spreadsheet.mjs';
@@ -123,6 +124,7 @@ export async function clickElement(text, { dblclick, table, toggle, expand, modi
// 5. Dispatch to the right handler by target kind.
const ctx = { formNum, modifier, dblclick, toggle, expand, timeout, table, gridSelector };
if (target.kind === 'formGroup') return await clickFormGroupTarget(target, ctx);
if (target.kind === 'gridGroup' || target.kind === 'gridParent') return await clickGridGroupTarget(target, ctx);
if (target.kind === 'gridTreeNode') return await clickGridTreeNodeTarget(target, ctx);
if (target.kind === 'gridRow') return await clickGridRowTarget(target, ctx);
@@ -0,0 +1,29 @@
// web-test forms/click-group v1.0 — click handler for collapsible/popup form-group titles.
// Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
//
// Reuses the tree/grid expand vocabulary so the model has ONE mental model:
// clickElement('<заголовок группы>', { expand: true }) — раскрыть (идемпотентно)
// clickElement('<заголовок группы>', { expand: false }) — свернуть (идемпотентно)
// clickElement('<заголовок группы>', { toggle: true }) — переключить
// clickElement('<заголовок группы>') — переключить (голый клик)
//
// target.collapsed приходит из findClickTargetScript (по display первого контент-сиблинга).
import { waitForStable } from '../core/wait.mjs';
import { modifierClick, returnFormState } from '../core/helpers.mjs';
import { shouldClickToggle } from '../table/grid-toggle.mjs';
export async function clickFormGroupTarget(target, ctx) {
const { formNum, modifier, toggle, expand } = ctx;
// shouldClickToggle ждёт { isExpanded }; при неизвестном состоянии (undefined) кликаем всегда.
const state = target.collapsed == null ? null : { isExpanded: !target.collapsed };
const shouldClick = shouldClickToggle(state, expand, toggle);
if (shouldClick) await modifierClick(target.x, target.y, modifier);
await waitForStable(formNum);
return returnFormState({
clicked: { kind: 'formGroup', name: target.name, toggled: shouldClick, ...(modifier ? { modifier } : {}) },
hint: shouldClick
? 'Group toggled. Call getFormState — its groups[].collapsed and revealed/hidden content update.'
: 'Group already in desired state.',
});
}