@controleonline/ui-common 1.2.89 → 1.2.91
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/docs/compact-order-history-1047.md +25 -0
- package/package.json +1 -1
- package/src/react/components/CopyDeviceConfigModal.js +7 -4
- package/src/react/components/DefaultProvider.native.configuration.js +275 -0
- package/src/react/components/DefaultProvider.native.js +24 -534
- package/src/react/components/DefaultProvider.native.lifecycle.js +323 -0
- package/src/react/components/DefaultProvider.web.configuration.js +327 -0
- package/src/react/components/DefaultProvider.web.js +23 -603
- package/src/react/components/DefaultProvider.web.lifecycle.js +336 -0
- package/src/react/components/resolveDomainThemeColors.js +5 -0
- package/src/react/pages/Connections.js +5 -7
- package/src/react/pages/MercadoLivreIntegrationPage.js +5 -75
- package/src/react/pages/mercadoLivreIntegrationHelpers.js +79 -0
- package/src/tests/browser/manager/bottom-navigation-role-toolbar.spec.js +14 -0
- package/src/tests/browser/manager/connections.spec.js +18 -0
- package/src/tests/browser/manager/device-detail-alias-save.spec.js +3 -1
- package/src/tests/browser/manager/device-detail-copy-config.spec.js +6 -0
- package/src/tests/browser/manager/device-detail-pdv-current-company.spec.js +3 -1
- package/src/tests/browser/manager/devices-current.spec.js +345 -343
- package/src/tests/browser/manager/devices-type-filters.spec.js +2 -0
- package/src/tests/browser/manager/managerSession.fixture.js +28 -0
- package/src/tests/react/components/DefaultProviderAuthority.test.js +4 -1
- package/src/tests/react/components/providerEffects.fingerprint.json +47 -0
- package/src/tests/react/components/providerEffects.test.js +24 -0
|
@@ -1,343 +1,345 @@
|
|
|
1
|
-
const {expect, test} = require('playwright/test');
|
|
2
|
-
const packageJson = require('../../../../../../../package.json');
|
|
3
|
-
const {API_ORIGIN} = require('../../../../../../../src/tests/browser/apiOrigin');
|
|
4
|
-
|
|
5
|
-
const APP_VERSION = packageJson?.version || '1.0.0';
|
|
6
|
-
const CURRENT_DEVICE_ID = 'web-7';
|
|
7
|
-
|
|
8
|
-
const CORS_HEADERS = {
|
|
9
|
-
'access-control-allow-origin': '*',
|
|
10
|
-
'access-control-allow-headers':
|
|
11
|
-
'API-TOKEN, APP-DOMAIN, DEVICE, ACCEPT, CONTENT-TYPE, X-Requested-With',
|
|
12
|
-
'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const jsonHeaders = () => ({
|
|
16
|
-
...CORS_HEADERS,
|
|
17
|
-
'content-type': 'application/ld+json; charset=utf-8',
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const collection = member => ({
|
|
21
|
-
member,
|
|
22
|
-
'hydra:member': member,
|
|
23
|
-
totalItems: member.length,
|
|
24
|
-
'hydra:totalItems': member.length,
|
|
25
|
-
summary: {},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const currentDevice = {
|
|
29
|
-
'@id': '/devices/396',
|
|
30
|
-
'@type': 'Device',
|
|
31
|
-
id: 396,
|
|
32
|
-
device: CURRENT_DEVICE_ID,
|
|
33
|
-
alias: 'Caixa atual',
|
|
34
|
-
metadata: {
|
|
35
|
-
runtime: 'web',
|
|
36
|
-
network: {
|
|
37
|
-
publicIp: '127.0.0.1',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const remoteDevice = {
|
|
43
|
-
'@id': '/devices/410',
|
|
44
|
-
'@type': 'Device',
|
|
45
|
-
id: 410,
|
|
46
|
-
device: 'remote-pdv',
|
|
47
|
-
alias: 'Caixa remoto',
|
|
48
|
-
metadata: {
|
|
49
|
-
runtime: 'android',
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const createDeviceConfig = ({
|
|
54
|
-
id,
|
|
55
|
-
type,
|
|
56
|
-
device = currentDevice,
|
|
57
|
-
}) => ({
|
|
58
|
-
'@id': `/device_configs/${id}`,
|
|
59
|
-
'@type': 'DeviceConfig',
|
|
60
|
-
id,
|
|
61
|
-
type,
|
|
62
|
-
people: '/people/3',
|
|
63
|
-
device,
|
|
64
|
-
configs: JSON.stringify({
|
|
65
|
-
'config-version': APP_VERSION,
|
|
66
|
-
'pos-gateway': 'infinite-pay',
|
|
67
|
-
}),
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const mockDevicesApi = async (page, {includeCurrentPdv}) => {
|
|
71
|
-
const company = {
|
|
72
|
-
id: 3,
|
|
73
|
-
name: 'Teste',
|
|
74
|
-
alias: 'TESTE',
|
|
75
|
-
panel_enabled: true,
|
|
76
|
-
enabled: true,
|
|
77
|
-
commercial_enabled: true,
|
|
78
|
-
theme: {
|
|
79
|
-
colors: {
|
|
80
|
-
primary: '#0EA5E9',
|
|
81
|
-
cardBackground: '#FFFFFF',
|
|
82
|
-
cardBorder: '#D8E0EA',
|
|
83
|
-
cardSelectedBackground: '#E8F8FD',
|
|
84
|
-
cardSelectedBorder: '#0284C7',
|
|
85
|
-
cardSelectedText: '#0F172A',
|
|
86
|
-
badgeSelectedBackground: '#CDEFFA',
|
|
87
|
-
badgeSelectedText: '#075985',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
const managerConfig = createDeviceConfig({id: 487, type: 'MANAGER'});
|
|
92
|
-
const currentPdvConfig = createDeviceConfig({id: 488, type: 'PDV'});
|
|
93
|
-
const remotePdvConfig = createDeviceConfig({
|
|
94
|
-
id: 410,
|
|
95
|
-
type: 'PDV',
|
|
96
|
-
device: remoteDevice,
|
|
97
|
-
});
|
|
98
|
-
const deviceConfigs = [
|
|
99
|
-
remotePdvConfig,
|
|
100
|
-
managerConfig,
|
|
101
|
-
...(includeCurrentPdv ? [currentPdvConfig] : []),
|
|
102
|
-
];
|
|
103
|
-
const savedPdvRequests = [];
|
|
104
|
-
|
|
105
|
-
await page.route(`${API_ORIGIN}/**`, async route => {
|
|
106
|
-
const request = route.request();
|
|
107
|
-
const url = new URL(request.url());
|
|
108
|
-
const pathname = url.pathname.replace(/^\/+/, '');
|
|
109
|
-
const method = request.method().toUpperCase();
|
|
110
|
-
|
|
111
|
-
if (method === 'OPTIONS') {
|
|
112
|
-
return route.fulfill({
|
|
113
|
-
status: 204,
|
|
114
|
-
headers: CORS_HEADERS,
|
|
115
|
-
body: '',
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (pathname === 'themes-colors.css') {
|
|
120
|
-
return route.fulfill({
|
|
121
|
-
status: 200,
|
|
122
|
-
headers: {
|
|
123
|
-
...CORS_HEADERS,
|
|
124
|
-
'content-type': 'text/css; charset=utf-8',
|
|
125
|
-
},
|
|
126
|
-
body: ':root { --primary: #0ea5e9; }',
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (pathname === 'runtime/ip') {
|
|
131
|
-
return route.fulfill({
|
|
132
|
-
status: 200,
|
|
133
|
-
headers: jsonHeaders(),
|
|
134
|
-
body: JSON.stringify({ip: '127.0.0.1'}),
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (pathname === 'menus-people') {
|
|
139
|
-
return route.fulfill({
|
|
140
|
-
status: 200,
|
|
141
|
-
headers: jsonHeaders(),
|
|
142
|
-
body: JSON.stringify({modules: {}}),
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (pathname === 'people/companies/my') {
|
|
147
|
-
return route.fulfill({
|
|
148
|
-
status: 200,
|
|
149
|
-
headers: jsonHeaders(),
|
|
150
|
-
body: JSON.stringify(collection([company])),
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (pathname === 'people/company/default') {
|
|
155
|
-
return route.fulfill({
|
|
156
|
-
status: 200,
|
|
157
|
-
headers: jsonHeaders(),
|
|
158
|
-
body: JSON.stringify(company),
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (pathname === 'configs/discovery-configs') {
|
|
163
|
-
return route.fulfill({
|
|
164
|
-
status: 200,
|
|
165
|
-
headers: jsonHeaders(),
|
|
166
|
-
body: JSON.stringify({configs: {}}),
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (pathname === 'devices' && method === 'GET') {
|
|
171
|
-
return route.fulfill({
|
|
172
|
-
status: 200,
|
|
173
|
-
headers: jsonHeaders(),
|
|
174
|
-
body: JSON.stringify(collection([currentDevice])),
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (pathname === 'devices' && method === 'POST') {
|
|
179
|
-
return route.fulfill({
|
|
180
|
-
status: 200,
|
|
181
|
-
headers: jsonHeaders(),
|
|
182
|
-
body: JSON.stringify(currentDevice),
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (pathname === 'device_configs' && method === 'GET') {
|
|
187
|
-
const requestedDevice = url.searchParams.get('device.device');
|
|
188
|
-
const requestedType = url.searchParams.get('type');
|
|
189
|
-
const filtered = deviceConfigs.filter(deviceConfig => {
|
|
190
|
-
if (
|
|
191
|
-
requestedDevice &&
|
|
192
|
-
deviceConfig.device.device !== requestedDevice
|
|
193
|
-
) {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (requestedType && deviceConfig.type !== requestedType) {
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return true;
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
return route.fulfill({
|
|
205
|
-
status: 200,
|
|
206
|
-
headers: jsonHeaders(),
|
|
207
|
-
body: JSON.stringify(collection(filtered)),
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (pathname === 'device_configs/add-configs' && method === 'POST') {
|
|
212
|
-
const payload = request.postDataJSON();
|
|
213
|
-
const type = String(payload?.type || '').toUpperCase();
|
|
214
|
-
const savedDeviceConfig = createDeviceConfig({
|
|
215
|
-
id: type === 'PDV' ? 489 : 490,
|
|
216
|
-
type: type || 'MANAGER',
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
if (type === 'PDV') {
|
|
220
|
-
savedPdvRequests.push(payload);
|
|
221
|
-
deviceConfigs.push(savedDeviceConfig);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return route.fulfill({
|
|
225
|
-
status: 200,
|
|
226
|
-
headers: jsonHeaders(),
|
|
227
|
-
body: JSON.stringify(savedDeviceConfig),
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
return route.fulfill({
|
|
232
|
-
status: 200,
|
|
233
|
-
headers: jsonHeaders(),
|
|
234
|
-
body: JSON.stringify(collection([])),
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
await page.addInitScript(
|
|
239
|
-
({appVersion}) => {
|
|
240
|
-
localStorage.setItem(
|
|
241
|
-
'session',
|
|
242
|
-
JSON.stringify({
|
|
243
|
-
id: 7,
|
|
244
|
-
people: '/people/7',
|
|
245
|
-
api_key: 'test-api-key',
|
|
246
|
-
active: 1,
|
|
247
|
-
mycompany: 3,
|
|
248
|
-
roles: ['ROLE_SUPER'],
|
|
249
|
-
}),
|
|
250
|
-
);
|
|
251
|
-
localStorage.setItem('config', JSON.stringify({language: 'pt-br'}));
|
|
252
|
-
localStorage.setItem(
|
|
253
|
-
'device',
|
|
254
|
-
JSON.stringify({
|
|
255
|
-
id: 'web-7',
|
|
256
|
-
device: 'web-7',
|
|
257
|
-
type: 'MANAGER',
|
|
258
|
-
appName: 'Browser Manager',
|
|
259
|
-
appVersion,
|
|
260
|
-
buildNumber: appVersion,
|
|
261
|
-
systemName: 'web',
|
|
262
|
-
systemVersion: 'web',
|
|
263
|
-
deviceType: 'web',
|
|
264
|
-
metadata: {
|
|
265
|
-
runtime: 'web',
|
|
266
|
-
},
|
|
267
|
-
}),
|
|
268
|
-
);
|
|
269
|
-
},
|
|
270
|
-
{appVersion: APP_VERSION},
|
|
271
|
-
);
|
|
272
|
-
|
|
273
|
-
return {savedPdvRequests};
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
test.describe('current device browser smoke', () => {
|
|
277
|
-
test('groups every profile under one highlighted current Device', async ({
|
|
278
|
-
page,
|
|
279
|
-
}) => {
|
|
280
|
-
await mockDevicesApi(page, {includeCurrentPdv: true});
|
|
281
|
-
|
|
282
|
-
await page.goto('/devices-index?store=device_config');
|
|
283
|
-
|
|
284
|
-
await expect(page.getByTestId('current-device-badge')).toHaveCount(1);
|
|
285
|
-
await expect(page.getByTestId('device-config-487')).toBeVisible();
|
|
286
|
-
await expect(page.getByTestId('device-config-488')).toBeVisible();
|
|
287
|
-
await expect(page.getByTestId('device-config-410')).toBeVisible();
|
|
288
|
-
await expect(page.getByTestId('device-config-488')).toContainText(
|
|
289
|
-
'
|
|
290
|
-
);
|
|
291
|
-
await expect(
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
await expect(
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
await page
|
|
310
|
-
|
|
311
|
-
await page.
|
|
312
|
-
|
|
313
|
-
await
|
|
314
|
-
|
|
315
|
-
await page.
|
|
316
|
-
|
|
317
|
-
await page.
|
|
318
|
-
|
|
319
|
-
await
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
await page
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
await
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
1
|
+
const {expect, test} = require('playwright/test');
|
|
2
|
+
const packageJson = require('../../../../../../../package.json');
|
|
3
|
+
const {API_ORIGIN} = require('../../../../../../../src/tests/browser/apiOrigin');
|
|
4
|
+
|
|
5
|
+
const APP_VERSION = packageJson?.version || '1.0.0';
|
|
6
|
+
const CURRENT_DEVICE_ID = 'web-7';
|
|
7
|
+
|
|
8
|
+
const CORS_HEADERS = {
|
|
9
|
+
'access-control-allow-origin': '*',
|
|
10
|
+
'access-control-allow-headers':
|
|
11
|
+
'API-TOKEN, APP-DOMAIN, DEVICE, ACCEPT, CONTENT-TYPE, X-Requested-With',
|
|
12
|
+
'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const jsonHeaders = () => ({
|
|
16
|
+
...CORS_HEADERS,
|
|
17
|
+
'content-type': 'application/ld+json; charset=utf-8',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const collection = member => ({
|
|
21
|
+
member,
|
|
22
|
+
'hydra:member': member,
|
|
23
|
+
totalItems: member.length,
|
|
24
|
+
'hydra:totalItems': member.length,
|
|
25
|
+
summary: {},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const currentDevice = {
|
|
29
|
+
'@id': '/devices/396',
|
|
30
|
+
'@type': 'Device',
|
|
31
|
+
id: 396,
|
|
32
|
+
device: CURRENT_DEVICE_ID,
|
|
33
|
+
alias: 'Caixa atual',
|
|
34
|
+
metadata: {
|
|
35
|
+
runtime: 'web',
|
|
36
|
+
network: {
|
|
37
|
+
publicIp: '127.0.0.1',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const remoteDevice = {
|
|
43
|
+
'@id': '/devices/410',
|
|
44
|
+
'@type': 'Device',
|
|
45
|
+
id: 410,
|
|
46
|
+
device: 'remote-pdv',
|
|
47
|
+
alias: 'Caixa remoto',
|
|
48
|
+
metadata: {
|
|
49
|
+
runtime: 'android',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const createDeviceConfig = ({
|
|
54
|
+
id,
|
|
55
|
+
type,
|
|
56
|
+
device = currentDevice,
|
|
57
|
+
}) => ({
|
|
58
|
+
'@id': `/device_configs/${id}`,
|
|
59
|
+
'@type': 'DeviceConfig',
|
|
60
|
+
id,
|
|
61
|
+
type,
|
|
62
|
+
people: '/people/3',
|
|
63
|
+
device,
|
|
64
|
+
configs: JSON.stringify({
|
|
65
|
+
'config-version': APP_VERSION,
|
|
66
|
+
'pos-gateway': 'infinite-pay',
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const mockDevicesApi = async (page, {includeCurrentPdv}) => {
|
|
71
|
+
const company = {
|
|
72
|
+
id: 3,
|
|
73
|
+
name: 'Teste',
|
|
74
|
+
alias: 'TESTE',
|
|
75
|
+
panel_enabled: true,
|
|
76
|
+
enabled: true,
|
|
77
|
+
commercial_enabled: true,
|
|
78
|
+
theme: {
|
|
79
|
+
colors: {
|
|
80
|
+
primary: '#0EA5E9',
|
|
81
|
+
cardBackground: '#FFFFFF',
|
|
82
|
+
cardBorder: '#D8E0EA',
|
|
83
|
+
cardSelectedBackground: '#E8F8FD',
|
|
84
|
+
cardSelectedBorder: '#0284C7',
|
|
85
|
+
cardSelectedText: '#0F172A',
|
|
86
|
+
badgeSelectedBackground: '#CDEFFA',
|
|
87
|
+
badgeSelectedText: '#075985',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
const managerConfig = createDeviceConfig({id: 487, type: 'MANAGER'});
|
|
92
|
+
const currentPdvConfig = createDeviceConfig({id: 488, type: 'PDV'});
|
|
93
|
+
const remotePdvConfig = createDeviceConfig({
|
|
94
|
+
id: 410,
|
|
95
|
+
type: 'PDV',
|
|
96
|
+
device: remoteDevice,
|
|
97
|
+
});
|
|
98
|
+
const deviceConfigs = [
|
|
99
|
+
remotePdvConfig,
|
|
100
|
+
managerConfig,
|
|
101
|
+
...(includeCurrentPdv ? [currentPdvConfig] : []),
|
|
102
|
+
];
|
|
103
|
+
const savedPdvRequests = [];
|
|
104
|
+
|
|
105
|
+
await page.route(`${API_ORIGIN}/**`, async route => {
|
|
106
|
+
const request = route.request();
|
|
107
|
+
const url = new URL(request.url());
|
|
108
|
+
const pathname = url.pathname.replace(/^\/+/, '');
|
|
109
|
+
const method = request.method().toUpperCase();
|
|
110
|
+
|
|
111
|
+
if (method === 'OPTIONS') {
|
|
112
|
+
return route.fulfill({
|
|
113
|
+
status: 204,
|
|
114
|
+
headers: CORS_HEADERS,
|
|
115
|
+
body: '',
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (pathname === 'themes-colors.css') {
|
|
120
|
+
return route.fulfill({
|
|
121
|
+
status: 200,
|
|
122
|
+
headers: {
|
|
123
|
+
...CORS_HEADERS,
|
|
124
|
+
'content-type': 'text/css; charset=utf-8',
|
|
125
|
+
},
|
|
126
|
+
body: ':root { --primary: #0ea5e9; }',
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (pathname === 'runtime/ip') {
|
|
131
|
+
return route.fulfill({
|
|
132
|
+
status: 200,
|
|
133
|
+
headers: jsonHeaders(),
|
|
134
|
+
body: JSON.stringify({ip: '127.0.0.1'}),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (pathname === 'menus-people') {
|
|
139
|
+
return route.fulfill({
|
|
140
|
+
status: 200,
|
|
141
|
+
headers: jsonHeaders(),
|
|
142
|
+
body: JSON.stringify({modules: {}}),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (pathname === 'people/companies/my') {
|
|
147
|
+
return route.fulfill({
|
|
148
|
+
status: 200,
|
|
149
|
+
headers: jsonHeaders(),
|
|
150
|
+
body: JSON.stringify(collection([company])),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (pathname === 'people/company/default') {
|
|
155
|
+
return route.fulfill({
|
|
156
|
+
status: 200,
|
|
157
|
+
headers: jsonHeaders(),
|
|
158
|
+
body: JSON.stringify(company),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (pathname === 'configs/discovery-configs') {
|
|
163
|
+
return route.fulfill({
|
|
164
|
+
status: 200,
|
|
165
|
+
headers: jsonHeaders(),
|
|
166
|
+
body: JSON.stringify({configs: {}}),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (pathname === 'devices' && method === 'GET') {
|
|
171
|
+
return route.fulfill({
|
|
172
|
+
status: 200,
|
|
173
|
+
headers: jsonHeaders(),
|
|
174
|
+
body: JSON.stringify(collection([currentDevice])),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (pathname === 'devices' && method === 'POST') {
|
|
179
|
+
return route.fulfill({
|
|
180
|
+
status: 200,
|
|
181
|
+
headers: jsonHeaders(),
|
|
182
|
+
body: JSON.stringify(currentDevice),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (pathname === 'device_configs' && method === 'GET') {
|
|
187
|
+
const requestedDevice = url.searchParams.get('device.device');
|
|
188
|
+
const requestedType = url.searchParams.get('type');
|
|
189
|
+
const filtered = deviceConfigs.filter(deviceConfig => {
|
|
190
|
+
if (
|
|
191
|
+
requestedDevice &&
|
|
192
|
+
deviceConfig.device.device !== requestedDevice
|
|
193
|
+
) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (requestedType && deviceConfig.type !== requestedType) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return true;
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
return route.fulfill({
|
|
205
|
+
status: 200,
|
|
206
|
+
headers: jsonHeaders(),
|
|
207
|
+
body: JSON.stringify(collection(filtered)),
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (pathname === 'device_configs/add-configs' && method === 'POST') {
|
|
212
|
+
const payload = request.postDataJSON();
|
|
213
|
+
const type = String(payload?.type || '').toUpperCase();
|
|
214
|
+
const savedDeviceConfig = createDeviceConfig({
|
|
215
|
+
id: type === 'PDV' ? 489 : 490,
|
|
216
|
+
type: type || 'MANAGER',
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
if (type === 'PDV') {
|
|
220
|
+
savedPdvRequests.push(payload);
|
|
221
|
+
deviceConfigs.push(savedDeviceConfig);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return route.fulfill({
|
|
225
|
+
status: 200,
|
|
226
|
+
headers: jsonHeaders(),
|
|
227
|
+
body: JSON.stringify(savedDeviceConfig),
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return route.fulfill({
|
|
232
|
+
status: 200,
|
|
233
|
+
headers: jsonHeaders(),
|
|
234
|
+
body: JSON.stringify(collection([])),
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
await page.addInitScript(
|
|
239
|
+
({appVersion}) => {
|
|
240
|
+
localStorage.setItem(
|
|
241
|
+
'session',
|
|
242
|
+
JSON.stringify({
|
|
243
|
+
id: 7,
|
|
244
|
+
people: '/people/7',
|
|
245
|
+
api_key: 'test-api-key',
|
|
246
|
+
active: 1,
|
|
247
|
+
mycompany: 3,
|
|
248
|
+
roles: ['ROLE_SUPER'],
|
|
249
|
+
}),
|
|
250
|
+
);
|
|
251
|
+
localStorage.setItem('config', JSON.stringify({language: 'pt-br'}));
|
|
252
|
+
localStorage.setItem(
|
|
253
|
+
'device',
|
|
254
|
+
JSON.stringify({
|
|
255
|
+
id: 'web-7',
|
|
256
|
+
device: 'web-7',
|
|
257
|
+
type: 'MANAGER',
|
|
258
|
+
appName: 'Browser Manager',
|
|
259
|
+
appVersion,
|
|
260
|
+
buildNumber: appVersion,
|
|
261
|
+
systemName: 'web',
|
|
262
|
+
systemVersion: 'web',
|
|
263
|
+
deviceType: 'web',
|
|
264
|
+
metadata: {
|
|
265
|
+
runtime: 'web',
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
);
|
|
269
|
+
},
|
|
270
|
+
{appVersion: APP_VERSION},
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
return {savedPdvRequests};
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
test.describe('current device browser smoke', () => {
|
|
277
|
+
test('groups every profile under one highlighted current Device', async ({
|
|
278
|
+
page,
|
|
279
|
+
}) => {
|
|
280
|
+
await mockDevicesApi(page, {includeCurrentPdv: true});
|
|
281
|
+
|
|
282
|
+
await page.goto('/devices-index?store=device_config');
|
|
283
|
+
|
|
284
|
+
await expect(page.getByTestId('current-device-badge')).toHaveCount(1);
|
|
285
|
+
await expect(page.getByTestId('device-config-487')).toBeVisible();
|
|
286
|
+
await expect(page.getByTestId('device-config-488')).toBeVisible();
|
|
287
|
+
await expect(page.getByTestId('device-config-410')).toBeVisible();
|
|
288
|
+
await expect(page.getByTestId('device-config-488')).toContainText(
|
|
289
|
+
'Infinite Pay',
|
|
290
|
+
);
|
|
291
|
+
await expect(page.getByTestId('device-config-488')).toHaveRole('button');
|
|
292
|
+
await expect(page.getByTestId('device-config-488')).toHaveAccessibleName(/^PDV/);
|
|
293
|
+
await expect(
|
|
294
|
+
page.getByTestId('configure-current-device-pdv'),
|
|
295
|
+
).toHaveCount(0);
|
|
296
|
+
|
|
297
|
+
const groups = page.locator('[data-testid^="device-group-"]');
|
|
298
|
+
await expect(groups).toHaveCount(2);
|
|
299
|
+
await expect(groups.first()).toContainText('Caixa atual');
|
|
300
|
+
await expect(page.getByTestId('device-config-487')).toHaveAttribute(
|
|
301
|
+
'data-session-config',
|
|
302
|
+
'true',
|
|
303
|
+
);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
test('opens the detail for the selected configuration profile', async ({
|
|
307
|
+
page,
|
|
308
|
+
}) => {
|
|
309
|
+
await mockDevicesApi(page, {includeCurrentPdv: true});
|
|
310
|
+
|
|
311
|
+
await page.goto('/devices-index?store=device_config');
|
|
312
|
+
|
|
313
|
+
await page.getByTestId('device-config-487').click();
|
|
314
|
+
await expect(page).toHaveURL(/device-detail/);
|
|
315
|
+
await expect(page.getByText('Configuração do PDV')).toHaveCount(0);
|
|
316
|
+
|
|
317
|
+
await page.goBack();
|
|
318
|
+
await expect(page.getByTestId('device-config-488')).toBeVisible();
|
|
319
|
+
await page.getByTestId('device-config-488').click();
|
|
320
|
+
|
|
321
|
+
await expect(page).toHaveURL(/device-detail/);
|
|
322
|
+
await expect(page.getByText('Configuração do PDV')).toBeVisible();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
test('creates the missing PDV profile for the current device', async ({
|
|
326
|
+
page,
|
|
327
|
+
}) => {
|
|
328
|
+
const api = await mockDevicesApi(page, {includeCurrentPdv: false});
|
|
329
|
+
|
|
330
|
+
await page.goto('/devices-index?store=device_config');
|
|
331
|
+
|
|
332
|
+
const setupButton = page.getByTestId('configure-current-device-pdv');
|
|
333
|
+
await expect(setupButton).toBeVisible();
|
|
334
|
+
await setupButton.click();
|
|
335
|
+
|
|
336
|
+
await expect.poll(() => api.savedPdvRequests.length).toBe(1);
|
|
337
|
+
expect(api.savedPdvRequests[0]).toEqual(
|
|
338
|
+
expect.objectContaining({
|
|
339
|
+
device: CURRENT_DEVICE_ID,
|
|
340
|
+
people: '/people/3',
|
|
341
|
+
type: 'PDV',
|
|
342
|
+
}),
|
|
343
|
+
);
|
|
344
|
+
});
|
|
345
|
+
});
|