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

CBIIT / bento-icdc-frontend / 26521483403

27 May 2026 03:36PM UTC coverage: 17.458% (-8.3%) from 25.73%
26521483403

Pull #1607

github

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

306 of 2587 branches covered (11.83%)

Branch coverage included in aggregate %.

1 of 4244 new or added lines in 74 files covered. (0.02%)

2 existing lines in 2 files now uncovered.

2197 of 11750 relevant lines covered (18.7%)

0.41 hits per line

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

0.0
/src/components/PaginatedTable/Customize/PaginationOptions.generated.test.js
1
// File: src/components/PaginatedTable/Customize/PaginationOptions.test.js
2

NEW
3
jest.mock('../../../bento-core', () => ({
×
NEW
4
  customPaginationAction: jest.fn(payload => ({
×
5
    type: 'CUSTOM_PAGINATION',
6
    payload,
7
  })),
8
}));
9

NEW
10
jest.mock('../../../bento/fileCentricCartWorkflowData', () => ({
×
11
  GET_MY_CART_DATA_QUERY: 'ASC_QUERY',
12
  GET_MY_CART_DATA_QUERY_DESC: 'DESC_QUERY',
13
  cartTable: {
14
    paginationAPIField: 'ascField',
15
    paginationAPIFieldDesc: 'descField',
16
  },
17
}));
18

NEW
19
jest.mock('../../../pages/dashboard/store/Actions', () => ({
×
NEW
20
  onInputSearchQueryChange: jest.fn(value => ({
×
21
    type: 'ON_SEARCH_INPUT_CHANGE',
22
    payload: value,
23
  })),
24
}));
25

NEW
26
jest.mock('../../../store', () => ({
×
27
  __esModule: true,
28
  default: { dispatch: jest.fn() },
29
}));
30

31
import {
32
  myFileTablePaginationOptions,
33
  paginationOptions,
34
} from './PaginationOptions';
35
import { customPaginationAction } from '../../../bento-core';
36
import { onInputSearchQueryChange } from '../../../pages/dashboard/store/Actions';
37
import store from '../../../store';
38

