fill method infrastructure ✓ 100.0%

Last updated: 2026-03-04T23:21:38.385Z

Metrics

LOC: 45 Complexity: 10 Params: 2 Coverage: 100.0% (21/21 lines, 6x executed)

Signature

fill(wrapper: HTMLElement, value: string): : boolean

Source Code

  fill(wrapper: HTMLElement, value: string): boolean {
    const labels = wrapper.querySelectorAll<HTMLElement>(
      ".ant-radio-wrapper, .ant-radio-button-wrapper",
    );

    // Try matching by value on the underlying input
    for (const label of labels) {
      const input = label.querySelector<HTMLInputElement>(
        "input[type='radio']",
      );
      if (input?.value === value) {
        simulateClick(label);
        return true;
      }
    }

    // Try matching by text
    for (const label of labels) {
      const text = label.textContent?.trim() ?? "";
      if (text.toLowerCase() === value.toLowerCase()) {
        simulateClick(label);
        return true;
      }
    }

    // Partial text match
    for (const label of labels) {
      const text = label.textContent?.trim() ?? "";
      if (text.toLowerCase().includes(value.toLowerCase())) {
        simulateClick(label);
        return true;
      }
    }

    // Fallback: click the first unchecked option
    const first = wrapper.querySelector<HTMLElement>(
      ".ant-radio-wrapper:not(.ant-radio-wrapper-checked), .ant-radio-button-wrapper:not(.ant-radio-button-wrapper-checked)",
    );
    if (first) {
      simulateClick(first);
      return true;
    }

    return false;
  },

Dependencies (Outgoing)

graph LR fill["fill"] simulateClick["simulateClick"] fill -->|calls| simulateClick style fill fill:#dbeafe,stroke:#2563eb,stroke-width:2px click fill "b140fc089eac84d4.html" click simulateClick "7c6c21320aaee4c4.html"
TargetType
simulateClick calls

No incoming dependencies.