@controleonline/ui-default 1.0.272 → 1.0.274

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 (45) hide show
  1. package/.github/workflows/publish-npm.yml +91 -0
  2. package/AGENTS.md +1 -1
  3. package/docs/technical/DefaultTable.md +70 -1
  4. package/package.json +22 -22
  5. package/src/react/components/address/DefaultAddress.js +20 -9
  6. package/src/react/components/address/DefaultAddressCoordFields.js +59 -0
  7. package/src/react/components/address/LatLonReadonlyFields.js +2 -2
  8. package/src/react/components/address/defaultAddressStyles.js +13 -1
  9. package/src/react/components/files/DefaultFile.js +2 -2
  10. package/src/react/components/files/DefaultFileColumn.js +1 -1
  11. package/src/react/components/filters/DefaultColumnFilter.js +2 -7
  12. package/src/react/components/filters/DefaultExternalFilters.js +4 -11
  13. package/src/react/components/filters/filterValue.js +65 -0
  14. package/src/react/components/help/DefaultTooltip.js +73 -63
  15. package/src/react/components/help/DefaultTooltip.styles.js +23 -23
  16. package/src/react/components/inputs/DefaultInput.js +301 -210
  17. package/src/react/components/inputs/defaultInputUtils.js +193 -170
  18. package/src/react/components/table/DefaultColumnMenu.js +127 -109
  19. package/src/react/components/table/DefaultTable.js +43 -92
  20. package/src/react/components/table/DefaultTable.styles.js +10 -4
  21. package/src/react/components/table/DefaultTable.utils.js +38 -4
  22. package/src/react/components/table/DefaultTableRows.js +324 -153
  23. package/src/react/components/table/DefaultTableToolbar.js +17 -7
  24. package/src/react/components/table/DefaultTableView.js +118 -0
  25. package/src/react/components/upload/DefaultUpload.js +6 -36
  26. package/src/react/components/upload/DefaultUpload.styles.js +5 -5
  27. package/src/react/components/upload/DefaultUploadAttachmentsList.js +11 -3
  28. package/src/react/hooks/usePostalCodeLookup.js +15 -1
  29. package/src/react/services/addressFormUtils.js +104 -38
  30. package/src/react/services/addressGeo.js +6 -3
  31. package/src/react/utils/tableVisibleColumnsPreferences.js +84 -3
  32. package/src/tests/react/components/files/DefaultFile.test.js +16 -0
  33. package/src/tests/react/components/files/DefaultFileColumn.company.test.js +24 -0
  34. package/src/tests/react/components/help/DefaultTooltip.test.js +93 -0
  35. package/src/tests/react/components/table/DefaultTable.test.js +37 -0
  36. package/src/tests/react/components/table/DefaultTable.utils.test.js +10 -0
  37. package/src/tests/react/components/table/DefaultTableRowActions.test.js +23 -0
  38. package/src/tests/react/components/table/DefaultTableRows.rowActions.test.js +152 -0
  39. package/src/tests/react/components/table/DefaultTableToolbar.waiter.test.js +42 -0
  40. package/src/tests/react/components/upload/defaultUploadLibrary.test.js +31 -9
  41. package/src/tests/react/filters/filterValue.test.js +46 -0
  42. package/src/tests/react/hooks/usePostalCodeLookup.test.js +67 -0
  43. package/src/tests/react/inputs/defaultInputUtils.test.js +9 -1
  44. package/src/tests/react/services/addressFormUtils.test.js +6 -3
  45. package/src/tests/react/utils/tableVisibleColumnsPreferences.test.js +12 -1
@@ -20,6 +20,7 @@ jest.mock('@store', () => ({
20
20
  }));
21
21
 
22
22
  jest.mock('react-native', () => ({
23
+ Platform: {OS: 'android'},
23
24
  Image: props => React.createElement('image', props, props.children),
24
25
  }));
25
26
 
@@ -78,3 +79,18 @@ describe('DefaultFile', () => {
78
79
  expect(tree.toJSON()).toBeNull();
79
80
  });
80
81
  });