NEW
39
describe('myFileTablePaginationOptions', () => {
×
NEW
40
  beforeEach(() => {
×
NEW
41
    jest.clearAllMocks();
×
42
  });
43

NEW
44
  describe('customizeSortByColumn', () => {
×
NEW
45
    it('should dispatch desc order when current order is asc and sortBy equals column', () => {
×
NEW
46
      const dispatch = jest.fn();
×
NEW
47
      const context = { dispatch, sortBy: 'file_name' };
×
48

NEW
49
      const { customizeSortByColumn } = myFileTablePaginationOptions(context);
×
50

NEW
51
      customizeSortByColumn('file_name', 'asc');
×
52

NEW
53
      const expectedPayload = {
×
54
        sortOrder: 'desc',
55
        sortBy: 'file_name',
56
        query: 'DESC_QUERY',
57
        paginationAPIField: 'descField',
58
      };
59

NEW
60
      expect(customPaginationAction).toHaveBeenCalledWith(expectedPayload);
×
NEW
61
      expect(dispatch).toHaveBeenCalledTimes(1);
×
NEW
62
      expect(dispatch).toHaveBeenCalledWith({
×
63
        type: 'CUSTOM_PAGINATION',
64
        payload: expectedPayload,
65
      });
66
    });
67

NEW
68
    it('should dispatch asc order when current order is not asc or sortBy differs', () => {
×
NEW
69
      const dispatch = jest.fn();
×
NEW
70
      const context = { dispatch, sortBy: 'other_column' };
×
71

NEW
72
      const { customizeSortByColumn } = myFileTablePaginationOptions(context);
×
73

NEW
74
      customizeSortByColumn('file_name', 'desc');
×
75

NEW
76
      const expectedPayload = {
×
77
        sortOrder: 'asc',
78
        sortBy: 'file_name',
79
        query: 'ASC_QUERY',
80
        paginationAPIField: 'ascField',
81
      };
82

NEW
83
      expect(customPaginationAction).toHaveBeenCalledWith(expectedPayload);
×
NEW
84
      expect(dispatch).toHaveBeenCalledWith({
×
85
        type: 'CUSTOM_PAGINATION',
86
        payload: expectedPayload,
87
      });
88
    });
89
  });
90

NEW
91
  describe('customizeToggleSelectAll', () => {
×
NEW
92
    const rows = [
×
93
      { file_uuid: 'uuid-1' },
94
      { file_uuid: 'uuid-2' },
95
      { file_uuid: 'uuid-3' },
96
    ];
97

NEW
98
    it('should select all when checked and includeIds is falsy', () => {
×
NEW
99
      const dispatch = jest.fn();
×
NEW
100
      const context = {
×
101
        dispatch,
102
        selectedRows: ['existingA'],
103
        selectedFileIds: ['uuid-0'],
104
      };
105

106
      const { customizeToggleSelectAll } =
NEW
107
        myFileTablePaginationOptions(context);
×
108

NEW
109
      const event = { stopPropagation: jest.fn(), target: { checked: true } };
×
NEW
110
      const Ids = ['name-1', 'name-2'];
×
111

NEW
112
      customizeToggleSelectAll(event, Ids, false, rows);
×
113

NEW
114
      expect(event.stopPropagation).toHaveBeenCalled();
×
115

NEW
116
      const expectedRows = Ids.concat(context.selectedRows);
×
NEW
117
      const expectedIds = ['uuid-0', 'uuid-1', 'uuid-2', 'uuid-3'];
×
118

NEW
119
      expect(customPaginationAction).toHaveBeenCalledWith({
×
120
        selectedRows: expectedRows,
121
        selectedFileIds: expectedIds,
122
      });
NEW
123
      expect(dispatch).toHaveBeenCalledWith({
×
124
        type: 'CUSTOM_PAGINATION',
125
        payload: { selectedRows: expectedRows, selectedFileIds: expectedIds },
126
      });
127
    });
128

NEW
129
    it('should uncheck all when event is unchecked', () => {
×
NEW
130
      const dispatch = jest.fn();
×
NEW
131
      const context = {
×
132
        dispatch,
133
        selectedRows: ['name-1', 'name-2', 'name-3'],
134
        selectedFileIds: ['uuid-1', 'uuid-2', 'uuid-3', 'uuid-4'],
135
      };
136

137
      const { customizeToggleSelectAll } =
NEW
138
        myFileTablePaginationOptions(context);
×
139

NEW
140
      const event = { stopPropagation: jest.fn(), target: { checked: false } };
×
NEW
141
      const Ids = ['name-1', 'name-2'];
×
142

NEW
143
      customizeToggleSelectAll(event, Ids, true, rows);
×
144

NEW
145
      expect(event.stopPropagation).toHaveBeenCalled();
×
146

NEW
147
      const expectedRows = ['name-3'];
×
NEW
148
      const expectedIds = ['uuid-4'];
×
149

NEW
150
      expect(customPaginationAction).toHaveBeenCalledWith({
×
151
        selectedRows: expectedRows,
152
        selectedFileIds: expectedIds,
153
      });
NEW
154
      expect(dispatch).toHaveBeenCalledWith({
×
155
        type: 'CUSTOM_PAGINATION',
156
        payload: { selectedRows: expectedRows, selectedFileIds: expectedIds },
157
      });
158
    });
159

NEW
160
    it('should handle undefined selectedRows/selectedFileIds by defaulting to empty arrays', () => {
×
NEW
161
      const dispatch = jest.fn();
×
NEW
162
      const context = { dispatch };
×
163

164
      const { customizeToggleSelectAll } =
NEW
165
        myFileTablePaginationOptions(context);
×
166

NEW
167
      const event = { stopPropagation: jest.fn(), target: { checked: true } };
×
NEW
168
      const Ids = ['n1'];
×
169

NEW
170
      customizeToggleSelectAll(event, Ids, false, rows);
×
171

NEW
172
      expect(customPaginationAction).toHaveBeenCalledWith({
×
173
        selectedRows: ['n1'],
174
        selectedFileIds: ['uuid-1', 'uuid-2', 'uuid-3'],
175
      });
NEW
176
      expect(dispatch).toHaveBeenCalledTimes(1);
×
177
    });
178
  });
179

NEW
180
  describe('customizeOnRowSelect', () => {
×
NEW
181
    it('should add file when row is not checked (select)', () => {
×
NEW
182
      const dispatch = jest.fn();
×
NEW
183
      const context = {
×
184
        dispatch,
185
        selectedRows: ['old1'],
186
        selectedFileIds: ['fid-0'],
187
      };
NEW
188
      const { customizeOnRowSelect } = myFileTablePaginationOptions(context);
×
189

NEW
190
      const event = { stopPropagation: jest.fn() };
×
NEW
191
      const row = {
×
192
        isChecked: false,
193
        file_name: 'newFile',
194
        file_uuid: 'fid-1',
195
      };
196

NEW
197
      customizeOnRowSelect(event, row);
×
198

NEW
199
      expect(event.stopPropagation).toHaveBeenCalled();
×
200

NEW
201
      expect(customPaginationAction).toHaveBeenCalledWith({
×
202
        selectedRows: ['old1', 'newFile'],
203
        selectedFileIds: ['fid-0', 'fid-1'],
204
      });
NEW
205
      expect(dispatch).toHaveBeenCalledWith({
×
206
        type: 'CUSTOM_PAGINATION',
207
        payload: {
208
          selectedRows: ['old1', 'newFile'],
209
          selectedFileIds: ['fid-0', 'fid-1'],
210
        },
211
      });
212
    });
213

NEW
214
    it('should remove file when row is checked (deselect)', () => {
×
NEW
215
      const dispatch = jest.fn();
×
NEW
216
      const context = {
×
217
        dispatch,
218
        selectedRows: ['keep', 'removeMe'],
219
        selectedFileIds: ['fid-keep', 'fid-remove'],
220
      };
NEW
221
      const { customizeOnRowSelect } = myFileTablePaginationOptions(context);
×
222

NEW
223
      const event = { stopPropagation: jest.fn() };
×
NEW
224
      const row = {
×
225
        isChecked: true,
226
        file_name: 'removeMe',
227
        file_uuid: 'fid-remove',
228
      };
229

NEW
230
      customizeOnRowSelect(event, row);
×
231

NEW
232
      expect(event.stopPropagation).toHaveBeenCalled();
×
NEW
233
      expect(customPaginationAction).toHaveBeenCalledWith({
×
234
        selectedRows: ['keep'],
235
        selectedFileIds: ['fid-keep'],
236
      });
NEW
237
      expect(dispatch).toHaveBeenCalledWith({
×
238
        type: 'CUSTOM_PAGINATION',
239
        payload: { selectedRows: ['keep'], selectedFileIds: ['fid-keep'] },
240
      });
241
    });
242

NEW
243
    it('should default to empty arrays when context does not provide selectedRows/selectedFileIds', () => {
×
NEW
244
      const dispatch = jest.fn();
×
NEW
245
      const context = { dispatch };
×
NEW
246
      const { customizeOnRowSelect } = myFileTablePaginationOptions(context);
×
247

NEW
248
      const event = { stopPropagation: jest.fn() };
×
NEW
249
      const row = {
×
250
        isChecked: false,
251
        file_name: 'onlyOne',
252
        file_uuid: 'fid-1',
253
      };
254

NEW
255
      customizeOnRowSelect(event, row);
×
256

NEW
257
      expect(customPaginationAction).toHaveBeenCalledWith({
×
258
        selectedRows: ['onlyOne'],
259
        selectedFileIds: ['fid-1'],
260
      });
NEW
261
      expect(dispatch).toHaveBeenCalledTimes(1);
×
262
    });
263
  });
264
});
265

