@openmrs/esm-metadataexport-app 4.6.2-pre.1023 → 4.6.2-pre.1032

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/1574.css +1 -0
  3. package/dist/1574.css.map +1 -0
  4. package/dist/1574.js +1 -0
  5. package/dist/1574.js.map +1 -0
  6. package/dist/2173.js +1 -1
  7. package/dist/2173.js.map +1 -1
  8. package/dist/5117.js +1 -1
  9. package/dist/5117.js.map +1 -1
  10. package/dist/6813.js +1 -1
  11. package/dist/6813.js.map +1 -1
  12. package/dist/8213.css +1 -0
  13. package/dist/8213.css.map +1 -0
  14. package/dist/8213.js +1 -0
  15. package/dist/8213.js.map +1 -0
  16. package/dist/9503.js +1 -1
  17. package/dist/9503.js.map +1 -1
  18. package/dist/openmrs-esm-metadataexport-app.js +2 -2
  19. package/dist/openmrs-esm-metadataexport-app.js.map +1 -1
  20. package/dist/routes.json +1 -1
  21. package/package.json +1 -1
  22. package/src/components/metadata-package-form/domain-selection-row/domain-selection-row.component.tsx +232 -0
  23. package/src/components/metadata-package-form/domain-selection-row/domain-selection-row.scss +41 -0
  24. package/src/components/metadata-package-form/domain-selection-row/domain-selection-row.test.tsx +329 -0
  25. package/src/components/metadata-package-form/metadata-package-form.workspace.test.tsx +158 -2
  26. package/src/components/metadata-package-form/metadata-package-form.workspace.tsx +87 -19
  27. package/src/components/packages-table/packages-table.component.tsx +8 -5
  28. package/src/components/packages-table/packages-table.test.tsx +25 -0
  29. package/src/components/select-domain-items/select-domain-items.modal.scss +65 -0
  30. package/src/components/select-domain-items/select-domain-items.modal.test.tsx +462 -0
  31. package/src/components/select-domain-items/select-domain-items.modal.tsx +448 -0
  32. package/src/components/view-metadata-package/view-metadata-package.workspace.test.tsx +12 -0
  33. package/src/components/view-metadata-package/view-metadata-package.workspace.tsx +2 -10
  34. package/src/domain-lookups/domain-lookups.resource.ts +24 -1
  35. package/src/index.ts +5 -0
  36. package/src/items/items.resource.test.ts +50 -0
  37. package/src/items/items.resource.ts +108 -0
  38. package/src/routes.json +5 -1
  39. package/src/types/index.ts +9 -0
  40. package/translations/en.json +36 -0
  41. package/dist/5065.css +0 -1
  42. package/dist/5065.css.map +0 -1
  43. package/dist/5065.js +0 -1
  44. package/dist/5065.js.map +0 -1