82
+
83
+ it('uses the domain company from the store when another company is selected', () => {
84
+ require('@store').useStore.mockReturnValue({getters: {
85
+ mainCompany: {id: 1, domain: 'domain.example'},
86
+ currentCompany: {id: 2, domain: 'selected.example'},
87
+ }});
88
+ let tree;
89
+ renderer.act(() => {
90
+ tree = renderer.create(React.createElement(DefaultFile, {file: {id: 7, url: '/files/7/download'}}));
91
+ });
92
+ const source = tree.root.findByType('image').props.source;
93
+ expect(source.uri).toBe('https://api.controleonline.com/domain.example/files/7/download');
94
+ expect(source.headers['app-domain']).toBe('domain.example');
95
+ renderer.act(() => tree.unmount());
96
+ });
@@ -0,0 +1,24 @@
1
+ const React = require('react');
2
+ const renderer = require('react-test-renderer');
3
+ const {expect, it, jest} = require('@jest/globals');
4
+ global.IS_REACT_ACT_ENVIRONMENT = true;
5
+ jest.mock('react-native', () => ({View: 'View', Text: 'Text', TouchableOpacity: 'TouchableOpacity',
6
+ Linking: {openURL: jest.fn()}, StyleSheet: {create: x => x}}));
7
+ jest.mock('react-native-vector-icons/Feather', () => 'Icon');
8
+ jest.mock('@store', () => ({useStore: jest.fn()}));
9
+ jest.mock('../../../../react/components/files/DefaultFile', () => 'Preview');
10
+ jest.mock('../../../../react/components/files/DefaultFileColumn.utils', () => ({
11
+ normalizeDefaultFileColumnItems: jest.fn(() => []), normalizeFileColumnText: value => value,
12
+ }));
13
+ const {useStore} = require('@store');
14
+ const {normalizeDefaultFileColumnItems} = require('../../../../react/components/files/DefaultFileColumn.utils');
15
+ const Column = require('../../../../react/components/files/DefaultFileColumn').default;
16
+ it('passes the domain company to file URL resolution when B is selected', () => {
17
+ const mainCompany = {id: 1, domain: 'domain.example'};
18
+ useStore.mockImplementation(name => name === 'people'
19
+ ? {getters: {mainCompany, currentCompany: {id: 2}}} : {getters: {colors: {}}});
20
+ let tree;
21
+ renderer.act(() => { tree = renderer.create(React.createElement(Column, {})); });
22
+ expect(normalizeDefaultFileColumnItems.mock.calls.at(-1)[0].company).toEqual(mainCompany);
23
+ renderer.act(() => tree.unmount());
24
+ });
@@ -0,0 +1,93 @@
1
+ /* global jest */
2
+
3
+ const React = require('react');
4
+ const TestRenderer = require('react-test-renderer');
5
+ const {act} = TestRenderer;
6
+ const {describe, expect, it} = global;
7
+
8
+ jest.mock('react-native', () => {
9
+ const React = require('react');
10
+ const component = name => props => React.createElement(name, props, props.children);
11
+
12
+ return {
13
+ Modal: props =>
14
+ React.createElement('modal', props, props.visible ? props.children : null),
15
+ Pressable: component('pressable'),
16
+ StyleSheet: {create: styles => styles},
17
+ Text: component('text'),
18
+ TouchableOpacity: component('touchable-opacity'),
19
+ View: component('view'),
20
+ };
21
+ });
22
+
23
+ const DefaultTooltip = require('../../../../react/components/help/DefaultTooltip').default;
24
+
25
+ describe('DefaultTooltip', () => {
26
+ it('keeps the existing text message contract', () => {
27
+ let renderer;
28
+ act(() => {
29
+ renderer = TestRenderer.create(
30
+ React.createElement(DefaultTooltip, {
31
+ message: 'Ajuda já existente',
32
+ testID: 'message-trigger',
33
+ }),
34
+ );
35
+ });
36
+
37
+ const trigger = renderer.root
38
+ .findAllByType('touchable-opacity')
39
+ .find(node => node.props.testID === 'message-trigger');
40
+
41
+ act(() => trigger.props.onPress());
42
+
43
+ const renderedText = renderer.root
44
+ .findAllByType('text')
45
+ .flatMap(node => node.children)
46
+ .join(' ');
47
+ expect(renderedText).toContain('Ajuda já existente');
48
+ });
49
+
50
+ it('renders structured rows and closes from the action or backdrop', () => {
51
+ let renderer;
52
+ act(() => {
53
+ renderer = TestRenderer.create(
54
+ React.createElement(DefaultTooltip, {
55
+ backdropTestID: 'tooltip-backdrop',
56
+ closeAccessibilityLabel: 'Fechar detalhes',
57
+ dialogTestID: 'tooltip-dialog',
58
+ label: 'i',
59
+ rows: [
60
+ {key: 'company', label: 'Empresa', value: 'GYROS'},
61
+ {key: 'device', label: 'Device', value: null},
62
+ ],
63
+ testID: 'tooltip-trigger',
64
+ title: 'Detalhes',
65
+ }),
66
+ );
67
+ });
68
+
69
+ expect(renderer.root.findAllByProps({testID: 'tooltip-dialog'})).toHaveLength(0);
70
+
71
+ const trigger = renderer.root
72
+ .findAllByType('touchable-opacity')
73
+ .find(node => node.props.testID === 'tooltip-trigger');
74
+
75
+ act(() => trigger.props.onPress());
76
+
77
+ const renderedText = renderer.root
78
+ .findAllByType('text')
79
+ .flatMap(node => node.children)
80
+ .join(' ');
81
+ expect(renderedText).toContain('GYROS');
82
+ expect(renderedText).toContain('Não configurado');
83
+
84
+ act(() =>
85
+ renderer.root.findByProps({accessibilityLabel: 'Fechar detalhes'}).props.onPress(),
86
+ );
87
+ expect(renderer.root.findAllByProps({testID: 'tooltip-dialog'})).toHaveLength(0);
88
+
89
+ act(() => trigger.props.onPress());
90
+ act(() => renderer.root.findByProps({testID: 'tooltip-backdrop'}).props.onPress());
91
+ expect(renderer.root.findAllByProps({testID: 'tooltip-dialog'})).toHaveLength(0);
92
+ });
93
+ });
@@ -287,6 +287,43 @@ describe('DefaultTable', () => {
287
287
  }
288
288
  });