NEW
266
describe('paginationOptions', () => {
×
NEW
267
  beforeEach(() => {
×
NEW
268
    jest.clearAllMocks();
×
269
  });
270

NEW
271
  it('should return myFiles pagination options with handlers', () => {
×
NEW
272
    const context = { dispatch: jest.fn(), sortBy: 'x' };
×
NEW
273
    const options = paginationOptions(context, { title: 'myFiles' });
×
274

NEW
275
    expect(typeof options.customizeSortByColumn).toBe('function');
×
NEW
276
    expect(typeof options.customizeToggleSelectAll).toBe('function');
×
NEW
277
    expect(typeof options.customizeOnRowSelect).toBe('function');
×
278
  });
279

NEW
280
  it('should wire customizeSearchQueryChange to global store dispatch for samples', () => {
×
NEW
281
    const options = paginationOptions({}, { title: 'samples' });
×
282

NEW
283
    expect(typeof options.customizeSearchQueryChange).toBe('function');
×
284

NEW
285
    options.customizeSearchQueryChange('abc');
×
286

NEW
287
    expect(onInputSearchQueryChange).toHaveBeenCalledWith('abc');
×
NEW
288
    expect(store.dispatch).toHaveBeenCalledWith({
×
289
      type: 'ON_SEARCH_INPUT_CHANGE',
290
      payload: 'abc',
291
    });
292
  });
293

NEW
294
  it('should return empty object for unknown title', () => {
×
NEW
295
    const options = paginationOptions({}, { title: 'unknown' });
×
NEW
296
    expect(options).toEqual({});
×
297
  });
298

NEW
299
  it('should safely handle missing config (undefined)', () => {
×
NEW
300
    const options = paginationOptions({}, undefined);
×
NEW
301
    expect(options).toEqual({});
×
302
  });
303
});
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