@controleonline/ui-default 1.0.272 → 1.0.273

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 (41) 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 +4 -4
  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/upload/DefaultUpload.js +6 -36
  24. package/src/react/components/upload/DefaultUpload.styles.js +5 -5
  25. package/src/react/components/upload/DefaultUploadAttachmentsList.js +11 -3
  26. package/src/react/hooks/usePostalCodeLookup.js +15 -1
  27. package/src/react/services/addressFormUtils.js +104 -38
  28. package/src/react/services/addressGeo.js +6 -3
  29. package/src/react/utils/tableVisibleColumnsPreferences.js +84 -3
  30. package/src/tests/react/components/files/DefaultFile.test.js +16 -0
  31. package/src/tests/react/components/files/DefaultFileColumn.company.test.js +24 -0
  32. package/src/tests/react/components/help/DefaultTooltip.test.js +93 -0
  33. package/src/tests/react/components/table/DefaultTable.utils.test.js +10 -0
  34. package/src/tests/react/components/table/DefaultTableRowActions.test.js +23 -0
  35. package/src/tests/react/components/table/DefaultTableRows.rowActions.test.js +152 -0
  36. package/src/tests/react/components/upload/defaultUploadLibrary.test.js +31 -9
  37. package/src/tests/react/filters/filterValue.test.js +46 -0
  38. package/src/tests/react/hooks/usePostalCodeLookup.test.js +67 -0
  39. package/src/tests/react/inputs/defaultInputUtils.test.js +9 -1
  40. package/src/tests/react/services/addressFormUtils.test.js +6 -3
  41. package/src/tests/react/utils/tableVisibleColumnsPreferences.test.js +12 -1
@@ -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
+ });
@@ -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
+ });
@@ -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) {
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  mergePostalCodeData,
3
+ clearPostalCodeDerivedFields,
3
4
  onlyDigits,
4
5
  hydrateAddressFromRow,
5
6
  hasCoordinates,
@@ -47,13 +48,13 @@ describe('addressFormUtils', () => {
47
48
  expect(next.city).toBe('São Paulo');
48
49
  expect(next.uf).toBe('SP');
49
50
  expect(next.cep).toBe('01310100');
50
- expect(next.number).toBe('100');
51
+ expect(next.number).toBe(''); // cleared on CEP lookup (#746)
51
52
  expect(next.complement).toBe('Apto 1');
52
53
  expect(next.nickname).toBe('Casa');
53
54
  expect(next.countryCode).toBe('BR');
54
55
  });
55
56
 
56
- test('mergePostalCodeData never clears number/complement/nickname', () => {
57
+ test('mergePostalCodeData clears number but keeps complement/nickname (#746)', () => {
57
58
  const prev = {
58
59
  nickname: 'Trabalho',
59
60
  number: '42',
@@ -75,7 +76,7 @@ describe('addressFormUtils', () => {
75
76
  country: 'Brazil',
76
77
  };
77
78
  const next = mergePostalCodeData(prev, data);
78
- expect(next.number).toBe('42');
79
+ expect(next.number).toBe('');
79
80
  expect(next.complement).toBe('Sala 3');
80
81
  expect(next.nickname).toBe('Trabalho');
81
82
  expect(next.street).toBe('Av Paulista');
@@ -137,6 +138,8 @@ describe('addressFormUtils', () => {
137
138
  test('hasCoordinates requires finite lat/lng', () => {
138
139
  expect(hasCoordinates({latitude: -23, longitude: -46})).toBe(true);
139
140
  expect(hasCoordinates({latitude: null, longitude: -46})).toBe(false);
141
+ expect(hasCoordinates({latitude: 0, longitude: 0})).toBe(false);
142
+ expect(hasCoordinates({latitude: '0', longitude: '0'})).toBe(false);
140
143
  });
141
144
 
142
145
  test('parseOptionalCoordinate returns null for empty/invalid', () => {
@@ -5,6 +5,7 @@ const {
5
5
  TABLE_VISIBLE_COLUMNS_PREFERENCES_KEY,
6
6
  TABLE_VIEW_MODE_PREFERENCES_KEY,
7
7
  buildDefaultVisibleColumns,
8
+ canHideVisibleColumn,
8
9
  persistTableFiltersPreference,
9
10
  persistTableSortPreference,
10
11
  persistTableViewModePreference,
@@ -71,12 +72,22 @@ describe('tableVisibleColumnsPreferences', () => {
71
72
  },
72
73
  }),
73
74
  ).toEqual({
74
- id: false,
75
+ id: true,
75
76
  status: true,
76
77
  price: false,
77
78
  });
78
79
  });
79
80
 
81
+ it('does not allow hiding the last remaining column', () => {
82
+ expect(
83
+ canHideVisibleColumn({
84
+ columns,
85
+ fieldName: 'status',
86
+ visibleColumns: {id: true, status: false, price: false},
87
+ }),
88
+ ).toBe(false);
89
+ });
90
+
80
91
  it('builds the company, route and store preference scope', () => {
81
92
  global.location = {pathname: '/order-history-page'};
82
93