@@ -0,0 +1,462 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { SWRConfig } from 'swr';
5
+ import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
6
+ import { useOpenmrsPagination } from '@openmrs/esm-framework';
7
+ import { useMetadataItems, useMetadataItemsByUuid } from '../../items/items.resource';
8
+ import type * as itemsResource from '../../items/items.resource';
9
+ import type { MetadataItem } from '../../types';
10
+ import SelectDomainItemsModal from './select-domain-items.modal';
11
+
12
+ vi.mock('../../items/items.resource', () => ({
13
+ useMetadataItems: vi.fn(),
14
+ useMetadataItemsByUuid: vi.fn(),
15
+ }));
16
+
17
+ const { useMetadataItems: actualUseMetadataItems } =
18
+ await vi.importActual<typeof itemsResource>('../../items/items.resource');
19
+
20
+ const mockUseMetadataItems = useMetadataItems as Mock;
21
+ const mockUseMetadataItemsByUuid = useMetadataItemsByUuid as Mock;
22
+ const mockUseOpenmrsPagination = useOpenmrsPagination as Mock;
23
+ const realUseOpenmrsPagination = mockUseOpenmrsPagination.getMockImplementation();
24
+ const mockCloseModal = vi.fn();
25
+ const mockOnApply = vi.fn();
26
+
27
+ const item = (uuid: string, display: string, retired = false): MetadataItem => ({
28
+ uuid,
29
+ display,
30
+ domain: 'ATTRIBUTE_TYPES',
31
+ retired,
32
+ });
33
+
34
+ const punctuality = item('uuid-1', 'Punctuality');
35
+ const insuranceScheme = item('uuid-2', 'Insurance Scheme');
36
+ const paymentMethod = item('uuid-3', 'Payment Method', true);
37
+
38
+ function mockItems(items: Array<MetadataItem>, overrides = {}) {
39
+ mockUseMetadataItems.mockReturnValue({
40
+ items,
41
+ totalCount: items.length,
42
+ currentPage: 1,
43
+ goTo: vi.fn(),
44
+ isLoading: false,
45
+ error: undefined,
46
+ ...overrides,
47
+ });
48
+ }
49
+
50
+ /**
51
+ * Backs the real `useMetadataItems` and pagination hook with a fake server holding the given items,
52
+ * so paging, searching and resizing pages behave as they do against the backend.
53
+ */
54
+ function serveItems(items: Array<MetadataItem>) {
55
+ const fetchItems = async (url: string) => {
56
+ const searchParams = new URL(url, window.location.href).searchParams;
57
+ const searchTerm = (searchParams.get('q') ?? '').toLowerCase();
58
+ const startIndex = Number(searchParams.get('startIndex'));
59
+ const limit = Number(searchParams.get('limit'));
60
+ const matchingItems = items.filter((item) => item.display.toLowerCase().includes(searchTerm));
61
+ return {
62
+ data: {
63
+ results: matchingItems.slice(startIndex, startIndex + limit),
64
+ totalCount: matchingItems.length,
65
+ links: [],
66
+ },
67
+ };
68
+ };
69
+ mockUseMetadataItems.mockImplementation(actualUseMetadataItems);
70
+ mockUseOpenmrsPagination.mockImplementation((url, pageSize, options) =>
71
+ realUseOpenmrsPagination(url, pageSize, { ...options, fetcher: fetchItems }),
72
+ );
73
+ }
74
+
75
+ function renderModal(
76
+ initiallySelectedItems: Array<MetadataItem> = [],
77
+ unresolvedItemUuids?: Array<string>,
78
+ initialTab?: 'all' | 'selected',
79
+ ) {
80
+ return render(
81
+ <SelectDomainItemsModal
82
+ closeModal={mockCloseModal}
83
+ domain="ATTRIBUTE_TYPES"
84
+ packageFormTitle="New package"
85
+ initiallySelectedItems={initiallySelectedItems}
86
+ unresolvedItemUuids={unresolvedItemUuids}
87
+ initialTab={initialTab}
88
+ onApply={mockOnApply}
89
+ />,
90
+ { wrapper: ({ children }) => <SWRConfig value={{ provider: () => new Map() }}>{children}</SWRConfig> },
91
+ );
92
+ }
93
+
94
+ describe('SelectDomainItemsModal', () => {
95
+ beforeEach(() => {
96
+ mockItems([punctuality, insuranceScheme, paymentMethod]);
97
+ mockUseMetadataItemsByUuid.mockReturnValue({ itemsByUuid: undefined, failedUuids: new Set() });
98
+ });
99
+
100
+ it('renders the header, the items and a retired tag for retired rows', () => {
101
+ renderModal();
102
+
103
+ expect(screen.getByText('New package · Attribute types')).toBeInTheDocument();
104
+ expect(screen.getByRole('heading', { name: 'Select attribute types' })).toBeInTheDocument();
105
+ expect(screen.getByRole('checkbox', { name: 'Punctuality' })).toBeInTheDocument();
106
+ expect(screen.getByRole('checkbox', { name: 'Insurance Scheme' })).toBeInTheDocument();
107
+ expect(screen.getByText('Retired')).toBeInTheDocument();
108
+ expect(screen.getByRole('tab', { name: 'All (3)' })).toBeInTheDocument();
109
+ });
110
+
111
+ it('applies "include all" when nothing is selected', async () => {
112
+ const user = userEvent.setup();
113
+ renderModal();
114
+
115
+ await user.click(screen.getByRole('button', { name: 'Include all attribute types' }));
116
+
117
+ expect(mockOnApply).toHaveBeenCalledWith([]);
118
+ expect(mockCloseModal).toHaveBeenCalled();
119
+ });
120
+
121
+ it('applies the selected items', async () => {
122
+ const user = userEvent.setup();
123
+ renderModal();
124
+
125
+ await user.click(screen.getByRole('checkbox', { name: 'Punctuality' }));
126
+ await user.click(screen.getByRole('checkbox', { name: 'Insurance Scheme' }));
127
+ expect(screen.getByText(/2 selected across all pages/)).toBeInTheDocument();
128
+
129
+ await user.click(screen.getByRole('button', { name: 'Include 2 selected' }));
130
+
131
+ expect(mockOnApply).toHaveBeenCalledWith([punctuality, insuranceScheme]);
132
+ });
133
+
134
+ it('keeps the selection when the search results change', async () => {
135
+ const user = userEvent.setup();
136
+ renderModal();
137
+
138
+ await user.click(screen.getByRole('checkbox', { name: 'Punctuality' }));
139
+
140
+ mockItems([insuranceScheme]);
141
+ await user.type(screen.getByRole('searchbox'), 'insurance');
142
+
143
+ expect(screen.queryByRole('checkbox', { name: 'Punctuality' })).not.toBeInTheDocument();
144
+ expect(screen.getByRole('tab', { name: 'Selected (1)' })).toBeInTheDocument();
145
+ expect(mockUseMetadataItems).toHaveBeenLastCalledWith('ATTRIBUTE_TYPES', 'insurance', false, 8);
146
+ });
147
+
148
+ it('selects and clears every row on the page from the header checkbox', async () => {
149
+ const user = userEvent.setup();
150
+ renderModal();
151
+
152
+ await user.click(screen.getByRole('checkbox', { name: 'Select all on this page' }));
153
+ expect(screen.getByRole('tab', { name: 'Selected (3)' })).toBeInTheDocument();
154
+
155
+ await user.click(screen.getByRole('checkbox', { name: 'Select all on this page' }));
156
+ expect(screen.getByRole('tab', { name: 'Selected (0)' })).toBeInTheDocument();
157
+ });
158
+
159
+ it('starts from the initial selection and lists it in the selected view', async () => {
160
+ const user = userEvent.setup();
161
+ renderModal([paymentMethod]);
162
+
163
+ await user.click(screen.getByRole('tab', { name: 'Selected (1)' }));
164
+
165
+ expect(screen.getByRole('checkbox', { name: 'Payment Method' })).toBeChecked();
166
+ expect(screen.queryByRole('checkbox', { name: 'Punctuality' })).not.toBeInTheDocument();
167
+ });
168
+
169
+ it('replaces a uuid placeholder in the selection with the real item once it loads', async () => {
170
+ const user = userEvent.setup();
171
+ const punctualityPlaceholder = item('uuid-1', 'uuid-1');
172
+ mockItems([]);
173
+ const { rerender } = renderModal([punctualityPlaceholder]);
174
+
175
+ mockItems([punctuality, insuranceScheme]);
176
+ rerender(
177
+ <SelectDomainItemsModal
178
+ closeModal={mockCloseModal}
179
+ domain="ATTRIBUTE_TYPES"
180
+ packageFormTitle="New package"
181
+ initiallySelectedItems={[punctualityPlaceholder]}
182
+ onApply={mockOnApply}
183
+ />,
184
+ );
185
+ await user.click(screen.getByRole('tab', { name: 'Selected (1)' }));
186
+
187
+ expect(screen.getByRole('checkbox', { name: 'Punctuality' })).toBeChecked();
188
+ expect(screen.queryByRole('checkbox', { name: 'uuid-1' })).not.toBeInTheDocument();
189
+
190
+ await user.click(screen.getByRole('button', { name: 'Include 1 selected' }));
191
+ expect(mockOnApply).toHaveBeenCalledWith([punctuality]);
192
+ });
193
+
194
+ describe('looking up uuid placeholders on the Selected tab', () => {
195
+ const placeholder = (uuid: string) => item(uuid, uuid);
196
+
197
+ it('looks up only the placeholders on the current page, and only while the tab is open', async () => {
198
+ const user = userEvent.setup();
199
+ const placeholders = Array.from({ length: 10 }, (_, index) => placeholder(`hidden-${index + 1}`));
200
+ renderModal(
201
+ [punctuality, ...placeholders],
202
+ placeholders.map((item) => item.uuid),
203
+ );
204
+
205
+ expect(mockUseMetadataItemsByUuid).toHaveBeenLastCalledWith('ATTRIBUTE_TYPES', []);
206
+
207
+ await user.click(screen.getByRole('tab', { name: 'Selected (11)' }));
208
+
209
+ // Page one holds punctuality and the first seven placeholders.
210
+ expect(mockUseMetadataItemsByUuid).toHaveBeenLastCalledWith(
211
+ 'ATTRIBUTE_TYPES',
212
+ placeholders.slice(0, 7).map((item) => item.uuid),
213
+ );
214
+ });
215
+
216
+ it('shows the looked-up names and retired tags, flags unavailable items and applies the real items', async () => {
217
+ const user = userEvent.setup();
218
+ mockUseMetadataItemsByUuid.mockImplementation((_domain: string, uuids: Array<string>) => ({
219
+ itemsByUuid: uuids.length
220
+ ? new Map<string, MetadataItem | null>([
221
+ [paymentMethod.uuid, paymentMethod],
222
+ ['deleted-uuid', null],
223
+ ])
224
+ : undefined,
225
+ failedUuids: new Set(),
226
+ }));
227
+ mockItems([]);
228
+ renderModal([placeholder(paymentMethod.uuid), placeholder('deleted-uuid')], [paymentMethod.uuid, 'deleted-uuid']);
229
+
230
+ await user.click(screen.getByRole('tab', { name: 'Selected (2)' }));
231
+
232
+ expect(screen.getByRole('checkbox', { name: 'Payment Method' })).toBeChecked();
233
+ expect(screen.getByText('Retired')).toBeInTheDocument();
234
+ expect(screen.getByRole('checkbox', { name: 'deleted-uuid' })).toBeChecked();
235
+ expect(screen.getByText('Unavailable')).toBeInTheDocument();
236
+
237
+ await user.click(screen.getByRole('button', { name: 'Include 2 selected' }));
238
+ expect(mockOnApply).toHaveBeenCalledWith([paymentMethod, placeholder('deleted-uuid')]);
239
+ });
240
+
241
+ describe('while searching', () => {
242
+ // 12 saved items make 2 pages at the default page size of 8.
243
+ const savedItems = Array.from({ length: 12 }, (_, index) =>
244
+ item(`saved-${index + 1}`, `Attribute ${String(index + 1).padStart(2, '0')}`),
245
+ );
246
+ const savedItemsByUuid = new Map(savedItems.map((savedItem) => [savedItem.uuid, savedItem]));
247
+
248
+ function renderModalWithPlaceholders() {
249
+ mockItems([]);
250
+ return renderModal(
251
+ savedItems.map((savedItem) => placeholder(savedItem.uuid)),
252
+ savedItems.map((savedItem) => savedItem.uuid),
253
+ );
254
+ }
255
+
256
+ it('looks up the placeholders on every page so the search matches their names', async () => {
257
+ const user = userEvent.setup();
258
+ mockUseMetadataItemsByUuid.mockImplementation((_domain: string, uuids: Array<string>) => ({
259
+ itemsByUuid: uuids.length ? new Map(uuids.map((uuid) => [uuid, savedItemsByUuid.get(uuid)])) : undefined,
260
+ failedUuids: new Set(),
261
+ isLoading: false,
262
+ }));
263
+ renderModalWithPlaceholders();
264
+
265
+ await user.click(screen.getByRole('tab', { name: 'Selected (12)' }));
266
+ expect(mockUseMetadataItemsByUuid).toHaveBeenCalledWith(
267
+ 'ATTRIBUTE_TYPES',
268
+ savedItems.slice(0, 8).map((savedItem) => savedItem.uuid),
269
+ );
270
+
271
+ // Matches Attribute 10, 11 and 12, which are placeholders on the unopened page two.
272
+ await user.type(screen.getByRole('searchbox'), 'Attribute 1');
273
+
274
+ expect(await screen.findByRole('checkbox', { name: 'Attribute 10' })).toBeInTheDocument();
275
+ expect(screen.getByRole('checkbox', { name: 'Attribute 11' })).toBeInTheDocument();
276
+ expect(screen.getByRole('checkbox', { name: 'Attribute 12' })).toBeInTheDocument();
277
+ expect(screen.getByText(/1–3 of 3 items/)).toBeInTheDocument();
278
+ });
279
+
280
+ it('shows a skeleton while the placeholders are looked up', async () => {
281
+ const user = userEvent.setup();
282
+ mockUseMetadataItemsByUuid.mockImplementation((_domain: string, uuids: Array<string>) => ({
283
+ itemsByUuid: undefined,
284
+ failedUuids: new Set(),
285
+ isLoading: uuids.length > 0,
286
+ }));
287
+ renderModalWithPlaceholders();
288
+
289
+ await user.click(screen.getByRole('tab', { name: 'Selected (12)' }));
290
+ expect(screen.queryByRole('progressbar')).not.toBeInTheDocument();
291
+
292
+ await user.type(screen.getByRole('searchbox'), 'Attribute 1');
293
+
294
+ expect(await screen.findByRole('progressbar')).toBeInTheDocument();
295
+ });
296
+ });
297
+ });
298
+
299
+ it('clears the selection', async () => {
300
+ const user = userEvent.setup();
301
+ renderModal([punctuality, insuranceScheme]);
302
+
303
+ await user.click(screen.getByRole('button', { name: 'Clear selection' }));
304
+
305
+ expect(screen.getByRole('tab', { name: 'Selected (0)' })).toBeInTheDocument();
306
+ expect(screen.getByRole('button', { name: 'Include all attribute types' })).toBeInTheDocument();
307
+ });
308
+
309
+ it('opens on the Selected tab when asked to', () => {
310
+ renderModal([paymentMethod], undefined, 'selected');
311
+
312
+ expect(screen.getByRole('tab', { name: 'Selected (1)' })).toHaveAttribute('aria-selected', 'true');
313
+ expect(screen.getByRole('checkbox', { name: 'Payment Method' })).toBeInTheDocument();
314
+ expect(screen.queryByRole('checkbox', { name: 'Punctuality' })).not.toBeInTheDocument();
315
+ });
316
+
317
+ describe('when a search on the Selected tab matches nothing', () => {
318
+ it('says nothing matches if there is a selection', async () => {
319
+ const user = userEvent.setup();
320
+ renderModal([punctuality], undefined, 'selected');
321
+
322
+ await user.type(screen.getByRole('searchbox'), 'zzz');
323
+
324
+ expect(await screen.findByText('No attribute types match your search')).toBeInTheDocument();
325
+ expect(screen.queryByText('Nothing selected yet')).not.toBeInTheDocument();
326
+ });
327
+
328
+ it('says nothing is selected if the selection is empty', async () => {
329
+ const user = userEvent.setup();
330
+ renderModal([], undefined, 'selected');
331
+
332
+ await user.type(screen.getByRole('searchbox'), 'zzz');
333
+
334
+ expect(screen.getByText('Nothing selected yet')).toBeInTheDocument();
335
+ });
336
+ });
337
+
338
+ it('disables "Include retired" on the Selected tab, where it does not apply', async () => {
339
+ const user = userEvent.setup();
340
+ renderModal([paymentMethod]);
341
+
342
+ expect(screen.getByRole('switch', { name: 'Include retired' })).toBeEnabled();
343
+
344
+ await user.click(screen.getByRole('tab', { name: 'Selected (1)' }));
345
+
346
+ expect(screen.getByRole('switch', { name: 'Include retired' })).toBeDisabled();
347
+ });
348
+
349
+ it('requests retired rows when "Include retired" is toggled on', async () => {
350
+ const user = userEvent.setup();
351
+ renderModal();
352
+
353
+ await user.click(screen.getByRole('switch', { name: 'Include retired' }));
354
+
355
+ expect(mockUseMetadataItems).toHaveBeenLastCalledWith('ATTRIBUTE_TYPES', '', true, 8);
356
+ });
357
+
358
+ it('shows a skeleton instead of the previous rows while a new search or retired toggle loads', () => {
359
+ // keepPreviousData still hands back the last page's rows while the new request is in flight.
360
+ mockItems([punctuality, insuranceScheme], { isLoading: true });
361
+ renderModal();
362
+
363
+ expect(screen.queryByRole('checkbox', { name: 'Punctuality' })).not.toBeInTheDocument();
364
+ expect(screen.getByRole('progressbar')).toBeInTheDocument();
365
+ });
366
+
367
+ it('shows an error when the items request fails', () => {
368
+ mockItems([], { error: new Error('Privilege required: Get Concepts') });
369
+ renderModal();
370
+
371
+ expect(screen.getByText('Error loading attribute types')).toBeInTheDocument();
372
+ expect(screen.getByText('Privilege required: Get Concepts')).toBeInTheDocument();
373
+ });
374
+
375
+ describe('across pages', () => {
376
+ // 20 items make 3 pages at the default page size of 8.
377
+ const attributeTypes = Array.from({ length: 20 }, (_, index) =>
378
+ item(`uuid-attribute-${index + 1}`, `Attribute ${String(index + 1).padStart(2, '0')}`),
379
+ );
380
+ const [, attribute02, , , , , , , attribute09] = attributeTypes;
381
+
382
+ beforeEach(() => {
383
+ serveItems(attributeTypes);
384
+ });
385
+
386
+ it('keeps the selection from every page and applies all of it', async () => {
387
+ const user = userEvent.setup();
388
+ renderModal();
389
+
390
+ await user.click(await screen.findByRole('checkbox', { name: 'Attribute 01' }));
391
+ await user.click(screen.getByRole('checkbox', { name: 'Attribute 02' }));
392
+
393
+ await user.click(screen.getByRole('button', { name: 'Next page' }));
394
+ await user.click(await screen.findByRole('checkbox', { name: 'Attribute 09' }));
395
+ expect(screen.getByRole('tab', { name: 'Selected (3)' })).toBeInTheDocument();
396
+
397
+ await user.click(screen.getByRole('button', { name: 'Previous page' }));
398
+ expect(await screen.findByRole('checkbox', { name: 'Attribute 01' })).toBeChecked();
399
+ expect(screen.getByRole('checkbox', { name: 'Attribute 02' })).toBeChecked();
400
+ await user.click(screen.getByRole('checkbox', { name: 'Attribute 01' }));
401
+
402
+ await user.click(screen.getByRole('button', { name: 'Include 2 selected' }));
403
+
404
+ expect(mockOnApply).toHaveBeenCalledWith([attribute02, attribute09]);
405
+ });
406
+
407
+ it.each(['all', 'selected'])(
408
+ 'shows a page that exists when a search from a later page of the %s view leaves fewer pages',
409
+ async (tabName) => {
410
+ const user = userEvent.setup();
411
+ renderModal(attributeTypes);
412
+ if (tabName === 'selected') {
413
+ await user.click(screen.getByRole('tab', { name: 'Selected (20)' }));
414
+ }
415
+
416
+ await user.click(await screen.findByRole('button', { name: 'Next page' }));
417
+ await user.click(screen.getByRole('button', { name: 'Next page' }));
418
+ expect(await screen.findByRole('checkbox', { name: 'Attribute 20' })).toBeInTheDocument();
419
+
420
+ // Matches Attribute 02, 12 and 20, which fit on 1 page.
421
+ await user.type(screen.getByRole('searchbox'), '2');
422
+
423
+ expect(await screen.findByRole('checkbox', { name: 'Attribute 02' })).toBeInTheDocument();
424
+ expect(screen.getByRole('checkbox', { name: 'Attribute 12' })).toBeInTheDocument();
425
+ expect(screen.getByRole('checkbox', { name: 'Attribute 20' })).toBeInTheDocument();
426
+ expect(screen.getByText(/1–3 of 3 items/)).toBeInTheDocument();
427
+ },
428
+ );
429
+
430
+ it.each(['all', 'selected'])(
431
+ 'shows a page that exists when the page size grows from a later page of the %s view',
432
+ async (tabName) => {
433
+ const user = userEvent.setup();
434
+ renderModal(attributeTypes);
435
+ if (tabName === 'selected') {
436
+ await user.click(screen.getByRole('tab', { name: 'Selected (20)' }));
437
+ }
438
+
439
+ await user.click(await screen.findByRole('button', { name: 'Next page' }));
440
+ await user.click(screen.getByRole('button', { name: 'Next page' }));
441
+ expect(await screen.findByRole('checkbox', { name: 'Attribute 20' })).toBeInTheDocument();
442
+
443
+ await user.selectOptions(screen.getByRole('combobox', { name: /items per page/i }), '50');
444
+
445
+ expect(await screen.findByRole('checkbox', { name: 'Attribute 01' })).toBeInTheDocument();
446
+ expect(screen.getByRole('checkbox', { name: 'Attribute 20' })).toBeInTheDocument();
447
+ expect(screen.getByText(/1–20 of 20 items/)).toBeInTheDocument();
448
+ },
449
+ );
450
+ });
451
+
452
+ it('does not apply anything when cancelled', async () => {
453
+ const user = userEvent.setup();
454
+ renderModal();
455
+
456
+ await user.click(screen.getByRole('checkbox', { name: 'Punctuality' }));
457
+ await user.click(screen.getByRole('button', { name: 'Cancel' }));
458
+
459
+ expect(mockOnApply).not.toHaveBeenCalled();
460
+ expect(mockCloseModal).toHaveBeenCalled();
461
+ });
462
+ });