fix(web-test): add startsWith matching to findClickTargetScript

The button/link search in findClickTargetScript jumped from exact
to includes matching, causing "Поступление" to match "Поступление
билетов" instead of "Поступление (акты, накладные, УПД)" when the
shorter name appeared first in DOM order. Add startsWith step for
both name and label between exact and includes matching.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-03-02 19:03:34 +03:00
parent 0c0a1aea49
commit 98ece6206e
+3 -1
View File
@@ -561,9 +561,11 @@ export function findClickTargetScript(formNum, text) {
items.push({ id: el.id, name: el.dataset.content, label: '', kind: 'tab' });
});
// Fuzzy match: exact name -> exact label -> includes name -> includes label
// Fuzzy match: exact name -> exact label -> startsWith name -> startsWith label -> includes name -> includes label
let found = items.find(i => i.name.toLowerCase() === target);
if (!found) found = items.find(i => i.label && i.label.toLowerCase() === target);
if (!found) found = items.find(i => i.name.toLowerCase().startsWith(target));
if (!found) found = items.find(i => i.label && i.label.toLowerCase().startsWith(target));
if (!found) found = items.find(i => i.name.toLowerCase().includes(target));
if (!found) found = items.find(i => i.label && i.label.toLowerCase().includes(target));