mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-23 13:11:05 +03:00
fix(web-test): strict search input detection in selection forms
Selection forms without a search field (e.g. ERP Соглашения) have only filter fields like ТипСоглашения. The old code fell back to inputs[0], typing the search text into the filter field and breaking the form. Now pickFromSelectionForm only uses inputs whose ID matches known search field patterns (поиск/search/строкапоиска/SearchString/find). When no search input is found, it skips text entry and matches rows directly in the grid — which works because the target value is visible among the rows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
5061d83282
commit
328cb60f18
@@ -348,15 +348,14 @@ export async function readTable({ maxRows = 20, offset = 0 } = {}) {
|
|||||||
* @returns {{ field, ok, method }} or {{ field, error, message }}
|
* @returns {{ field, ok, method }} or {{ field, error, message }}
|
||||||
*/
|
*/
|
||||||
async function pickFromSelectionForm(selFormNum, fieldName, text, origFormNum) {
|
async function pickFromSelectionForm(selFormNum, fieldName, text, origFormNum) {
|
||||||
// 1. Find search input in the selection form
|
// 1. Find search input in the selection form (strict — only named search fields,
|
||||||
|
// do NOT fall back to first input — it may be a filter field like ТипСоглашения)
|
||||||
const searchInputId = await page.evaluate(`(() => {
|
const searchInputId = await page.evaluate(`(() => {
|
||||||
const p = 'form${selFormNum}_';
|
const p = 'form${selFormNum}_';
|
||||||
const inputs = [...document.querySelectorAll('input.editInput[id^="' + p + '"]')].filter(el => el.offsetWidth > 0);
|
const inputs = [...document.querySelectorAll('input.editInput[id^="' + p + '"]')].filter(el => el.offsetWidth > 0);
|
||||||
// Prefer field with "search"/"поиск" in its ID
|
const searchInput = inputs.find(el => /поиск|search|строкапоиска|SearchString|find/i.test(el.id));
|
||||||
let searchInput = inputs.find(el => /поиск|search|строкапоиска|find/i.test(el.id));
|
|
||||||
if (!searchInput && inputs.length > 0) searchInput = inputs[0];
|
|
||||||
return searchInput ? searchInput.id : null;
|
return searchInput ? searchInput.id : null;
|
||||||
})()`);
|
})()`)
|
||||||
|
|
||||||
// 2. Fill search field via clipboard paste (more reliable than page.fill for 1C)
|
// 2. Fill search field via clipboard paste (more reliable than page.fill for 1C)
|
||||||
if (searchInputId && text) {
|
if (searchInputId && text) {
|
||||||
|
|||||||
Reference in New Issue
Block a user