@controleonline/ui-common 1.2.70

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 (203) hide show
  1. package/.github/agents/developer.agent.md +30 -0
  2. package/.github/agents/devops.agent.md +30 -0
  3. package/.github/agents/qa.agent.md +30 -0
  4. package/.github/agents/security.agent.md +30 -0
  5. package/.github/workflows/npmjs.yml +35 -0
  6. package/.github/workflows/pull-request-checks.yml +19 -0
  7. package/.scrutinizer.yml +24 -0
  8. package/FUNDING.yml +1 -0
  9. package/package.json +28 -0
  10. package/src/api/fetch.js +74 -0
  11. package/src/api/index.js +155 -0
  12. package/src/api/localDB.js +131 -0
  13. package/src/api/queue.js +66 -0
  14. package/src/react/assets/tap.mp3 +0 -0
  15. package/src/react/components/AddImportModal.js +157 -0
  16. package/src/react/components/AddImportModal.styles.js +81 -0
  17. package/src/react/components/BackgroundRuntimeBridge.js +219 -0
  18. package/src/react/components/BottomNavigationBar.config.js +238 -0
  19. package/src/react/components/BottomNavigationBar.js +120 -0
  20. package/src/react/components/BottomNavigationBar.styles.js +110 -0
  21. package/src/react/components/CategoryForm.js +572 -0
  22. package/src/react/components/CategoryForm.styles.js +334 -0
  23. package/src/react/components/ConfirmModal.js +24 -0
  24. package/src/react/components/ConfirmModal.styles.js +43 -0
  25. package/src/react/components/ContextHelpButton.js +69 -0
  26. package/src/react/components/ContextHelpButton.styles.js +62 -0
  27. package/src/react/components/DefaultProvider.native.js +848 -0
  28. package/src/react/components/DefaultProvider.styles.js +21 -0
  29. package/src/react/components/DefaultProvider.web.js +909 -0
  30. package/src/react/components/DeliveryPushBridge.native.js +314 -0
  31. package/src/react/components/DeliveryPushBridge.web.js +5 -0
  32. package/src/react/components/DeviceAlertSoundService.js +499 -0
  33. package/src/react/components/EntityLogContent.js +909 -0
  34. package/src/react/components/EntityLogContent.styles.js +400 -0
  35. package/src/react/components/EventBus.js +12 -0
  36. package/src/react/components/KioskModeBridge.js +65 -0
  37. package/src/react/components/LauncherModeBridge.js +47 -0
  38. package/src/react/components/LinkedOrderProductsTab.js +388 -0
  39. package/src/react/components/LinkedOrderProductsTab.styles.js +180 -0
  40. package/src/react/components/ManagerPushBridge.native.js +345 -0
  41. package/src/react/components/MessageService.js +314 -0
  42. package/src/react/components/Paywall/Google.js +89 -0
  43. package/src/react/components/PrintService.js +778 -0
  44. package/src/react/components/ProductCatalogCacheService.js +45 -0
  45. package/src/react/components/RemoteCheckoutService.js +292 -0
  46. package/src/react/components/RuntimeBottomNavigationBar.js +151 -0
  47. package/src/react/components/RuntimeInfoFooter.js +214 -0
  48. package/src/react/components/RuntimeInfoFooter.styles.js +56 -0
  49. package/src/react/components/SystemErrorToast.js +29 -0
  50. package/src/react/components/SystemErrorToast.styles.js +38 -0
  51. package/src/react/components/TouchFeedbackProvider.js +65 -0
  52. package/src/react/components/UnifiedPaymentBar.js +155 -0
  53. package/src/react/components/UnifiedPaymentBar.styles.js +174 -0
  54. package/src/react/components/WebsocketListener.native.js +487 -0
  55. package/src/react/components/WebsocketListener.web.js +102 -0
  56. package/src/react/components/inputs/IdInput.js +49 -0
  57. package/src/react/components/inputs/IdInput.styles.js +26 -0
  58. package/src/react/components/inputs/InvoiceDueDateFilterInput.js +74 -0
  59. package/src/react/components/inputs/InvoiceDueDateFilterInput.styles.js +34 -0
  60. package/src/react/components/inputs/InvoiceDueDateRangeFilterInput.js +115 -0
  61. package/src/react/components/inputs/InvoiceDueDateRangeFilterInput.styles.js +39 -0
  62. package/src/react/components/lists/CategoriesList.js +56 -0
  63. package/src/react/components/lists/PaymentTypeList.js +55 -0
  64. package/src/react/components/lists/ReceiverList.js +56 -0
  65. package/src/react/components/lists/SelectList.styles.js +18 -0
  66. package/src/react/components/lists/StatusList.js +55 -0
  67. package/src/react/components/lists/WalletList.js +54 -0
  68. package/src/react/components/radio/Spotify.js +144 -0
  69. package/src/react/components/radio/Spotify.styles.js +32 -0
  70. package/src/react/components/radio/YouTube.js +82 -0
  71. package/src/react/components/radio/YouTube.styles.js +16 -0
  72. package/src/react/components/toastConfig.js +16 -0
  73. package/src/react/config/deviceConfigBootstrap.js +571 -0
  74. package/src/react/index.js +4 -0
  75. package/src/react/localStorage.js +30 -0
  76. package/src/react/pages/EntityLogPage.js +124 -0
  77. package/src/react/pages/EntityLogPage.styles.js +17 -0
  78. package/src/react/pages/GenericLogPage.js +760 -0
  79. package/src/react/pages/GenericLogPage.styles.js +401 -0
  80. package/src/react/pages/Imports.js +361 -0
  81. package/src/react/pages/Imports.styles.js +223 -0
  82. package/src/react/pages/SettingsPage/PaymentTypesByWalletTab.js +462 -0
  83. package/src/react/pages/SettingsPage/index.js +1171 -0
  84. package/src/react/pages/SettingsPage/index.styles.js +122 -0
  85. package/src/react/print/jobs.js +147 -0
  86. package/src/react/print/providers/local.js +53 -0
  87. package/src/react/print/providers/remote.js +81 -0
  88. package/src/react/print/selection.js +296 -0
  89. package/src/react/print/usePrintButtonController.js +474 -0
  90. package/src/react/router/routes.js +42 -0
  91. package/src/react/services/NetworkPrinterService.native.js +391 -0
  92. package/src/react/services/NetworkPrinterService.web.js +15 -0
  93. package/src/react/stores/index.js +128 -0
  94. package/src/react/stores/storeErrorBridge.js +36 -0
  95. package/src/react/utils/backgroundRuntimeRegistration.js +69 -0
  96. package/src/react/utils/cashPayment.js +87 -0
  97. package/src/react/utils/commercialDocumentOrders.js +269 -0
  98. package/src/react/utils/dateRangeFilter.js +264 -0
  99. package/src/react/utils/deviceRuntime.js +193 -0
  100. package/src/react/utils/entityDisplay.js +231 -0
  101. package/src/react/utils/entityLog.js +649 -0
  102. package/src/react/utils/fileUrl.js +102 -0
  103. package/src/react/utils/frontendDebugLog.js +45 -0
  104. package/src/react/utils/googleMapsConfig.js +49 -0
  105. package/src/react/utils/importStatus.js +100 -0
  106. package/src/react/utils/invoiceDueDateMessages.js +14 -0
  107. package/src/react/utils/invoicePresentation.js +46 -0
  108. package/src/react/utils/logSettings.js +143 -0
  109. package/src/react/utils/maintenanceSettings.js +53 -0
  110. package/src/react/utils/managerOrderNotifications.js +523 -0
  111. package/src/react/utils/mapNavigation.js +76 -0
  112. package/src/react/utils/menuCatalogConfig.js +8 -0
  113. package/src/react/utils/menuCatalogDownload.js +157 -0
  114. package/src/react/utils/networkCameraDevices.js +175 -0
  115. package/src/react/utils/networkDeviceProfiles.js +135 -0
  116. package/src/react/utils/normalizedCatalogDownload.js +157 -0
  117. package/src/react/utils/notificationNavigation.js +94 -0
  118. package/src/react/utils/notificationSound.js +42 -0
  119. package/src/react/utils/paymentDevices.js +397 -0
  120. package/src/react/utils/paymentGatewayExecution.js +91 -0
  121. package/src/react/utils/paymentOptions.js +88 -0
  122. package/src/react/utils/peopleDisplay.js +39 -0
  123. package/src/react/utils/printerDevices.js +465 -0
  124. package/src/react/utils/remotePayment.js +61 -0
  125. package/src/react/utils/runtimeFooter.js +475 -0
  126. package/src/react/utils/runtimeLanguage.js +50 -0
  127. package/src/react/utils/runtimeMenu.js +224 -0
  128. package/src/react/utils/screenMetrics.js +30 -0
  129. package/src/react/utils/shopConfig.js +294 -0
  130. package/src/react/utils/shopFranchises.js +114 -0
  131. package/src/react/utils/socketRuntimePipeline.js +454 -0
  132. package/src/react/utils/spoolAckTracker.js +77 -0
  133. package/src/react/utils/storeColumns.js +427 -0
  134. package/src/react/utils/systemErrorChannel.js +109 -0
  135. package/src/react/utils/systemErrorMessage.js +67 -0
  136. package/src/react/utils/toastPresentation.js +53 -0
  137. package/src/react/utils/websocketSharedRuntime.js +826 -0
  138. package/src/store/acl/getters.js +4 -0
  139. package/src/store/acl/index.js +19 -0
  140. package/src/store/acl/mutation_types.js +4 -0
  141. package/src/store/acl/mutations.js +17 -0
  142. package/src/store/address/city.js +22 -0
  143. package/src/store/categories/category_file/index.js +25 -0
  144. package/src/store/categories/index.js +93 -0
  145. package/src/store/configs/customActions.js +131 -0
  146. package/src/store/configs/index.js +25 -0
  147. package/src/store/connections/customActions.js +26 -0
  148. package/src/store/connections/index.js +124 -0
  149. package/src/store/device/index.js +22 -0
  150. package/src/store/device_config/customActions.js +190 -0
  151. package/src/store/device_config/index.js +28 -0
  152. package/src/store/entity_log/customActions.js +63 -0
  153. package/src/store/entity_log/index.js +25 -0
  154. package/src/store/extra/data.js +85 -0
  155. package/src/store/extra/fields.js +88 -0
  156. package/src/store/file/actions.js +27 -0
  157. package/src/store/file/index.js +24 -0
  158. package/src/store/imports/index.js +88 -0
  159. package/src/store/print/customActions.js +251 -0
  160. package/src/store/print/index.js +28 -0
  161. package/src/store/printer/customActions.js +54 -0
  162. package/src/store/printer/index.js +26 -0
  163. package/src/store/runtime_debug/customActions.js +71 -0
  164. package/src/store/runtime_debug/index.js +30 -0
  165. package/src/store/status/index.js +65 -0
  166. package/src/store/timezones/index.js +43 -0
  167. package/src/store/websocket/customActions.js +24 -0
  168. package/src/store/websocket/index.js +28 -0
  169. package/src/tests/react/components/LauncherModeBridge.test.js +93 -0
  170. package/src/tests/react/config/deviceConfigBootstrap.test.js +337 -0
  171. package/src/tests/react/print/localPrintProvider.test.js +45 -0
  172. package/src/tests/react/utils/backgroundRuntimeRegistration.test.js +123 -0
  173. package/src/tests/react/utils/cashPayment.test.js +41 -0
  174. package/src/tests/react/utils/dateRangeFilter.test.mjs +29 -0
  175. package/src/tests/react/utils/entityDisplay.test.js +18 -0
  176. package/src/tests/react/utils/googleMapsConfig.test.js +32 -0
  177. package/src/tests/react/utils/importStatus.test.js +85 -0
  178. package/src/tests/react/utils/invoicePresentation.test.mjs +40 -0
  179. package/src/tests/react/utils/managerOrderNotifications.test.js +127 -0
  180. package/src/tests/react/utils/mapNavigation.test.js +58 -0
  181. package/src/tests/react/utils/notificationNavigation.test.js +39 -0
  182. package/src/tests/react/utils/notificationSound.test.js +27 -0
  183. package/src/tests/react/utils/paymentDevices.test.js +88 -0
  184. package/src/tests/react/utils/runtimeFooter.test.js +429 -0
  185. package/src/tests/react/utils/runtimeLanguage.test.js +80 -0
  186. package/src/tests/react/utils/runtimeMenu.test.js +174 -0
  187. package/src/tests/react/utils/shopFranchises.test.js +82 -0
  188. package/src/tests/react/utils/socketRuntimePipeline.test.js +124 -0
  189. package/src/tests/react/utils/spoolAckTracker.test.js +40 -0
  190. package/src/tests/react/utils/storeErrorBridge.test.js +66 -0
  191. package/src/tests/react/utils/systemErrorChannel.test.js +58 -0
  192. package/src/tests/react/utils/systemErrorMessage.test.js +59 -0
  193. package/src/tests/react/utils/toastPresentation.test.js +75 -0
  194. package/src/tests/react/utils/translate.test.mjs +396 -0
  195. package/src/tests/react/utils/websocketSharedRuntime.test.js +245 -0
  196. package/src/utils/apiEntryPoint.js +31 -0
  197. package/src/utils/appDomain.js +50 -0
  198. package/src/utils/config.js +14 -0
  199. package/src/utils/formatter.js +419 -0
  200. package/src/utils/integrationConfigs.js +79 -0
  201. package/src/utils/methods.js +23 -0
  202. package/src/utils/oauth.js +42 -0
  203. package/src/utils/translate.js +620 -0
