mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-12 08:54:57 +03:00
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:
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user