289
289
 
290
+ it('can show only search in the toolbar while hiding configured actions and controls', () => {
291
+ mockWindowDimensions = {width: 375, height: 667};
292
+ mockStores.categories = {
293
+ actions: {},
294
+ getters: {
295
+ columns: [{key: 'name', label: 'Nome', searchable: true}],
296
+ configs: {
297
+ import: {enabled: true, importType: 'product', label: 'Importar CSV'},
298
+ showSearch: true,
299
+ },
300
+ items: [],
301
+ totalItems: 17,
302
+ },
303
+ };
304
+ let tree;
305
+
306
+ renderer.act(() => {
307
+ tree = renderer.create(
308
+ React.createElement(DefaultTable, {
309
+ columns: [{key: 'name', label: 'Nome', searchable: true}],
310
+ data: [],
311
+ showToolbarActions: false,
312
+ showToolbarControls: false,
313
+ showTotalItemsInFooter: false,
314
+ storeName: 'categories',
315
+ }),
316
+ );
317
+ });
318
+
319
+ const iconNames = tree.root.findAllByType('icon').map(node => node.props.name);
320
+ expect(iconNames).toContain('search');
321
+ expect(iconNames).not.toEqual(
322
+ expect.arrayContaining(['upload', 'code', 'filter', 'list', 'columns']),
323
+ );
324
+ expect(tree.root.findAllByType('Text').map(node => node.props.children)).not.toContain('Importar CSV');
325
+ });
326
+
290
327
  it('keeps the list/card toggle visible on compact layouts even when cards are forced', () => {
291
328
  let tree;
292
329
 
@@ -21,6 +21,7 @@ jest.mock('@controleonline/ui-common/src/react/utils/dateRangeFilter', () => ({
21
21
  const {
22
22
  getColumnMinWidth,
23
23
  getColumnStyle,
24
+ parseSortNumber,
24
25
  } = require('../../../../react/components/table/DefaultTable.utils');
25
26
 
26
27
  describe('DefaultTable utils', () => {
@@ -34,4 +35,13 @@ describe('DefaultTable utils', () => {
34
35
  ]),
35
36
  );
36
37
  });
38
+
39
+ it('parses Brazilian thousand and decimal masks as numbers', () => {
40
+ expect(parseSortNumber('1.234,56')).toBeCloseTo(1234.56);
41
+ expect(parseSortNumber('10')).toBe(10);
42
+ expect(parseSortNumber('2')).toBe(2);
43
+ expect(parseSortNumber('1.234')).toBe(1234);
44
+ expect(parseSortNumber('12/03/2024')).toBeNaN();
45
+ expect(parseSortNumber('abc')).toBeNaN();
46
+ });
37
47
  });
@@ -0,0 +1,23 @@
1
+ const React = require('react');
2
+ const {describe, expect, it} = require('@jest/globals');
3
+
4
+ const {
5
+ hasDefaultTableRowActionsComponent,
6
+ resolveDefaultTableRowActionsWidth,
7
+ } = require('../../../../react/components/table/DefaultTableRowActions');
8
+
9
+ describe('DefaultTableRowActions helpers', () => {
10
+ it('accepts function and element types as custom row actions', () => {
11
+ expect(hasDefaultTableRowActionsComponent(() => null)).toBe(true);
12
+ expect(hasDefaultTableRowActionsComponent(React.createElement('span'))).toBe(true);
13
+ expect(hasDefaultTableRowActionsComponent(null)).toBe(false);
14
+ expect(hasDefaultTableRowActionsComponent('pdf')).toBe(false);
15
+ });
16
+
17
+ it('uses configured width and falls back to 140', () => {
18
+ expect(resolveDefaultTableRowActionsWidth({rowActionsWidth: 168})).toBe(168);
19
+ expect(resolveDefaultTableRowActionsWidth({actionsColumnWidth: 96})).toBe(96);
20
+ expect(resolveDefaultTableRowActionsWidth({rowActionsWidth: 0})).toBe(140);
21
+ expect(resolveDefaultTableRowActionsWidth({})).toBe(140);
22
+ });
23
+ });
@@ -0,0 +1,152 @@
1
+ const React = require('react');
2
+ const renderer = require('react-test-renderer');
3
+ const {describe, expect, it, beforeEach} = require('@jest/globals');
4
+
5
+ global.IS_REACT_ACT_ENVIRONMENT = true;
6
+
7
+ let mockStores = {};
8
+
9
+ jest.mock('@store', () => ({
10
+ useStore: jest.fn(name => mockStores[name] || {actions: {}, getters: {}}),
11
+ }));
12
+
13
+ jest.mock('@controleonline/ui-common/src/react/utils/storeColumns', () => ({
14
+ formatStoreColumnLabel: ({fallbackLabel, fieldName}) => fallbackLabel || fieldName,
15
+ }));
16
+
17
+ jest.mock('react-native-vector-icons/Feather', () => {
18
+ const React = require('react');
19
+ return props => React.createElement('icon', props);
20
+ });
21
+
22
+ jest.mock('react-native', () => {
23
+ const React = require('react');
24
+ const createComponent = name => props =>
25
+ React.createElement(name, props, props.children);
26
+ const FlatList = props => {
27
+ const items = Array.isArray(props.data) ? props.data : [];
28
+ return React.createElement(
29
+ 'FlatList',
30
+ props,
31
+ items.map((item, index) =>
32
+ props.renderItem ? props.renderItem({item, index}) : null,
33
+ ),
34
+ );
35
+ };
36
+ return {
37
+ FlatList,
38
+ ScrollView: createComponent('ScrollView'),
39
+ Text: createComponent('Text'),
40
+ TouchableOpacity: createComponent('TouchableOpacity'),
41
+ View: createComponent('View'),
42
+ StyleSheet: {create: value => value},
43
+ Platform: {select: value => value.web || value.default},
44
+ };
45
+ });
46
+
47
+ jest.mock('../../../../react/components/filters/DefaultColumnFilter', () => () => null);
48
+ jest.mock('../../../../react/components/table/DefaultTable.styles', () => ({
49
+ cell: {},
50
+ actionsCell: {},
51
+ pinnedActionsCell: {},
52
+ stickyActionsCell: {},
53
+ stickyHeaderCell: {},
54
+ stickyIdentityCell: {},
55
+ rowActionsGroup: {},
56
+ headerRow: {},
57
+ headerText: {},
58
+ sortableHeader: {},
59
+ row: {},
60
+ scroll: {},
61
+ content: {},
62
+ tableList: {},
63
+ tableListContent: {},
64
+ filterRow: {},
65
+ filterCell: {},
66
+ iconButton: {},
67
+ horizontalScrollContent: {},
68
+ }));
69
+ jest.mock('../../../../react/components/table/DefaultTableEmptyState', () => () => null);
70
+ jest.mock('../../../../react/components/table/DefaultTableInput', () => {
71
+ const React = require('react');
72
+ return ({column, row}) =>
73
+ React.createElement('cell', {
74
+ field: column?.key || column?.name,
75
+ value: row?.[column?.key || column?.name],
76
+ });
77
+ });
78
+ jest.mock('../../../../react/components/table/useDefaultTableTheme', () => () => ({
79
+ palette: {background: '#fff', text: '#111', textSecondary: '#666'},
80
+ resolvedAccentColor: '#eee',
81
+ tableBorderColors: {rowBorderColor: '#ddd', headerBorderColor: '#ccc'},
82
+ themeTokens: {},
83
+ }));
84
+
85
+ const DefaultTableRows = require('../../../../react/components/table/DefaultTableRows').default;
86
+
87
+ const collectTestIds = tree =>
88
+ [
89
+ ...tree.root.findAllByType('View'),
90
+ ...tree.root.findAllByType('TouchableOpacity'),
91
+ ...tree.root.findAllByType('Text'),
92
+ ]
93
+ .map(node => node.props.testID)
94
+ .filter(Boolean);
95
+
96
+ describe('DefaultTableRows row actions column', () => {
97
+ beforeEach(() => {
98
+ mockStores = {};
99
+ global.t = {t: (_store, _kind, key) => ({actions: 'Ações', edit: 'Editar'}[key])};
100
+ });
101
+
102
+ it('renders header + cell when rowActionsComponent is set', () => {
103
+ mockStores.orders = {
104
+ getters: {
105
+ columns: [{key: 'name', label: 'Nome'}],
106
+ items: [{id: 7, name: 'CT-e'}],
107
+ visibleColumns: {},
108
+ configs: {
109
+ rowActionsComponent: () => React.createElement('row-actions'),
110
+ showRowActions: true,
111
+ },
112
+ },
113
+ };
114
+
115
+ let tree;
116
+ renderer.act(() => {
117
+ tree = renderer.create(React.createElement(DefaultTableRows, {storeName: 'orders'}));
118
+ });
119
+
120
+ expect(collectTestIds(tree)).toEqual(
121
+ expect.arrayContaining([
122
+ 'default-table-row-actions-header',
123
+ 'default-table-row-actions-7',
124
+ ]),
125
+ );
126
+ expect(tree.root.findAllByType('row-actions')).toHaveLength(1);
127
+ });
128
+
129
+ it('does not render an actions column when showRowActions is false', () => {
130
+ mockStores.orders = {
131
+ getters: {
132
+ columns: [{key: 'name', label: 'Nome'}],
133
+ items: [{id: 7, name: 'CT-e'}],
134
+ visibleColumns: {},
135
+ configs: {
136
+ rowActionsComponent: () => React.createElement('row-actions'),
137
+ showRowActions: false,
138
+ },
139
+ },
140
+ };
141
+
142
+ let tree;
143
+ renderer.act(() => {
144
+ tree = renderer.create(React.createElement(DefaultTableRows, {storeName: 'orders'}));
145
+ });
146
+
147
+ expect(collectTestIds(tree)).not.toEqual(
148
+ expect.arrayContaining(['default-table-row-actions-header']),
149
+ );
150
+ expect(tree.root.findAllByType('row-actions')).toHaveLength(0);
151
+ });
152
+ });
@@ -0,0 +1,42 @@
1
+ const React = require('react');
2
+ const renderer = require('react-test-renderer');
3
+ global.IS_REACT_ACT_ENVIRONMENT = true;
4
+ let mockConfigs;
5
+ jest.mock('@store', () => ({useStore: () => ({getters: {configs: mockConfigs}})}));
6
+ jest.mock('react-native', () => ({
7
+ View: props => require('react').createElement('view', props, props.children),
8
+ Text: props => require('react').createElement('text', props, props.children),
9
+ StyleSheet: {create: value => value},
10
+ Platform: {select: value => value.web || value.default || null},
11
+ useWindowDimensions: () => ({width: 400}),
12
+ }));
13
+ jest.mock('../../../../react/components/table/DefaultTableControls', () => () => require('react').createElement('controls'));
14
+ jest.mock('../../../../react/components/table/DefaultToolbarAction', () => props => require('react').createElement('action', props));
15
+ jest.mock('../../../../react/components/table/DefaultTableImportModal', () => () => null);
16
+ jest.mock('../../../../react/components/table/DefaultTableSearch', () => ({
17
+ DefaultTableCollapsedSearch: () => null, DefaultTableCompactSearch: () => null, DefaultTableInlineSearch: () => require('react').createElement('search'),
18
+ }));
19
+ jest.mock('../../../../react/components/table/useDefaultTableTheme', () => () => ({tableBorderColors: {}, toolbarColors: {}}));
20
+ const Toolbar = require('../../../../react/components/table/DefaultTableToolbar').default;
21
+ let tree;
22
+ beforeEach(() => {mockConfigs = {toolbarActions: [{key: 'custom', onPress: jest.fn()}], importAction: jest.fn(), exportAction: jest.fn()};});
23
+ afterEach(() => {if(tree) renderer.act(() => tree.unmount());});
24
+ it('keeps generic actions and controls enabled by default', () => {
25
+ renderer.act(() => {tree = renderer.create(React.createElement(Toolbar, {storeName: 'categories'}));});
26
+ expect(tree.root.findAllByType('action')).toHaveLength(3);
27
+ expect(tree.root.findAllByType('controls')).toHaveLength(1);
28
+ });
29
+ it('hides actions and administrative controls while keeping waiter search', () => {
30
+ renderer.act(() => {tree = renderer.create(React.createElement(Toolbar, {storeName: 'categories', showToolbarActions: false, showToolbarControls: false}));});
31
+ expect(tree.root.findAllByType('action')).toHaveLength(0);
32
+ expect(tree.root.findAllByType('controls')).toHaveLength(0);
33
+ expect(tree.root.findAllByType('search')).toHaveLength(1);
34
+ });
35
+ it('honors stored flags and allows an explicit screen override', () => {
36
+ mockConfigs.showToolbarActions = false; mockConfigs.showToolbarControls = false;
37
+ renderer.act(() => {tree = renderer.create(React.createElement(Toolbar, {storeName: 'categories'}));});
38
+ expect(tree.root.findAllByType('controls')).toHaveLength(0);
39
+ renderer.act(() => tree.update(React.createElement(Toolbar, {storeName: 'categories', showToolbarActions: true, showToolbarControls: true})));
40
+ expect(tree.root.findAllByType('controls')).toHaveLength(1);
41
+ expect(tree.root.findAllByType('action')).toHaveLength(3);
42
+ });
@@ -4,6 +4,7 @@
4
4
  const {
5
5
  fetchLibraryFiles,
6
6
  filesFromPeopleMediaRelations,
7
+ normalizeSeedLibraryFiles,
7
8
  } = require('../../../../react/components/upload/defaultUploadLibrary');
8
9
 
9
10
  describe('filesFromPeopleMediaRelations', () => {
@@ -20,22 +21,42 @@ describe('filesFromPeopleMediaRelations', () => {
20
21
  });
21
22
  });
22
23
 
24
+ describe('normalizeSeedLibraryFiles', () => {
25
+ it('accepts people_media rows and plain file objects', () => {
26
+ const files = normalizeSeedLibraryFiles([
27
+ {id: 1, file: {id: 10, fileName: 'a.png'}},
28
+ {id: 20, fileName: 'b.png'},
29
+ '/files/30',
30
+ ]);
31
+ expect(files.map(f => String(f.id)).sort()).toEqual(['10', '20', '30']);
32
+ });
33
+ });
34
+
23
35
  describe('fetchLibraryFiles', () => {
24
- it('returns empty when getItems is missing', async () => {
36
+ it('returns empty when getItems is missing and no seed', async () => {
25
37
  const result = await fetchLibraryFiles({fileActions: {}});
26
38
  expect(result).toEqual([]);
27
39
  });
28
40
 
29
- it('sends itemsPerPage and merges people_media relations', async () => {
41
+ it('returns seed files when getItems is missing', async () => {
42
+ const result = await fetchLibraryFiles({
43
+ fileActions: {},
44
+ additionalLibraryFiles: [
45
+ {id: 1, file: {id: 10, fileName: 'seed.png'}},
46
+ {id: 11, fileName: 'seed2.png'},
47
+ ],
48
+ });
49
+ expect(result.map(f => String(f.id)).sort()).toEqual(['10', '11']);
50
+ });
51
+
52
+ it('sends itemsPerPage and merges people_media relations + seed', async () => {
30
53
  const getItems = jest.fn().mockResolvedValue({
31
54
  member: [{id: 10, fileName: 'from-files.png', context: 'people_media'}],
32
55
  });
33
- const getPeopleMedia = jest.fn().mockResolvedValue({
34
- member: [
35
- {id: 1, file: {id: 10, fileName: 'from-files.png'}},
36
- {id: 2, file: {id: 11, fileName: 'only-relation.png'}},
37
- ],
38
- });
56
+ const getPeopleMedia = jest.fn().mockResolvedValue([
57
+ {id: 1, file: {id: 10, fileName: 'from-files.png'}},
58
+ {id: 2, file: {id: 11, fileName: 'only-relation.png'}},
59
+ ]);
39
60
 
40
61
  const files = await fetchLibraryFiles({
41
62
  fileActions: {getItems},
@@ -43,6 +64,7 @@ describe('fetchLibraryFiles', () => {
43
64
  fileType: 'image',
44
65
  libraryContexts: ['people_media'],
45
66
  peopleActions: {getPeopleMedia},
67
+ additionalLibraryFiles: [{id: 3, file: {id: 12, fileName: 'seeded.png'}}],
46
68
  });
47
69
 
48
70
  expect(getItems).toHaveBeenCalledWith(
@@ -60,7 +82,7 @@ describe('fetchLibraryFiles', () => {
60
82
  }),
61
83
  );
62
84
  const ids = files.map(f => String(f.id)).sort();
63
- expect(ids).toEqual(['10', '11']);
85
+ expect(ids).toEqual(['10', '11', '12']);
64
86
  });
65
87
 
66
88
  it('still returns /files results if people_media fetch fails', async () => {
@@ -0,0 +1,46 @@
1
+ import {
2
+ countActiveFilters,
3
+ isFilledFilterValue,
4
+ omitEmptyFilters,
5
+ } from '../../../react/components/filters/filterValue';
6
+
7
+ describe('filterValue', () => {
8
+ it('treats empty strings, null and empty collections as inactive', () => {
9
+ expect(isFilledFilterValue('')).toBe(false);
10
+ expect(isFilledFilterValue(' ')).toBe(false);
11
+ expect(isFilledFilterValue(null)).toBe(false);
12
+ expect(isFilledFilterValue(undefined)).toBe(false);
13
+ expect(isFilledFilterValue([])).toBe(false);
14
+ expect(isFilledFilterValue({})).toBe(false);
15
+ });
16
+
17
+ it('does not count date shortcut all or empty custom range', () => {
18
+ expect(isFilledFilterValue({shortcut: 'all'})).toBe(false);
19
+ expect(
20
+ isFilledFilterValue({
21
+ shortcut: 'custom',
22
+ customRange: {from: '', to: ''},
23
+ }),
24
+ ).toBe(false);
25
+ expect(isFilledFilterValue({shortcut: '7d'})).toBe(true);
26
+ expect(
27
+ isFilledFilterValue({
28
+ shortcut: 'custom',
29
+ customRange: {from: '2026-01-01', to: ''},
30
+ }),
31
+ ).toBe(true);
32
+ });
33
+
34
+ it('clears leftover empty filters when counting and omitting', () => {
35
+ const filters = {
36
+ status: '',
37
+ search: ' ',
38
+ period: {shortcut: 'all', customRange: {from: '', to: ''}},
39
+ page: 1,
40
+ category: 'sales',
41
+ };
42
+
43
+ expect(countActiveFilters(filters)).toBe(1);
44
+ expect(omitEmptyFilters(filters)).toEqual({category: 'sales'});
45
+ });
46
+ });
@@ -38,3 +38,70 @@ describe('CEP lookup race contract', () => {
38
38
  expect(form.nickname).toBe('X');
39
39
  });
40
40
  });
41
+
42
+ import {
43
+ GEOCODE_MISS_MESSAGE,
44
+ isGeocodeMiss,
45
+ mergePostalCodeData,
46
+ parseOptionalCoordinate,
47
+ } from '../../../react/services/addressFormUtils';
48
+
49
+ describe('geocode miss (#696)', () => {
50
+ test('isGeocodeMiss when address text exists and coords are null', () => {
51
+ expect(
52
+ isGeocodeMiss({
53
+ street: 'Rua Lotus',
54
+ district: 'Condomínio Jardim das Palmeiras',
55
+ city: 'Bragança Paulista',
56
+ uf: 'SP',
57
+ latitude: null,
58
+ longitude: null,
59
+ }),
60
+ ).toBe(true);
61
+ });
62
+
63
+ test('isGeocodeMiss false when Nominatim returns coords', () => {
64
+ expect(
65
+ isGeocodeMiss({
66
+ street: 'Rua Antônio Bonini',
67
+ city: 'Atibaia',
68
+ uf: 'SP',
69
+ latitude: -23.12,
70
+ longitude: -46.55,
71
+ }),
72
+ ).toBe(false);
73
+ });
74
+
75
+ test('mergePostalCodeData clears previous coords when lookup returns null', () => {
76
+ const prev = {
77
+ street: 'Old',
78
+ latitude: -23.1,
79
+ longitude: -46.5,
80
+ number: '10',
81
+ complement: '',
82
+ nickname: 'X',
83
+ cep: '12941040',
84
+ };
85
+ const next = mergePostalCodeData(prev, {
86
+ cep: '12924022',
87
+ street: 'Rua Lotus',
88
+ city: 'Bragança Paulista',
89
+ uf: 'SP',
90
+ latitude: null,
91
+ longitude: null,
92
+ });
93
+ expect(next.street).toBe('Rua Lotus');
94
+ expect(next.latitude).toBeNull();
95
+ expect(next.longitude).toBeNull();
96
+ expect(next.number).toBe('10');
97
+ });
98
+
99
+ test('parseOptionalCoordinate accepts comma decimals', () => {
100
+ expect(parseOptionalCoordinate('-23,5505')).toBeCloseTo(-23.5505);
101
+ });
102
+
103
+ test('GEOCODE_MISS_MESSAGE is PT', () => {
104
+ expect(GEOCODE_MISS_MESSAGE).toMatch(/localização no mapa/);
105
+ expect(GEOCODE_MISS_MESSAGE).toMatch(/latitude e longitude/);
106
+ });
107
+ });
@@ -12,11 +12,19 @@ jest.mock('@controleonline/ui-common/src/react/utils/storeColumns', () => ({
12
12
 
13
13
  const {
14
14
  buildReadPresentationStyles,
15
+ isIconColumn,
15
16
  mapOptions,
16
17
  resolveCellPresentation,
17
18
  } = require('../../../react/components/inputs/defaultInputUtils');
18
-
19
+
19
20
  describe('defaultInputUtils', () => {
21
+ it('identifies icon columns by input type or field name', () => {
22
+ expect(isIconColumn({inputType: 'icon', name: 'symbol'})).toBe(true);
23
+ expect(isIconColumn({type: 'ICON', name: 'symbol'})).toBe(true);
24
+ expect(isIconColumn({name: 'icon'})).toBe(true);
25
+ expect(isIconColumn({name: 'status'})).toBe(false);
26
+ });
27
+
20
28
  it('deduplicates list options by normalized key', () => {
21
29
  const column = {
22
30
  formatList(item) {