@@ -0,0 +1,93 @@
1
+ const React = require('react');
2
+ const renderer = require('react-test-renderer');
3
+ const {jest} = require('@jest/globals');
4
+
5
+ const {beforeEach, describe, expect, it} = global;
6
+ global.IS_REACT_ACT_ENVIRONMENT = true;
7
+
8
+ const mockSetLauncherMode = jest.fn(() => Promise.resolve({}));
9
+ const mockBackHandlerAddEventListener = jest.fn(() => ({
10
+ remove: jest.fn(),
11
+ }));
12
+ const mockUseStore = jest.fn(name => {
13
+ if (name === 'device_config') {
14
+ return {
15
+ getters: {
16
+ item: {
17
+ configs: {
18
+ 'android-launcher-enabled': '1',
19
+ },
20
+ },
21
+ },
22
+ };
23
+ }
24
+
25
+ return {
26
+ getters: {},
27
+ };
28
+ });
29
+
30
+ jest.mock('@env', () => ({
31
+ env: {
32
+ APP_TYPE: 'POS',
33
+ },
34
+ }));
35
+
36
+ jest.mock('@store', () => ({
37
+ useStore: mockUseStore,
38
+ }));
39
+
40
+ jest.mock('react-native', () => ({
41
+ AppState: {
42
+ currentState: 'active',
43
+ },
44
+ BackHandler: {
45
+ addEventListener: mockBackHandlerAddEventListener,
46
+ },
47
+ NativeModules: {
48
+ LauncherMode: {
49
+ setLauncherMode: mockSetLauncherMode,
50
+ },
51
+ },
52
+ Platform: {
53
+ OS: 'android',
54
+ },
55
+ }));
56
+
57
+ const LauncherModeBridge =
58
+ require('../../../react/components/LauncherModeBridge').default;
59
+
60
+ describe('LauncherModeBridge', () => {
61
+ beforeEach(() => {
62
+ mockSetLauncherMode.mockClear();
63
+ mockBackHandlerAddEventListener.mockClear();
64
+ mockUseStore.mockClear();
65
+ });
66
+
67
+ it('requests launcher mode on mount and reasserts it after returning active', async () => {
68
+ let tree;
69
+
70
+ await renderer.act(async () => {
71
+ tree = renderer.create(React.createElement(LauncherModeBridge));
72
+ });
73
+
74
+ expect(mockSetLauncherMode).toHaveBeenCalledTimes(1);
75
+ expect(mockSetLauncherMode).toHaveBeenLastCalledWith(true);
76
+ expect(mockBackHandlerAddEventListener).not.toHaveBeenCalled();
77
+
78
+ await renderer.act(async () => {
79
+ tree.update(React.createElement(LauncherModeBridge, {appState: 'background'}));
80
+ });
81
+
82
+ await renderer.act(async () => {
83
+ tree.update(React.createElement(LauncherModeBridge, {appState: 'active'}));
84
+ });
85
+
86
+ expect(mockSetLauncherMode).toHaveBeenCalledTimes(2);
87
+ expect(mockSetLauncherMode).toHaveBeenLastCalledWith(true);
88
+
89
+ await renderer.act(async () => {
90
+ tree.unmount();
91
+ });
92
+ });
93
+ });
@@ -0,0 +1,337 @@
1
+ const {jest} = require('@jest/globals')
2
+
3
+ jest.mock('../../../react/utils/screenMetrics', () => ({
4
+ appendScreenMetrics: configs => configs,
5
+ hasScreenMetricsChanges: () => false,
6
+ }))
7
+
8
+ const {
9
+ buildProviderManagedDeviceConfigs,
10
+ DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY,
11
+ DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY,
12
+ DISPLAY_SIZE_CONFIG_KEY,
13
+ DISPLAY_SIZE_DEFAULT,
14
+ DISPLAY_SIZE_MAX,
15
+ DISPLAY_SIZE_MIN,
16
+ DISPLAY_SIDE_BREAK_CONFIG_KEY,
17
+ POS_AUTO_PRINT_ENABLED_CONFIG_KEY,
18
+ POS_CASH_MANAGEMENT_MODE_CONFIG_KEY,
19
+ POS_DELIVERY_ENABLED_CONFIG_KEY,
20
+ POS_OPERATION_MODE_CONFIG_KEY,
21
+ isPosSingleItemMode,
22
+ isPosAutoPrintEnabled,
23
+ isPosCashRegisterClosed,
24
+ isPosCashRegisterOpen,
25
+ isPosCounterMode,
26
+ isAndroidLauncherEnabled,
27
+ isPosDeliveryEnabled,
28
+ isPosKioskMode,
29
+ isPosSelfServiceMode,
30
+ isDisplaySideBreakEnabled,
31
+ normalizeDisplaySize,
32
+ resolveDisplaySize,
33
+ resolvePosCashManagementMode,
34
+ resolvePosOperationMode,
35
+ resolvePosPrintMode,
36
+ shouldEnableAndroidKioskMode,
37
+ shouldEnableAndroidLauncherMode,
38
+ shouldUsePosCashRegisterLifecycle,
39
+ isPosTotemMode,
40
+ } = require('../../../react/config/deviceConfigBootstrap')
41
+
42
+ const {describe, expect, it} = global
43
+
44
+ describe('deviceConfigBootstrap POS operation helpers', () => {
45
+ it('normalizes balcão as counter and treats counter as self service', () => {
46
+ const configs = {
47
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'balcao',
48
+ }
49
+
50
+ expect(resolvePosOperationMode(configs)).toBe('counter')
51
+ expect(isPosCounterMode(configs)).toBe(true)
52
+ expect(isPosSelfServiceMode(configs)).toBe(true)
53
+ })
54
+
55
+ it('normalizes venda unitaria as single-item mode', () => {
56
+ const configs = {
57
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'venda unitaria',
58
+ }
59
+
60
+ expect(resolvePosOperationMode(configs)).toBe('single-item')
61
+ expect(isPosSingleItemMode(configs)).toBe(true)
62
+ expect(isPosSelfServiceMode(configs)).toBe(false)
63
+ })
64
+
65
+ it('keeps counter auto print disabled by default and allows explicit enablement', () => {
66
+ const counterConfigs = {
67
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'counter',
68
+ }
69
+
70
+ expect(isPosAutoPrintEnabled(counterConfigs)).toBe(false)
71
+
72
+ expect(
73
+ isPosAutoPrintEnabled({
74
+ ...counterConfigs,
75
+ [POS_AUTO_PRINT_ENABLED_CONFIG_KEY]: '1',
76
+ }),
77
+ ).toBe(true)
78
+ })
79
+
80
+ it('defaults non-counter modes to auto print enabled', () => {
81
+ expect(
82
+ isPosAutoPrintEnabled({
83
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'cashier',
84
+ }),
85
+ ).toBe(true)
86
+ })
87
+
88
+ it('resolves counter daily close mode and skips cash register lifecycle', () => {
89
+ const configs = {
90
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'counter',
91
+ [POS_CASH_MANAGEMENT_MODE_CONFIG_KEY]: 'daily',
92
+ }
93
+
94
+ expect(resolvePosCashManagementMode(configs)).toBe('daily')
95
+ expect(shouldUsePosCashRegisterLifecycle(configs)).toBe(false)
96
+ expect(isPosCashRegisterOpen(configs)).toBe(true)
97
+ expect(isPosCashRegisterClosed(configs)).toBe(false)
98
+ })
99
+
100
+ it('requires cash register lifecycle for counter with open/close policy', () => {
101
+ const closedConfigs = {
102
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'counter',
103
+ [POS_CASH_MANAGEMENT_MODE_CONFIG_KEY]: 'cash-register',
104
+ 'cash-wallet-closed-id': 1,
105
+ }
106
+
107
+ expect(shouldUsePosCashRegisterLifecycle(closedConfigs)).toBe(true)
108
+ expect(isPosCashRegisterClosed(closedConfigs)).toBe(true)
109
+
110
+ expect(
111
+ isPosCashRegisterOpen({
112
+ ...closedConfigs,
113
+ 'cash-wallet-closed-id': 0,
114
+ }),
115
+ ).toBe(true)
116
+ })
117
+
118
+ it('keeps empty configs open until the runtime loads the real cash register state', () => {
119
+ expect(isPosCashRegisterOpen({})).toBe(true)
120
+ expect(isPosCashRegisterClosed({})).toBe(false)
121
+ })
122
+
123
+ it('keeps configs without cash-wallet-closed-id open during provider bootstrap', () => {
124
+ const configs = {
125
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'cashier',
126
+ 'config-version': '1.0.0',
127
+ 'pos-gateway': 'cielo',
128
+ }
129
+
130
+ expect(isPosCashRegisterOpen(configs)).toBe(true)
131
+ expect(isPosCashRegisterClosed(configs)).toBe(false)
132
+ })
133
+
134
+ it('preserves a manually configured pos gateway during provider sync', () => {
135
+ const {nextConfigs, needsUpdate} = buildProviderManagedDeviceConfigs({
136
+ appVersion: '1.3.74',
137
+ configs: {
138
+ 'config-version': '1.3.74',
139
+ 'pos-gateway': 'cielo',
140
+ },
141
+ deviceInfo: {
142
+ isEmulator: true,
143
+ manufacturer: 'Google',
144
+ },
145
+ })
146
+
147
+ expect(nextConfigs['pos-gateway']).toBe('cielo')
148
+ expect(needsUpdate).toBe(false)
149
+ })
150
+
151
+ it('keeps totem without cash register lifecycle and normalizes print mode', () => {
152
+ const configs = {
153
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'totem',
154
+ 'print-mode': 'form',
155
+ }
156
+
157
+ expect(resolvePosOperationMode(configs)).toBe('totem')
158
+ expect(isPosTotemMode(configs)).toBe(true)
159
+ expect(isPosKioskMode(configs)).toBe(true)
160
+ expect(shouldUsePosCashRegisterLifecycle(configs)).toBe(false)
161
+ expect(resolvePosPrintMode(configs)).toBe('form')
162
+ })
163
+
164
+ it('does not accept the legacy kiosk operation mode value', () => {
165
+ expect(
166
+ resolvePosOperationMode({
167
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'kiosk',
168
+ }),
169
+ ).toBe('')
170
+ expect(
171
+ isPosTotemMode({
172
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'kiosk',
173
+ }),
174
+ ).toBe(false)
175
+ expect(
176
+ isPosKioskMode({
177
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'kiosk',
178
+ }),
179
+ ).toBe(false)
180
+ })
181
+
182
+ it('defaults display size to 5 and clamps the configured range to 1..10', () => {
183
+ expect(resolveDisplaySize({})).toBe(DISPLAY_SIZE_DEFAULT)
184
+ expect(
185
+ resolveDisplaySize({
186
+ [DISPLAY_SIZE_CONFIG_KEY]: '1',
187
+ }),
188
+ ).toBe(DISPLAY_SIZE_MIN)
189
+ expect(
190
+ normalizeDisplaySize('18'),
191
+ ).toBe(DISPLAY_SIZE_MAX)
192
+ })
193
+
194
+ it('treats display side break as an explicit boolean flag', () => {
195
+ expect(isDisplaySideBreakEnabled({})).toBe(false)
196
+ expect(
197
+ isDisplaySideBreakEnabled({
198
+ [DISPLAY_SIDE_BREAK_CONFIG_KEY]: '1',
199
+ }),
200
+ ).toBe(true)
201
+ })
202
+
203
+ it('does not enable Android kiosk without the explicit device flag', () => {
204
+ expect(
205
+ shouldEnableAndroidKioskMode({
206
+ appType: 'POS',
207
+ configs: {
208
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'totem',
209
+ },
210
+ platform: 'android',
211
+ }),
212
+ ).toBe(false)
213
+
214
+ expect(
215
+ shouldEnableAndroidKioskMode({
216
+ appType: 'POS',
217
+ configs: {
218
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'totem',
219
+ },
220
+ platform: 'android',
221
+ }),
222
+ ).toBe(false)
223
+ })
224
+
225
+ it('respects the explicit Android kiosk flag independently of the operation mode', () => {
226
+ expect(
227
+ shouldEnableAndroidKioskMode({
228
+ appType: 'POS',
229
+ configs: {
230
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'counter',
231
+ [DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY]: '1',
232
+ },
233
+ platform: 'android',
234
+ }),
235
+ ).toBe(true)
236
+
237
+ expect(
238
+ shouldEnableAndroidKioskMode({
239
+ appType: 'POS',
240
+ configs: {
241
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'totem',
242
+ [DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY]: '0',
243
+ },
244
+ platform: 'android',
245
+ }),
246
+ ).toBe(false)
247
+
248
+ expect(
249
+ shouldEnableAndroidKioskMode({
250
+ appType: 'MANAGER',
251
+ configs: {
252
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'counter',
253
+ [DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY]: '1',
254
+ },
255
+ platform: 'android',
256
+ }),
257
+ ).toBe(false)
258
+
259
+ expect(
260
+ shouldEnableAndroidKioskMode({
261
+ appType: 'POS',
262
+ configs: {
263
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'counter',
264
+ [DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY]: '1',
265
+ },
266
+ platform: 'web',
267
+ }),
268
+ ).toBe(false)
269
+ })
270
+
271
+ it('does not enable Android launcher without the explicit device flag', () => {
272
+ expect(
273
+ isAndroidLauncherEnabled({
274
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'totem',
275
+ }),
276
+ ).toBe(false)
277
+
278
+ expect(
279
+ shouldEnableAndroidLauncherMode({
280
+ appType: 'POS',
281
+ configs: {
282
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'totem',
283
+ },
284
+ platform: 'android',
285
+ }),
286
+ ).toBe(false)
287
+ })
288
+
289
+ it('respects the explicit Android launcher flag independently of the operation mode', () => {
290
+ expect(
291
+ shouldEnableAndroidLauncherMode({
292
+ appType: 'POS',
293
+ configs: {
294
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'counter',
295
+ [DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY]: '1',
296
+ },
297
+ platform: 'android',
298
+ }),
299
+ ).toBe(true)
300
+
301
+ expect(
302
+ shouldEnableAndroidLauncherMode({
303
+ appType: 'MANAGER',
304
+ configs: {
305
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'counter',
306
+ [DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY]: '1',
307
+ },
308
+ platform: 'android',
309
+ }),
310
+ ).toBe(false)
311
+
312
+ expect(
313
+ shouldEnableAndroidLauncherMode({
314
+ appType: 'POS',
315
+ configs: {
316
+ [POS_OPERATION_MODE_CONFIG_KEY]: 'counter',
317
+ [DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY]: '1',
318
+ },
319
+ platform: 'web',
320
+ }),
321
+ ).toBe(false)
322
+ })
323
+
324
+ it('keeps delivery enabled by default and respects explicit disablement', () => {
325
+ expect(isPosDeliveryEnabled({})).toBe(true)
326
+ expect(
327
+ isPosDeliveryEnabled({
328
+ [POS_DELIVERY_ENABLED_CONFIG_KEY]: '0',
329
+ }),
330
+ ).toBe(false)
331
+ expect(
332
+ isPosDeliveryEnabled({
333
+ [POS_DELIVERY_ENABLED_CONFIG_KEY]: '1',
334
+ }),
335
+ ).toBe(true)
336
+ })
337
+ })
@@ -0,0 +1,45 @@
1
+ const {jest} = require('@jest/globals')
2
+
3
+ const mockPrint = jest.fn()
4
+
5
+ jest.mock('@controleonline/ui-orders/src/react/services/Cielo/Print', () => ({
6
+ CieloPrint: jest.fn().mockImplementation(() => ({
7
+ print: mockPrint,
8
+ })),
9
+ }))
10
+
11
+ const {describe, expect, it, beforeEach} = global
12
+
13
+ const {
14
+ LOCAL_CIELO_PRINT_UNAVAILABLE_MESSAGE,
15
+ printOnLocalCielo,
16
+ } = require('../../../react/print/providers/local')
17
+
18
+ describe('local print provider', () => {
19
+ beforeEach(() => {
20
+ mockPrint.mockReset()
21
+ })
22
+
23
+ it('normalizes missing local Cielo handler errors', async () => {
24
+ mockPrint.mockResolvedValue({
25
+ success: false,
26
+ result:
27
+ 'No Activity found to handle Intent { act=android.intent.action.VIEW dat=lio://print/... }',
28
+ })
29
+
30
+ await expect(printOnLocalCielo('payload')).rejects.toThrow(
31
+ LOCAL_CIELO_PRINT_UNAVAILABLE_MESSAGE,
32
+ )
33
+ })
34
+
35
+ it('keeps explicit provider error messages when available', async () => {
36
+ mockPrint.mockResolvedValue({
37
+ success: false,
38
+ result: 'Papel ausente.',
39
+ })
40
+
41
+ await expect(printOnLocalCielo('payload')).rejects.toThrow(
42
+ 'Papel ausente.',
43
+ )
44
+ })
45
+ })
@@ -0,0 +1,123 @@
1
+ const {jest} = require('@jest/globals');
2
+
3
+ const {
4
+ syncBackgroundRuntimeRegistration,
5
+ } = require('../../../react/utils/backgroundRuntimeRegistration');
6
+
7
+ const {describe, expect, it, beforeEach} = global;
8
+
9
+ const buildModule = () => ({
10
+ clearRegistration: jest.fn(() => Promise.resolve('removed')),
11
+ syncRegistration: jest.fn(() => Promise.resolve('started')),
12
+ });
13
+
14
+ const buildRefs = () => ({
15
+ lastRegistrationIdRef: {current: ''},
16
+ lastRegistrationPayloadRef: {current: ''},
17
+ });
18
+
19
+ describe('backgroundRuntimeRegistration lifecycle', () => {
20
+ let backgroundRuntimeModule;
21
+
22
+ beforeEach(() => {
23
+ backgroundRuntimeModule = buildModule();
24
+ });
25
+
26
+ it('syncs a valid registration and does not create an unmount cleanup', () => {
27
+ const refs = buildRefs();
28
+
29
+ const result = syncBackgroundRuntimeRegistration({
30
+ backgroundRuntimeModule,
31
+ registration: {
32
+ registrationId: 'com.controleonline.manager::device-1::company-1',
33
+ packageName: 'com.controleonline.manager',
34
+ companyId: 'company-1',
35
+ deviceId: 'device-1',
36
+ backgroundEnabled: true,
37
+ socketUrl: 'wss://example.test/socket',
38
+ token: 'session-token',
39
+ },
40
+ ...refs,
41
+ });
42
+
43
+ expect(result).toBeUndefined();
44
+ expect(backgroundRuntimeModule.syncRegistration).toHaveBeenCalledTimes(1);
45
+ expect(backgroundRuntimeModule.clearRegistration).not.toHaveBeenCalled();
46
+ expect(refs.lastRegistrationIdRef.current).toBe(
47
+ 'com.controleonline.manager::device-1::company-1',
48
+ );
49
+ });
50
+
51
+ it('clears the registration when the session becomes invalid', () => {
52
+ const refs = buildRefs();
53
+ const registration = {
54
+ registrationId: 'com.controleonline.manager::device-1::company-1',
55
+ packageName: 'com.controleonline.manager',
56
+ companyId: 'company-1',
57
+ deviceId: 'device-1',
58
+ backgroundEnabled: true,
59
+ socketUrl: 'wss://example.test/socket',
60
+ token: 'session-token',
61
+ };
62
+
63
+ syncBackgroundRuntimeRegistration({
64
+ backgroundRuntimeModule,
65
+ registration,
66
+ ...refs,
67
+ });
68
+
69
+ expect(backgroundRuntimeModule.syncRegistration).toHaveBeenCalledTimes(1);
70
+ expect(backgroundRuntimeModule.clearRegistration).not.toHaveBeenCalled();
71
+
72
+ syncBackgroundRuntimeRegistration({
73
+ backgroundRuntimeModule,
74
+ registration: null,
75
+ ...refs,
76
+ });
77
+
78
+ expect(backgroundRuntimeModule.clearRegistration).toHaveBeenCalledTimes(1);
79
+ expect(backgroundRuntimeModule.clearRegistration).toHaveBeenCalledWith(
80
+ 'com.controleonline.manager::device-1::company-1',
81
+ );
82
+ });
83
+
84
+ it('replaces the previous registration when the company changes', () => {
85
+ const refs = buildRefs();
86
+
87
+ syncBackgroundRuntimeRegistration({
88
+ backgroundRuntimeModule,
89
+ registration: {
90
+ registrationId: 'com.controleonline.manager::device-1::company-1',
91
+ packageName: 'com.controleonline.manager',
92
+ companyId: 'company-1',
93
+ deviceId: 'device-1',
94
+ backgroundEnabled: true,
95
+ socketUrl: 'wss://example.test/socket',
96
+ token: 'session-token',
97
+ },
98
+ ...refs,
99
+ });
100
+
101
+ syncBackgroundRuntimeRegistration({
102
+ backgroundRuntimeModule,
103
+ registration: {
104
+ registrationId: 'com.controleonline.manager::device-1::company-2',
105
+ packageName: 'com.controleonline.manager',
106
+ companyId: 'company-2',
107
+ deviceId: 'device-1',
108
+ backgroundEnabled: true,
109
+ socketUrl: 'wss://example.test/socket',
110
+ token: 'session-token',
111
+ },
112
+ ...refs,
113
+ });
114
+
115
+ expect(backgroundRuntimeModule.clearRegistration).toHaveBeenCalledWith(
116
+ 'com.controleonline.manager::device-1::company-1',
117
+ );
118
+ expect(backgroundRuntimeModule.syncRegistration).toHaveBeenCalledTimes(2);
119
+ expect(refs.lastRegistrationIdRef.current).toBe(
120
+ 'com.controleonline.manager::device-1::company-2',
121
+ );
122
+ });
123
+ });
@@ -0,0 +1,41 @@
1
+ const {
2
+ isGatewayFreePayment,
3
+ shouldBypassGatewayForPayment,
4
+ } = require('../../../react/utils/cashPayment')
5
+
6
+ const {describe, expect, it} = global
7
+
8
+ describe('cashPayment gateway bypass rules', () => {
9
+ it('treats DINHEIRO as a gateway-free payment even when a payment code exists', () => {
10
+ const payment = {
11
+ wallet: {id: 1},
12
+ paymentCode: 'DINHEIRO',
13
+ paymentType: {id: 22, paymentType: 'Dinheiro'},
14
+ }
15
+
16
+ expect(shouldBypassGatewayForPayment(payment)).toBe(true)
17
+ expect(isGatewayFreePayment(payment)).toBe(true)
18
+ })
19
+
20
+ it('treats courtesy voucher as a gateway-free payment', () => {
21
+ const payment = {
22
+ wallet: {id: 1},
23
+ paymentCode: 'VOUCHER_CORTESIA',
24
+ paymentType: {id: 12, paymentType: 'Cartão Gratidão'},
25
+ }
26
+
27
+ expect(shouldBypassGatewayForPayment(payment)).toBe(true)
28
+ expect(isGatewayFreePayment(payment)).toBe(true)
29
+ })
30
+
31
+ it('keeps card payments integrated when they have a real gateway code', () => {
32
+ const payment = {
33
+ wallet: {id: 1},
34
+ paymentCode: 'CREDITO_AVISTA',
35
+ paymentType: {id: 8, paymentType: 'Crédito à Vista'},
36
+ }
37
+
38
+ expect(shouldBypassGatewayForPayment(payment)).toBe(false)
39
+ expect(isGatewayFreePayment(payment)).toBe(false)
40
+ })
41
+ })
@@ -0,0 +1,29 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+
4
+ import {
5
+ buildDateFilterOptions,
6
+ getDateRange,
7
+ resolveDateRangeSummary,
8
+ } from '../../../react/utils/dateRangeFilter.js';
9
+
10
+ test('keeps 90d available in the shared date filter contract', () => {
11
+ const baseDate = new Date(2026, 5, 8, 12, 0, 0, 0);
12
+
13
+ assert.deepEqual(buildDateFilterOptions(['90d']), [
14
+ { key: '90d', label: '90 dias' },
15
+ ]);
16
+
17
+ assert.deepEqual(
18
+ getDateRange('90d', null, { baseDate }),
19
+ {
20
+ after: '2026-03-11 00:00:00',
21
+ before: '2026-06-08 23:59:59',
22
+ },
23
+ );
24
+
25
+ assert.equal(
26
+ resolveDateRangeSummary('90d', null, { baseDate }),
27
+ '11/03/2026 - 08/06/2026',
28
+ );
29
+ });
@@ -0,0 +1,18 @@
1
+ const {describe, expect, it} = global;
2
+
3
+ const {
4
+ formatDisplayUppercase,
5
+ uppercaseText,
6
+ } = require('../../../react/utils/entityDisplay');
7
+
8
+ describe('entityDisplay helpers', () => {
9
+ it('uppercases raw text with accented characters correctly', () => {
10
+ expect(uppercaseText('Cláudia')).toBe('CLÁUDIA');
11
+ expect(uppercaseText('Kibelicia Comida árabe')).toBe('KIBELICIA COMIDA ÁRABE');
12
+ });
13
+
14
+ it('uppercases pt-BR strings with cedilla correctly', () => {
15
+ expect(formatDisplayUppercase('Jagunços')).toBe('JAGUNÇOS');
16
+ expect(formatDisplayUppercase('Empório Jagunços Ltda')).toBe('EMPÓRIO JAGUNÇOS LTDA');
17
+ });
18
+ });