@controleonline/ui-common 1.2.137 → 1.2.141
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.
- package/.release/rc-manifest.json +6 -6
- package/package.json +3 -2
- package/src/react/components/ConversationAlertService.native.js +3 -0
- package/src/react/components/ConversationAlertService.web.js +87 -0
- package/src/react/components/DefaultProvider.web.js +2 -0
- package/src/react/utils/conversationAlert.js +28 -0
- package/src/react/utils/runtimeMenu.js +1 -190
- package/src/tests/react/utils/conversationAlert.test.js +19 -0
- package/src/tests/react/utils/runtimeMenu.test.js +4 -95
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.
|
|
2
|
+
"version": "1.2.141",
|
|
3
3
|
"rc": 1,
|
|
4
|
-
"branch": "rc/1.2.
|
|
5
|
-
"baseMaster": "
|
|
6
|
-
"baseTag": "v1.2.
|
|
4
|
+
"branch": "rc/1.2.141-rc.1",
|
|
5
|
+
"baseMaster": "37059521852cd73265e08e87f335a1473c6b3531",
|
|
6
|
+
"baseTag": "v1.2.140",
|
|
7
7
|
"tasks": [
|
|
8
|
-
|
|
8
|
+
1766
|
|
9
9
|
],
|
|
10
10
|
"frozen": true,
|
|
11
11
|
"repositories": {
|
|
12
|
-
"ControleOnline/ui-common": "
|
|
12
|
+
"ControleOnline/ui-common": "ae28b00d8f8b2737c7aa676dc8cce6efb34e1407"
|
|
13
13
|
}
|
|
14
14
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@controleonline/ui-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.141",
|
|
4
4
|
"author": "ControleOnline",
|
|
5
5
|
"description": "ControleOnline Common Quasar UI Component",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/react/index.js",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"test": "npm run test:receita-federal && npm run test:imports-status && npm run test:runtime-language && npm run test:runtime-footer && npm run test:runtime-footer-marquee && npm run test:runtime-footer-platform && npm run test:invoice-presentation && npm run test:system-error-message && npm run test:bottom-navigation-toolbar && npm run test:copy-device-configs && npm run test:print-routing && npm run test:device-detail-dependencies && npm run test:runtime-zoom && npm run test:cash-register-summary && npm run test:linked-order-payload && npm run test:document-file-content && npm run test:order-products-summary && npm run test:client-portfolio",
|
|
9
|
+
"test": "npm run test:receita-federal && npm run test:imports-status && npm run test:runtime-language && npm run test:runtime-footer && npm run test:runtime-footer-marquee && npm run test:runtime-footer-platform && npm run test:invoice-presentation && npm run test:system-error-message && npm run test:bottom-navigation-toolbar && npm run test:copy-device-configs && npm run test:print-routing && npm run test:device-detail-dependencies && npm run test:runtime-zoom && npm run test:cash-register-summary && npm run test:linked-order-payload && npm run test:document-file-content && npm run test:order-products-summary && npm run test:client-portfolio && npm run test:conversation-alert",
|
|
10
|
+
"test:conversation-alert": "node --test src/tests/react/utils/conversationAlert.test.js",
|
|
10
11
|
"test:receita-federal": "node --test src/tests/react/pages/receitaFederalIntegrationContract.test.mjs",
|
|
11
12
|
"test:imports-status": "mkdir -p node_modules/@controleonline && rm -rf node_modules/@controleonline/ui-common && ln -s ../.. node_modules/@controleonline/ui-common && node --test src/tests/react/utils/importStatus.test.js",
|
|
12
13
|
"test:cash-register-summary": "node --test src/tests/react/utils/cashRegisterSummary.test.js",
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Alerta de novas mensagens dos chamados no navegador (app-community#1766).
|
|
3
|
+
* - Fonte: evento `conversation_message` (status `received`) do websocket, o mesmo que atualiza as telas.
|
|
4
|
+
* - Só no MANAGER e no CRM, para a empresa atual, quando a aba não está em foco.
|
|
5
|
+
* - Notificação do navegador; a permissão é pedida no primeiro clique do usuário (o navegador exige um gesto).
|
|
6
|
+
* - Com o navegador fechado, o aviso vem do push (Firebase), não daqui.
|
|
7
|
+
*/
|
|
8
|
+
import {useEffect, useRef} from 'react';
|
|
9
|
+
import {useStores} from '@store';
|
|
10
|
+
import {app_type} from '@appType';
|
|
11
|
+
import {
|
|
12
|
+
conversationAlertContent,
|
|
13
|
+
conversationAlertKey,
|
|
14
|
+
idOf,
|
|
15
|
+
isConversationAlert,
|
|
16
|
+
} from '@controleonline/ui-common/src/react/utils/conversationAlert';
|
|
17
|
+
|
|
18
|
+
const ALERT_APPS = ['MANAGER', 'CRM'];
|
|
19
|
+
const MAX_SEEN = 300;
|
|
20
|
+
|
|
21
|
+
const normalizeText = value => String(value ?? '').trim();
|
|
22
|
+
|
|
23
|
+
const webNotification = () =>
|
|
24
|
+
typeof globalThis !== 'undefined' ? globalThis.Notification : undefined;
|
|
25
|
+
|
|
26
|
+
const isTabFocused = () => {
|
|
27
|
+
if (typeof document === 'undefined') return false;
|
|
28
|
+
if (document.visibilityState === 'hidden') return false;
|
|
29
|
+
return typeof document.hasFocus === 'function' ? document.hasFocus() : true;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const ConversationAlertService = () => {
|
|
33
|
+
const websocketMessages = useStores(state => state?.websocket?.getters?.messages);
|
|
34
|
+
const currentCompany = useStores(state => state?.people?.getters?.currentCompany);
|
|
35
|
+
const seenRef = useRef(new Set());
|
|
36
|
+
const enabled = ALERT_APPS.includes(normalizeText(app_type).toUpperCase());
|
|
37
|
+
const companyId = idOf(currentCompany?.id);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const Notification = webNotification();
|
|
41
|
+
if (!enabled || !Notification || Notification.permission !== 'default' || typeof document === 'undefined') {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const ask = () => {
|
|
45
|
+
document.removeEventListener('click', ask, true);
|
|
46
|
+
try {
|
|
47
|
+
Notification.requestPermission();
|
|
48
|
+
} catch {
|
|
49
|
+
// Navegadores antigos: segue sem alerta.
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
document.addEventListener('click', ask, true);
|
|
53
|
+
return () => document.removeEventListener('click', ask, true);
|
|
54
|
+
}, [enabled]);
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!enabled || !Array.isArray(websocketMessages)) return;
|
|
58
|
+
const Notification = webNotification();
|
|
59
|
+
const seen = seenRef.current;
|
|
60
|
+
websocketMessages.forEach(message => {
|
|
61
|
+
if (!isConversationAlert(message, companyId)) return;
|
|
62
|
+
const key = conversationAlertKey(message);
|
|
63
|
+
if (seen.has(key)) return;
|
|
64
|
+
seen.add(key);
|
|
65
|
+
if (seen.size > MAX_SEEN) seen.delete(seen.values().next().value);
|
|
66
|
+
if (!Notification || Notification.permission !== 'granted' || isTabFocused()) return;
|
|
67
|
+
try {
|
|
68
|
+
const {title, body, tag} = conversationAlertContent(message);
|
|
69
|
+
const notification = new Notification(title, {body, tag, renotify: true});
|
|
70
|
+
notification.onclick = () => {
|
|
71
|
+
try {
|
|
72
|
+
globalThis.focus?.();
|
|
73
|
+
notification.close();
|
|
74
|
+
} catch {
|
|
75
|
+
// ignora
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
} catch {
|
|
79
|
+
// Sem permissão ou bloqueado pelo navegador.
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}, [companyId, enabled, websocketMessages]);
|
|
83
|
+
|
|
84
|
+
return null;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default ConversationAlertService;
|
|
@@ -14,6 +14,7 @@ import { View } from 'react-native';
|
|
|
14
14
|
import Translate from '@controleonline/ui-common/src/utils/translate';
|
|
15
15
|
import { WebsocketListener } from '@controleonline/ui-common/src/react/components/WebsocketListener';
|
|
16
16
|
import DeviceAlertSoundService from '@controleonline/ui-common/src/react/components/DeviceAlertSoundService';
|
|
17
|
+
import ConversationAlertService from '@controleonline/ui-common/src/react/components/ConversationAlertService';
|
|
17
18
|
import PrintService from '@controleonline/ui-common/src/react/components/PrintService';
|
|
18
19
|
import RemoteCheckoutService from '@controleonline/ui-common/src/react/components/RemoteCheckoutService';
|
|
19
20
|
import ProductCatalogCacheService from '@controleonline/ui-common/src/react/components/ProductCatalogCacheService';
|
|
@@ -425,6 +426,7 @@ export const DefaultProvider = ({
|
|
|
425
426
|
<>
|
|
426
427
|
<WebsocketListener />
|
|
427
428
|
<DeviceAlertSoundService />
|
|
429
|
+
<ConversationAlertService />
|
|
428
430
|
<ProductCatalogCacheService />
|
|
429
431
|
<RemoteCheckoutService />
|
|
430
432
|
<PrintService />
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Pure helpers of the browser alert for new request messages (app-community#1766).
|
|
2
|
+
const CHANNELS = {whatsapp: 'WhatsApp', email: 'E-mail'};
|
|
3
|
+
|
|
4
|
+
const normalizeText = value => String(value ?? '').trim();
|
|
5
|
+
const idOf = value => normalizeText(value && typeof value === 'object' ? value.id : value).replace(/\D/g, '');
|
|
6
|
+
|
|
7
|
+
// Only customer messages ("received") of the current company raise an alert.
|
|
8
|
+
const isConversationAlert = (message, companyId) => {
|
|
9
|
+
if (normalizeText(message?.event) !== 'conversation_message') return false;
|
|
10
|
+
if (normalizeText(message?.status).toLowerCase() !== 'received') return false;
|
|
11
|
+
const messageCompany = idOf(message?.companyId ?? message?.company);
|
|
12
|
+
return !companyId || !messageCompany || messageCompany === String(companyId);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const conversationAlertKey = message =>
|
|
16
|
+
`${idOf(message?.task_id)}:${normalizeText(message?.interaction_id)}:${normalizeText(message?.sentAt)}`;
|
|
17
|
+
|
|
18
|
+
const conversationAlertContent = message => {
|
|
19
|
+
const taskId = idOf(message?.task_id);
|
|
20
|
+
const channel = CHANNELS[normalizeText(message?.channel).toLowerCase()];
|
|
21
|
+
return {
|
|
22
|
+
title: 'Nova mensagem',
|
|
23
|
+
body: [taskId ? `Chamado #${taskId}` : 'Chamado', channel].filter(Boolean).join(' · '),
|
|
24
|
+
tag: `conversation-${taskId || 'new'}`,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = {conversationAlertContent, conversationAlertKey, idOf, isConversationAlert};
|
|
@@ -26,182 +26,6 @@ const normalizeRuntimeMenuItem = (menu = {}) => ({
|
|
|
26
26
|
sortOrder: Number(menu?.sortOrder ?? menu?.sort_order ?? 0),
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
const MANAGER_RUNTIME_MENU_FALLBACK = [
|
|
30
|
-
{
|
|
31
|
-
id: 'manager-financeiro',
|
|
32
|
-
label: 'Financeiro',
|
|
33
|
-
icon: 'dollar-sign',
|
|
34
|
-
menus: [
|
|
35
|
-
{
|
|
36
|
-
id: 'financial_hub',
|
|
37
|
-
menuKey: 'financial_hub',
|
|
38
|
-
label: 'Financeiro',
|
|
39
|
-
route: 'FinancialHubPage',
|
|
40
|
-
icon: 'dollar-sign',
|
|
41
|
-
color: '#0284C7',
|
|
42
|
-
sortOrder: 10,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: 'income_statement',
|
|
46
|
-
menuKey: 'income_statement',
|
|
47
|
-
label: 'Demonstrativo de resultados',
|
|
48
|
-
route: 'IncomeStatement',
|
|
49
|
-
icon: 'bar-chart-2',
|
|
50
|
-
color: '#0F766E',
|
|
51
|
-
sortOrder: 15,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
id: 'manager-operacoes',
|
|
57
|
-
label: 'Operacoes',
|
|
58
|
-
icon: 'shopping-bag',
|
|
59
|
-
menus: [
|
|
60
|
-
{
|
|
61
|
-
id: 'orders',
|
|
62
|
-
menuKey: 'orders',
|
|
63
|
-
label: 'Pedidos',
|
|
64
|
-
route: 'OrderHistoryPage',
|
|
65
|
-
icon: 'shopping-bag',
|
|
66
|
-
color: '#0EA5E9',
|
|
67
|
-
sortOrder: 20,
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
id: 'manager-comercial',
|
|
73
|
-
label: 'Comercial',
|
|
74
|
-
icon: 'users',
|
|
75
|
-
menus: [
|
|
76
|
-
{
|
|
77
|
-
id: 'products',
|
|
78
|
-
menuKey: 'products',
|
|
79
|
-
label: 'Produtos',
|
|
80
|
-
route: 'ProductsPage',
|
|
81
|
-
icon: 'package',
|
|
82
|
-
color: '#16A34A',
|
|
83
|
-
sortOrder: 25,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
id: 'clients',
|
|
87
|
-
menuKey: 'clients',
|
|
88
|
-
label: 'Cadastro de clientes',
|
|
89
|
-
route: 'ClientsIndex',
|
|
90
|
-
icon: 'users',
|
|
91
|
-
color: '#16A34A',
|
|
92
|
-
sortOrder: 30,
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
id: 'providers',
|
|
96
|
-
menuKey: 'providers',
|
|
97
|
-
label: 'Fornecedores',
|
|
98
|
-
route: 'ProvidersIndex',
|
|
99
|
-
icon: 'truck',
|
|
100
|
-
color: '#EA580C',
|
|
101
|
-
sortOrder: 35,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
id: 'franchisees',
|
|
105
|
-
menuKey: 'franchisees',
|
|
106
|
-
label: 'Cadastro de franquias',
|
|
107
|
-
route: 'FranchiseesIndex',
|
|
108
|
-
icon: 'map-pin',
|
|
109
|
-
color: '#0EA5E9',
|
|
110
|
-
sortOrder: 40,
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
id: 'manager-configuracoes',
|
|
116
|
-
label: 'Configuracoes',
|
|
117
|
-
icon: 'settings',
|
|
118
|
-
menus: [
|
|
119
|
-
{
|
|
120
|
-
id: 'devices',
|
|
121
|
-
menuKey: 'devices',
|
|
122
|
-
label: 'Dispositivos',
|
|
123
|
-
route: 'DevicesIndex',
|
|
124
|
-
icon: 'credit-card',
|
|
125
|
-
color: '#e67e22',
|
|
126
|
-
sortOrder: 50,
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
id: 'configurator',
|
|
130
|
-
menuKey: 'configurator',
|
|
131
|
-
label: 'Configurador',
|
|
132
|
-
route: 'ConfiguratorPage',
|
|
133
|
-
icon: 'settings',
|
|
134
|
-
color: '#64748B',
|
|
135
|
-
sortOrder: 60,
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
id: 'product_showcases',
|
|
139
|
-
menuKey: 'product_showcases',
|
|
140
|
-
label: 'Vitrines de preços',
|
|
141
|
-
route: 'ProductShowcasesPage',
|
|
142
|
-
icon: 'grid',
|
|
143
|
-
color: '#0F766E',
|
|
144
|
-
sortOrder: 65,
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
},
|
|
148
|
-
];
|
|
149
|
-
|
|
150
|
-
const ADMIN_RUNTIME_MENU_FALLBACK = [
|
|
151
|
-
{
|
|
152
|
-
id: 'admin-configuracoes',
|
|
153
|
-
label: 'Configuracoes',
|
|
154
|
-
icon: 'settings',
|
|
155
|
-
menus: [
|
|
156
|
-
{
|
|
157
|
-
id: 'menu_access',
|
|
158
|
-
menuKey: 'menu_access',
|
|
159
|
-
label: 'Menus por perfil',
|
|
160
|
-
route: 'MenuAccessConfigPage',
|
|
161
|
-
icon: 'list',
|
|
162
|
-
color: '#64748B',
|
|
163
|
-
sortOrder: 10,
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
id: 'test_results',
|
|
167
|
-
menuKey: 'test_results',
|
|
168
|
-
label: 'Resultados de testes',
|
|
169
|
-
route: 'TestsPlaygroundPage',
|
|
170
|
-
icon: 'clipboard',
|
|
171
|
-
color: '#0EA5E9',
|
|
172
|
-
sortOrder: 20,
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
id: 'tenancies',
|
|
176
|
-
menuKey: 'tenancies',
|
|
177
|
-
label: 'Tenancies',
|
|
178
|
-
route: 'TenanciesPage',
|
|
179
|
-
icon: 'server',
|
|
180
|
-
color: '#0F766E',
|
|
181
|
-
sortOrder: 25,
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
id: 'people_domains',
|
|
185
|
-
menuKey: 'people_domains',
|
|
186
|
-
label: 'Domínios',
|
|
187
|
-
route: 'PeopleDomainsPage',
|
|
188
|
-
icon: 'globe',
|
|
189
|
-
color: '#0EA5E9',
|
|
190
|
-
sortOrder: 30,
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
id: 'flowcharts',
|
|
194
|
-
menuKey: 'flowcharts',
|
|
195
|
-
label: 'Fluxogramas',
|
|
196
|
-
route: 'FlowchartsPage',
|
|
197
|
-
icon: 'git-branch',
|
|
198
|
-
color: '#0F766E',
|
|
199
|
-
sortOrder: 40,
|
|
200
|
-
},
|
|
201
|
-
],
|
|
202
|
-
},
|
|
203
|
-
];
|
|
204
|
-
|
|
205
29
|
const cloneRuntimeMenuModules = modules =>
|
|
206
30
|
(Array.isArray(modules) ? modules : []).map(module => ({
|
|
207
31
|
...module,
|
|
@@ -226,10 +50,7 @@ const resolveRuntimeModuleSortOrder = module => {
|
|
|
226
50
|
return 0;
|
|
227
51
|
};
|
|
228
52
|
|
|
229
|
-
export const normalizeRuntimeMenuResponse =
|
|
230
|
-
result,
|
|
231
|
-
{appType, allowFallback = true} = {},
|
|
232
|
-
) => {
|
|
53
|
+
export const normalizeRuntimeMenuResponse = result => {
|
|
233
54
|
const modules =
|
|
234
55
|
result?.response?.data?.modules ||
|
|
235
56
|
result?.data?.modules ||
|
|
@@ -260,16 +81,6 @@ export const normalizeRuntimeMenuResponse = (
|
|
|
260
81
|
return normalizedModules;
|
|
261
82
|
}
|
|
262
83
|
|
|
263
|
-
const normalizedAppType = String(appType || '').trim().toUpperCase();
|
|
264
|
-
|
|
265
|
-
if (allowFallback && normalizedAppType === 'MANAGER') {
|
|
266
|
-
return cloneRuntimeMenuModules(MANAGER_RUNTIME_MENU_FALLBACK);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (allowFallback && normalizedAppType === 'ADMIN') {
|
|
270
|
-
return cloneRuntimeMenuModules(ADMIN_RUNTIME_MENU_FALLBACK);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
84
|
return [];
|
|
274
85
|
};
|
|
275
86
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const test = require('node:test');
|
|
2
|
+
const assert = require('node:assert/strict');
|
|
3
|
+
const {conversationAlertContent, conversationAlertKey, isConversationAlert} = require('../../../react/utils/conversationAlert');
|
|
4
|
+
|
|
5
|
+
const message = {event: 'conversation_message', status: 'received', companyId: 7, task_id: 54, interaction_id: 258, channel: 'whatsapp', sentAt: 'x'};
|
|
6
|
+
|
|
7
|
+
test('alerts customer messages of the current company only', () => {
|
|
8
|
+
assert.equal(isConversationAlert(message, '7'), true);
|
|
9
|
+
assert.equal(isConversationAlert(message, ''), true);
|
|
10
|
+
assert.equal(isConversationAlert({...message, companyId: 8}, '7'), false);
|
|
11
|
+
assert.equal(isConversationAlert({...message, status: 'updated'}, '7'), false);
|
|
12
|
+
assert.equal(isConversationAlert({...message, event: 'mcp_chat_reply'}, '7'), false);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('builds the alert text and a stable key', () => {
|
|
16
|
+
assert.deepEqual(conversationAlertContent(message), {title: 'Nova mensagem', body: 'Chamado #54 · WhatsApp', tag: 'conversation-54'});
|
|
17
|
+
assert.equal(conversationAlertContent({task_id: '/tasks/9'}).body, 'Chamado #9');
|
|
18
|
+
assert.equal(conversationAlertKey(message), '54:258:x');
|
|
19
|
+
});
|
|
@@ -153,106 +153,15 @@ describe('runtimeMenu', () => {
|
|
|
153
153
|
).toEqual(['ToolbarPage']);
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
it('
|
|
157
|
-
const menus = normalizeRuntimeMenuResponse({}, {appType: 'MANAGER'});
|
|
158
|
-
|
|
159
|
-
expect(menus).toHaveLength(4);
|
|
160
|
-
expect(menus.map(module => module.label)).toEqual([
|
|
161
|
-
'Financeiro',
|
|
162
|
-
'Operacoes',
|
|
163
|
-
'Comercial',
|
|
164
|
-
'Configuracoes',
|
|
165
|
-
]);
|
|
166
|
-
expect(menus[0].menus[0]).toMatchObject({
|
|
167
|
-
label: 'Financeiro',
|
|
168
|
-
menuKey: 'financial_hub',
|
|
169
|
-
route: 'FinancialHubPage',
|
|
170
|
-
menuType: 'home',
|
|
171
|
-
});
|
|
172
|
-
expect(menus[0].menus[1]).toMatchObject({
|
|
173
|
-
label: 'Demonstrativo de resultados',
|
|
174
|
-
menuKey: 'income_statement',
|
|
175
|
-
route: 'IncomeStatement',
|
|
176
|
-
});
|
|
177
|
-
expect(menus[1].menus[0]).toMatchObject({
|
|
178
|
-
label: 'Pedidos',
|
|
179
|
-
menuKey: 'orders',
|
|
180
|
-
route: 'OrderHistoryPage',
|
|
181
|
-
});
|
|
182
|
-
expect(menus[2].menus[0]).toMatchObject({
|
|
183
|
-
label: 'Produtos',
|
|
184
|
-
menuKey: 'products',
|
|
185
|
-
route: 'ProductsPage',
|
|
186
|
-
});
|
|
187
|
-
expect(menus[2].menus[1]).toMatchObject({
|
|
188
|
-
label: 'Cadastro de clientes',
|
|
189
|
-
menuKey: 'clients',
|
|
190
|
-
route: 'ClientsIndex',
|
|
191
|
-
});
|
|
192
|
-
expect(menus[2].menus[2]).toMatchObject({
|
|
193
|
-
label: 'Fornecedores',
|
|
194
|
-
menuKey: 'providers',
|
|
195
|
-
route: 'ProvidersIndex',
|
|
196
|
-
});
|
|
197
|
-
expect(menus[2].menus[3]).toMatchObject({
|
|
198
|
-
label: 'Cadastro de franquias',
|
|
199
|
-
menuKey: 'franchisees',
|
|
200
|
-
route: 'FranchiseesIndex',
|
|
201
|
-
});
|
|
202
|
-
expect(menus[3].menus.map(item => item.route)).toEqual([
|
|
203
|
-
'DevicesIndex',
|
|
204
|
-
'ConfiguratorPage',
|
|
205
|
-
'ProductShowcasesPage',
|
|
206
|
-
]);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('falls back to the admin starter menu when the runtime menu is empty', () => {
|
|
210
|
-
const menus = normalizeRuntimeMenuResponse({}, {appType: 'ADMIN'});
|
|
211
|
-
|
|
212
|
-
expect(menus).toHaveLength(1);
|
|
213
|
-
expect(menus[0].label).toBe('Configuracoes');
|
|
214
|
-
expect(menus[0].menus).toHaveLength(5);
|
|
215
|
-
expect(menus[0].menus[0]).toMatchObject({
|
|
216
|
-
label: 'Menus por perfil',
|
|
217
|
-
menuKey: 'menu_access',
|
|
218
|
-
route: 'MenuAccessConfigPage',
|
|
219
|
-
menuType: 'home',
|
|
220
|
-
});
|
|
221
|
-
expect(menus[0].menus[1]).toMatchObject({
|
|
222
|
-
label: 'Resultados de testes',
|
|
223
|
-
menuKey: 'test_results',
|
|
224
|
-
route: 'TestsPlaygroundPage',
|
|
225
|
-
menuType: 'home',
|
|
226
|
-
});
|
|
227
|
-
expect(menus[0].menus[2]).toMatchObject({
|
|
228
|
-
label: 'Tenancies',
|
|
229
|
-
menuKey: 'tenancies',
|
|
230
|
-
route: 'TenanciesPage',
|
|
231
|
-
menuType: 'home',
|
|
232
|
-
});
|
|
233
|
-
expect(menus[0].menus[3]).toMatchObject({
|
|
234
|
-
label: 'Domínios',
|
|
235
|
-
menuKey: 'people_domains',
|
|
236
|
-
route: 'PeopleDomainsPage',
|
|
237
|
-
menuType: 'home',
|
|
238
|
-
});
|
|
239
|
-
expect(menus[0].menus[4]).toMatchObject({
|
|
240
|
-
label: 'Fluxogramas',
|
|
241
|
-
menuKey: 'flowcharts',
|
|
242
|
-
route: 'FlowchartsPage',
|
|
243
|
-
menuType: 'home',
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it('does not invent a fallback menu for non-manager apps', () => {
|
|
156
|
+
it('does not invent a fallback menu for the admin app', () => {
|
|
248
157
|
expect(
|
|
249
|
-
normalizeRuntimeMenuResponse({}, {appType: '
|
|
158
|
+
normalizeRuntimeMenuResponse({}, {appType: 'ADMIN'}),
|
|
250
159
|
).toEqual([]);
|
|
251
160
|
});
|
|
252
161
|
|
|
253
|
-
it('
|
|
162
|
+
it('does not invent a fallback menu for non-manager apps', () => {
|
|
254
163
|
expect(
|
|
255
|
-
normalizeRuntimeMenuResponse({}, {appType: '
|
|
164
|
+
normalizeRuntimeMenuResponse({}, {appType: 'SHOP'}),
|
|
256
165
|
).toEqual([]);
|
|
257
166
|
});
|
|
258
167
|
});
|