mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-11 08:24:57 +03:00
refactor(web-test): returnFormState в nav + grid + spreadsheet + selectValue (7 веток)
navigation.mjs: navigateSection (sections+commands ветка), switchTab, openFile
(оба success-сайта). Закрывает R1/R2 для навигационных action-функций.
grid.mjs: deleteTableRow — заодно унификация shape с SKILL.md ("→ form state"
плоский). До этого код возвращал {deleted, ..., form: formData} в нарушение
документации; теперь плоский state с extras. JSDoc обновлён.
spreadsheet.mjs: clickSpreadsheetCell. select-value.mjs: ветка clear-success
selectValue (search=null, method='clear').
Phase 1 / C3 (final) из плана upload/returnFormState-audit.md. Полный регресс 19/19
зелёный. Известный pre-existing test-isolation issue в одиночном прогоне
04-selectvalue (auto-history) — описан в backlog §0.8 #4 родительского плана.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// web-test forms/select-value v1.17 — Reference & composite-type value selection: selectValue, fillReferenceField, selection/type-dialog pickers.
|
||||
// web-test forms/select-value v1.18 — Reference & composite-type value selection: selectValue, fillReferenceField, selection/type-dialog pickers.
|
||||
// Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import {
|
||||
@@ -17,7 +17,7 @@ import { highlight, unhighlight } from '../recording/highlight.mjs';
|
||||
import {
|
||||
safeClick, findFieldInputId, readEdd,
|
||||
detectNewForm as helperDetectNewForm,
|
||||
clickEddItemViaDispatch, clickShowAllInEdd,
|
||||
clickEddItemViaDispatch, clickShowAllInEdd, returnFormState,
|
||||
} from '../core/helpers.mjs';
|
||||
import { pasteText } from '../core/clipboard.mjs';
|
||||
import { getFormState } from './state.mjs';
|
||||
@@ -617,8 +617,7 @@ export async function selectValue(fieldName, searchText, { type } = {}) {
|
||||
await waitForStable();
|
||||
}
|
||||
if (highlightMode) try { await unhighlight(); } catch {}
|
||||
const formData = await getFormState();
|
||||
return { ...formData, selected: { field: fieldName, search: null, method: 'clear' } };
|
||||
return returnFormState({ selected: { field: fieldName, search: null, method: 'clear' } });
|
||||
}
|
||||
|
||||
// === COMPOSITE TYPE HANDLING ===
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// web-test nav/navigation v1.16 — Section navigation, openCommand, switchTab, navigateLink (Shift+F11), openFile.
|
||||
// web-test nav/navigation v1.17 — Section navigation, openCommand, switchTab, navigateLink (Shift+F11), openFile.
|
||||
// Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import {
|
||||
@@ -12,9 +12,9 @@ import {
|
||||
import { dismissPendingErrors, checkForErrors } from '../core/errors.mjs';
|
||||
import { waitForStable, waitForCondition } from '../core/wait.mjs';
|
||||
import { highlight, unhighlight } from '../recording/highlight.mjs';
|
||||
import { returnFormState } from '../core/helpers.mjs';
|
||||
import { returnFormState } from '../core/helpers.mjs';
|
||||
// Static import — ESM cycle that resolves at call time.
|
||||
// Static import — ESM cycle that resolves at call time.
|
||||
import { pasteText } from '../core/clipboard.mjs';
|
||||
import { getFormState } from '../forms/state.mjs';
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ export async function navigateSection(name) {
|
||||
sections: ${readSectionsScript()},
|
||||
commands: ${readCommandsScript()}
|
||||
})`);
|
||||
})`);
|
||||
return returnFormState({ navigated: result, sections, commands });
|
||||
}
|
||||
|
||||
/** Read commands of the current section. */
|
||||
@@ -88,7 +88,7 @@ export async function switchTab(name) {
|
||||
const result = await page.evaluate(switchTabScript(name));
|
||||
if (result?.error) throw new Error(`switchTab: "${name}" not found. Available: ${result.available?.join(', ') || 'none'}`);
|
||||
await waitForStable();
|
||||
await waitForStable();
|
||||
return returnFormState();
|
||||
}
|
||||
|
||||
// English → Russian metadata type mapping for e1cib navigation links
|
||||
@@ -206,9 +206,7 @@ export async function openFile(filePath) {
|
||||
}
|
||||
}
|
||||
// It's the real EPF form
|
||||
// It's the real EPF form
|
||||
const state = await getFormState();
|
||||
state.opened = { file: absPath, attempt: attempt + 1 };
|
||||
return returnFormState({ opened: { file: absPath, attempt: attempt + 1 } });
|
||||
}
|
||||
// Form didn't appear — retry
|
||||
continue;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// web-test spreadsheet v1.17 — readSpreadsheet + helpers for SpreadsheetDocument (отчёты, печатные формы).
|
||||
// web-test spreadsheet v1.18 — readSpreadsheet + helpers for SpreadsheetDocument (отчёты, печатные формы).
|
||||
// Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import { page, ensureConnected } from '../core/state.mjs';
|
||||
import { detectFormScript } from '../../dom.mjs';
|
||||
import { waitForStable } from '../core/wait.mjs';
|
||||
import { getFormState } from '../forms/state.mjs';
|
||||
import { returnFormState } from '../core/helpers.mjs';
|
||||
|
||||
// --- Spreadsheet helpers (shared by readSpreadsheet and clickElement) ---
|
||||
|
||||
@@ -442,9 +443,7 @@ export async function clickSpreadsheetCell(target, { dblclick: dbl, modifier } =
|
||||
if (modKey) await page.keyboard.up(modKey);
|
||||
|
||||
await waitForStable();
|
||||
const state = await getFormState();
|
||||
state.clicked = { kind: 'spreadsheetCell', row: target.row, column: colName, ...(dbl ? { dblclick: true } : {}) };
|
||||
return state;
|
||||
return returnFormState({ clicked: { kind: 'spreadsheetCell', row: target.row, column: colName, ...(dbl ? { dblclick: true } : {}) } });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// web-test table/grid v1.17 — Form-grid operations: read table rows, fill rows, delete rows.
|
||||
// web-test table/grid v1.18 — Form-grid operations: read table rows, fill rows, delete rows.
|
||||
// Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
//
|
||||
// "Grid" в терминах 1С — таблица на форме (.gridLine/.gridBody/.grid в DOM):
|
||||
@@ -10,7 +10,7 @@ import { detectFormScript, readTableScript, resolveGridScript } from '../../dom.
|
||||
import { dismissPendingErrors } from '../core/errors.mjs';
|
||||
import { waitForStable } from '../core/wait.mjs';
|
||||
import { clickElement } from '../core/click.mjs';
|
||||
import { getFormState } from '../forms/state.mjs';
|
||||
import { returnFormState } from '../core/helpers.mjs';
|
||||
|
||||
/** Read structured table data with pagination. Returns columns, rows, total count. */
|
||||
export async function readTable({ maxRows = 20, offset = 0, table } = {}) {
|
||||
@@ -33,7 +33,7 @@ export async function readTable({ maxRows = 20, offset = 0, table } = {}) {
|
||||
* @param {number} row - 0-based row index to delete
|
||||
* @param {Object} [options]
|
||||
* @param {string} [options.tab] - Switch to this form tab before operating
|
||||
* @returns {{ deleted, rowsBefore, rowsAfter, form }}
|
||||
* @returns {object} form state with { deleted, rowsBefore, rowsAfter }
|
||||
*/
|
||||
export async function deleteTableRow(row, { tab, table } = {}) {
|
||||
ensureConnected();
|
||||
@@ -98,6 +98,5 @@ export async function deleteTableRow(row, { tab, table } = {}) {
|
||||
return body ? body.querySelectorAll('.gridLine').length : 0;
|
||||
})()`);
|
||||
|
||||
const formData = await getFormState();
|
||||
return { deleted: row, rowsBefore, rowsAfter, form: formData };
|
||||
return returnFormState({ deleted: row, rowsBefore, rowsAfter });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user