fill method infrastructure ✓ 100.0%
Last updated: 2026-02-24T19:46:21.768Z
Metrics
LOC: 36
Complexity: 5
Params: 2
Coverage: 100.0% (21/21 lines, 8x executed)
Signature
fill(wrapper: HTMLElement, value: string): : boolean
Source Code
fill(wrapper: HTMLElement, value: string): boolean {
const hiddenSelect = findOriginalSelect(wrapper);
if (!hiddenSelect) return false;
const options = Array.from(hiddenSelect.options);
// Try matching by value
const byValue = options.find((opt) => opt.value === value);
if (byValue) {
hiddenSelect.value = byValue.value;
triggerSelect2Change(hiddenSelect);
return true;
}
// Try matching by text (partial, case-insensitive)
const byText = options.find((opt) =>
opt.text.toLowerCase().includes(value.toLowerCase()),
);
if (byText) {
hiddenSelect.value = byText.value;
triggerSelect2Change(hiddenSelect);
return true;
}
// Fallback: pick a random non-empty option
const validOptions = options.filter((opt) => opt.value);
if (validOptions.length > 0) {
const random =
validOptions[Math.floor(Math.random() * validOptions.length)];
hiddenSelect.value = random.value;
triggerSelect2Change(hiddenSelect);
return true;
}
return false;
},
Dependencies (Outgoing)
| Target | Type |
|---|---|
| findOriginalSelect | calls |
| triggerSelect2Change | calls |
No incoming dependencies.