• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CBIIT / bento-icdc-frontend / 26531437966

27 May 2026 06:43PM UTC coverage: 17.253% (-8.5%) from 25.73%
26531437966

Pull #1607

github

web-flow
Merge 8713d05ca into bc935f39c
Pull Request #1607: Feature/ai test studio - ICDC-4165 & ICDC-4171

306 of 2599 branches covered (11.77%)

Branch coverage included in aggregate %.

1 of 4403 new or added lines in 76 files covered. (0.02%)

2 existing lines in 2 files now uncovered.

2197 of 11909 relevant lines covered (18.45%)

0.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/components/header/SearchInput.generated.test.js
1
import React from 'react';
2
import {
3
  render,
4
  fireEvent,
5
  createEvent,
6
  cleanup,
7
} from '@testing-library/react';
8
import SearchBar from './SearchInput';
9

NEW
10
describe('SearchBar', () => {
×
11
  let consoleErrorSpy;
12

NEW
13
  beforeEach(() => {
×
NEW
14
    consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
×
15
  });
16

NEW
17
  afterEach(() => {
×
NEW
18
    if (consoleErrorSpy) {
×
NEW
19
      consoleErrorSpy.mockRestore();
×
20
    }
NEW
21
    cleanup();
×
22
  });
23

24
  function renderSearchBar(props = {}) {
×
NEW
25
    return render(
×
26
      <SearchBar
27
        placeholder="Search here"
28
        defaultValue=""
29
        ariaLabel="Search"
30
        {...props}
31
      />
32
    );
33
  }
34

NEW
35
  test('renders with placeholder, default value, and button text', () => {
×
NEW
36
    const { container } = renderSearchBar({
×
37
      placeholder: 'Search here',
38
      defaultValue: 'initial text',
39
      buttonText: 'Go',
40
    });
41

NEW
42
    const input = container.querySelector('input[aria-label="Search"]');
×
NEW
43
    const button = container.querySelector('button');
×
44

NEW
45
    expect(input).not.toBeNull();
×
NEW
46
    expect(button).not.toBeNull();
×
47

NEW
48
    expect(input.getAttribute('placeholder')).toBe('Search here');
×
NEW
49
    expect(input.value).toBe('initial text');
×
NEW
50
    expect(button.textContent).toContain('Go');
×
51
  });
52

NEW
53
  test('calls onClick with the current input value when button is clicked', () => {
×
NEW
54
    const onClick = jest.fn();
×
NEW
55
    const { container } = renderSearchBar({
×
56
      onClick,
57
      defaultValue: 'hello',
58
    });
59

NEW
60
    const input = container.querySelector('input[aria-label="Search"]');
×
NEW
61
    const button = container.querySelector('button');
×
62

NEW
63
    fireEvent.click(button);
×
64

NEW
65
    expect(onClick).toHaveBeenCalledTimes(1);
×
NEW
66
    expect(onClick).toHaveBeenCalledWith('hello');
×
NEW
67
    expect(input.value).toBe('hello');
×
68
  });
69

NEW
70
  test('updates the input value and passes the latest value to onClick', () => {
×
NEW
71
    const onClick = jest.fn();
×
NEW
72
    const { container } = renderSearchBar({
×
73
      onClick,
74
      defaultValue: '',
75
    });
76

NEW
77
    const input = container.querySelector('input[aria-label="Search"]');
×
NEW
78
    const button = container.querySelector('button');
×
79

NEW
80
    fireEvent.change(input, { target: { value: 'new query' } });
×
NEW
81
    fireEvent.click(button);
×
82

NEW
83
    expect(onClick).toHaveBeenCalledTimes(1);
×
NEW
84
    expect(onClick).toHaveBeenCalledWith('new query');
×
NEW
85
    expect(input.value).toBe('new query');
×
86
  });
87

NEW
88
  test('calls onEnter when Enter is pressed and prevents default behavior', () => {
×
NEW
89
    const onEnter = jest.fn();
×
NEW
90
    const { container } = renderSearchBar({
×
91
      onEnter,
92
      defaultValue: 'enter value',
93
    });
94

NEW
95
    const input = container.querySelector('input[aria-label="Search"]');
×
NEW
96
    const event = createEvent.keyDown(input, {
×
97
      key: 'Enter',
98
      code: 'Enter',
99
      charCode: 13,
100
      bubbles: true,
101
      cancelable: true,
102
    });
NEW
103
    const preventDefaultSpy = jest.spyOn(event, 'preventDefault');
×
104

NEW
105
    fireEvent(input, event);
×
106

NEW
107
    expect(preventDefaultSpy).toHaveBeenCalledTimes(1);
×
NEW
108
    expect(onEnter).toHaveBeenCalledTimes(1);
×
NEW
109
    expect(onEnter).toHaveBeenCalledWith('enter value');
×
110
  });
111

NEW
112
  test('does not call onEnter when a non-Enter key is pressed', () => {
×
NEW
113
    const onEnter = jest.fn();
×
NEW
114
    const { container } = renderSearchBar({
×
115
      onEnter,
116
      defaultValue: 'value',
117
    });
118

NEW
119
    const input = container.querySelector('input[aria-label="Search"]');
×
120

NEW
121
    fireEvent.keyDown(input, {
×
122
      key: 'Escape',
123
      code: 'Escape',
124
      bubbles: true,
125
      cancelable: true,
126
    });
127

NEW
128
    expect(onEnter).not.toHaveBeenCalled();
×
129
  });
130

NEW
131
  test('is disabled and shows a loading indicator when loading is true', () => {
×
NEW
132
    const onClick = jest.fn();
×
NEW
133
    const onEnter = jest.fn();
×
NEW
134
    const { container } = renderSearchBar({
×
135
      loading: true,
136
      onClick,
137
      onEnter,
138
      defaultValue: 'loading text',
139
    });
140

NEW
141
    const input = container.querySelector('input[aria-label="Search"]');
×
NEW
142
    const button = container.querySelector('button');
×
NEW
143
    const progress = container.querySelector('[role="progressbar"]');
×
144

NEW
145
    expect(input).not.toBeNull();
×
NEW
146
    expect(button).not.toBeNull();
×
NEW
147
    expect(progress).not.toBeNull();
×
148

NEW
149
    expect(input.disabled).toBe(true);
×
NEW
150
    expect(button.disabled).toBe(true);
×
NEW
151
    expect(button.textContent).not.toContain('Search');
×
152

NEW
153
    fireEvent.click(button);
×
NEW
154
    fireEvent.keyDown(input, {
×
155
      key: 'Enter',
156
      code: 'Enter',
157
      bubbles: true,
158
      cancelable: true,
159
    });
160

NEW
161
    expect(onClick).not.toHaveBeenCalled();
×
NEW
162
    expect(onEnter).not.toHaveBeenCalled();
×
163
  });
164

NEW
165
  test('is disabled when disabled prop is true', () => {
×
NEW
166
    const onClick = jest.fn();
×
NEW
167
    const onEnter = jest.fn();
×
NEW
168
    const { container } = renderSearchBar({
×
169
      disabled: true,
170
      onClick,
171
      onEnter,
172
      defaultValue: 'disabled text',
173
    });
174

NEW
175
    const input = container.querySelector('input[aria-label="Search"]');
×
NEW
176
    const button = container.querySelector('button');
×
177

NEW
178
    expect(input).not.toBeNull();
×
NEW
179
    expect(button).not.toBeNull();
×
180

NEW
181
    expect(input.disabled).toBe(true);
×
NEW
182
    expect(button.disabled).toBe(true);
×
183

NEW
184
    fireEvent.click(button);
×
NEW
185
    fireEvent.keyDown(input, {
×
186
      key: 'Enter',
187
      code: 'Enter',
188
      bubbles: true,
189
      cancelable: true,
190
    });
191

NEW
192
    expect(onClick).not.toHaveBeenCalled();
×
NEW
193
    expect(onEnter).not.toHaveBeenCalled();
×
194
  });
195

NEW
196
  test('applies a custom aria label', () => {
×
NEW
197
    const { container } = renderSearchBar({
×
198
      ariaLabel: 'Custom search field',
199
    });
200

NEW
201
    const input = container.querySelector(
×
202
      'input[aria-label="Custom search field"]'
203
    );
204

NEW
205
    expect(input).not.toBeNull();
×
206
  });
207
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc