fix(web-test): skip includes() fuzzy match for short strings (< 4 chars)

Prevents false positives like "Да" matching "Удаляемые" (group) or
"КомандаУстановитьВсе" (button). Exact and startsWith still work.
Applied to highlight groups, findClickTargetScript buttons/grid-scoped/grid rows.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-03-14 15:36:49 +03:00
co-authored by Claude Opus 4.6
parent 7a6e63078d
commit 3e8a0a792f
2 changed files with 12 additions and 8 deletions
+3 -1
View File
@@ -4075,10 +4075,12 @@ export async function highlight(text, opts = {}) {
return { id: el.id, name, label };
});
// Fuzzy match: exact label → exact name → startsWith → includes
// Skip includes() for short strings (< 4 chars) to avoid false positives
// e.g. "Да" matching "Удаляемые"
let found = items.find(i => i.label === target);
if (!found) found = items.find(i => i.name === target);
if (!found) found = items.find(i => i.label.startsWith(target) || i.name.startsWith(target));
if (!found) found = items.find(i => i.label.includes(target) || i.name.includes(target));
if (!found && target.length >= 4) found = items.find(i => i.label.includes(target) || i.name.includes(target));
return found ? found.id : null;
})()`);
}