@controleonline/ui-common 1.2.89 → 1.2.90
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/package.json +1 -1
- package/src/react/components/CopyDeviceConfigModal.js +7 -4
- 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 +2 -0
- 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 +2 -0
- 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/package.json
CHANGED
|
@@ -100,10 +100,13 @@ export default function CopyDeviceConfigModal({
|
|
|
100
100
|
</View>
|
|
101
101
|
|
|
102
102
|
<Text style={styles.message} testID="copy-device-config-hint">
|
|
103
|
-
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
{`${
|
|
104
|
+
tt('device_action', 'copyConfigHint') ||
|
|
105
|
+
'Escolha o device origem. As configurações serão aplicadas em'
|
|
106
|
+
} "${destinationAlias || destinationDeviceString || 'destino'}" (${
|
|
107
|
+
tt('device_action', 'copyConfigIdentityHint') ||
|
|
108
|
+
'identidade do destino não muda'
|
|
109
|
+
}).`}
|
|
107
110
|
</Text>
|
|
108
111
|
|
|
109
112
|
{loading ? (
|
|
@@ -209,13 +209,11 @@ export default function Connections() {
|
|
|
209
209
|
showColumnFiltersButton
|
|
210
210
|
onRowPress={openWhatsAppChannel}
|
|
211
211
|
renderCard={renderConnectionCard}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
storeName: 'connections',
|
|
218
|
-
}}
|
|
212
|
+
showSearch
|
|
213
|
+
searchPlaceholder={
|
|
214
|
+
tt('connections_label', 'search') || 'Buscar conexao, telefone ou status'
|
|
215
|
+
}
|
|
216
|
+
searchKey="search
|
|
219
217
|
totalItemsLabel="connections"
|
|
220
218
|
visibleColumnsPreferenceKey="connections"
|
|
221
219
|
accentColor={brandColors.primary}
|
|
@@ -23,6 +23,10 @@ import {
|
|
|
23
23
|
} from '@controleonline/../../src/styles/branding';
|
|
24
24
|
|
|
25
25
|
import styles from './IntegrationConfigPage.styles';
|
|
26
|
+
import {
|
|
27
|
+
normalizeTextValue, isConnected, formatApiError, resolveFrontOAuthRedirectUri,
|
|
28
|
+
replaceFrontOAuthStatus, formatOAuthStatusError,
|
|
29
|
+
} from './mercadoLivreIntegrationHelpers';
|
|
26
30
|
|
|
27
31
|
const PROVIDER = {
|
|
28
32
|
key: 'mercadolivre',
|
|
@@ -45,81 +49,6 @@ const shadowStyle = Platform.select({
|
|
|
45
49
|
web: {boxShadow: '0 10px 24px rgba(15,23,42,0.08)'},
|
|
46
50
|
});
|
|
47
51
|
|
|
48
|
-
const normalizeTextValue = value => String(value ?? '').trim();
|
|
49
|
-
|
|
50
|
-
const isConnected = value =>
|
|
51
|
-
value === true ||
|
|
52
|
-
value === 1 ||
|
|
53
|
-
value === '1' ||
|
|
54
|
-
String(value).trim().toLowerCase() === 'true';
|
|
55
|
-
|
|
56
|
-
const formatApiError = error =>
|
|
57
|
-
error?.message ||
|
|
58
|
-
error?.description ||
|
|
59
|
-
error?.error ||
|
|
60
|
-
tt('marketplace_error', 'mercadoLivreLoad') ||
|
|
61
|
-
'Nao foi possivel carregar a integracao Mercado Livre.';
|
|
62
|
-
|
|
63
|
-
const MERCADO_LIVRE_OAUTH_QUERY_KEYS = [
|
|
64
|
-
'code',
|
|
65
|
-
'state',
|
|
66
|
-
'error',
|
|
67
|
-
'error_description',
|
|
68
|
-
'mercadolivre_connected',
|
|
69
|
-
'mercadolivre_error',
|
|
70
|
-
'mercadolivre_message',
|
|
71
|
-
];
|
|
72
|
-
|
|
73
|
-
const resolveFrontOAuthRedirectUri = () => {
|
|
74
|
-
if (Platform.OS !== 'web' || typeof window === 'undefined') {
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const url = new URL(window.location.href);
|
|
79
|
-
MERCADO_LIVRE_OAUTH_QUERY_KEYS.forEach(key => url.searchParams.delete(key));
|
|
80
|
-
url.hash = '';
|
|
81
|
-
|
|
82
|
-
return url.toString();
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const replaceFrontOAuthStatus = statusParams => {
|
|
86
|
-
if (Platform.OS !== 'web' || typeof window === 'undefined') {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const url = new URL(window.location.href);
|
|
91
|
-
MERCADO_LIVRE_OAUTH_QUERY_KEYS.forEach(key => url.searchParams.delete(key));
|
|
92
|
-
Object.entries(statusParams || {}).forEach(([key, value]) => {
|
|
93
|
-
if (value !== undefined && value !== null && value !== '') {
|
|
94
|
-
url.searchParams.set(key, String(value));
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
window.history.replaceState({}, document.title, url.toString());
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const formatOAuthStatusError = (error, message) => {
|
|
101
|
-
const messageText = normalizeTextValue(message);
|
|
102
|
-
if (messageText) {
|
|
103
|
-
return `${
|
|
104
|
-
tt('marketplace_error', 'mercadoLivreConnectWithMessage') ||
|
|
105
|
-
'Nao foi possivel conectar o Mercado Livre:'
|
|
106
|
-
} ${messageText}`;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const errorText = normalizeTextValue(error);
|
|
110
|
-
if (!errorText) {
|
|
111
|
-
return (
|
|
112
|
-
tt('marketplace_error', 'mercadoLivreConnect') ||
|
|
113
|
-
'Nao foi possivel conectar o Mercado Livre.'
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return `${
|
|
118
|
-
tt('marketplace_error', 'mercadoLivreConnect') ||
|
|
119
|
-
'Nao foi possivel conectar o Mercado Livre.'
|
|
120
|
-
} (${errorText}).`;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
52
|
export default function MercadoLivreIntegrationPage() {
|
|
124
53
|
const peopleStore = useStore('people');
|
|
125
54
|
const themeStore = useStore('theme');
|
|
@@ -513,6 +442,7 @@ export default function MercadoLivreIntegrationPage() {
|
|
|
513
442
|
</View>
|
|
514
443
|
|
|
515
444
|
<TouchableOpacity
|
|
445
|
+
accessibilityRole="button"
|
|
516
446
|
style={[
|
|
517
447
|
styles.saveButton,
|
|
518
448
|
{backgroundColor: PROVIDER.button},
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {Platform} from 'react-native';
|
|
2
|
+
|
|
3
|
+
const tt = (type, key) => global.t?.t('configs', type, key);
|
|
4
|
+
|
|
5
|
+
export const normalizeTextValue = value => String(value ?? '').trim();
|
|
6
|
+
|
|
7
|
+
export const isConnected = value =>
|
|
8
|
+
value === true ||
|
|
9
|
+
value === 1 ||
|
|
10
|
+
value === '1' ||
|
|
11
|
+
String(value).trim().toLowerCase() === 'true';
|
|
12
|
+
|
|
13
|
+
export const formatApiError = error =>
|
|
14
|
+
error?.message ||
|
|
15
|
+
error?.description ||
|
|
16
|
+
error?.error ||
|
|
17
|
+
tt('marketplace_error', 'mercadoLivreLoad') ||
|
|
18
|
+
'Nao foi possivel carregar a integracao Mercado Livre.';
|
|
19
|
+
|
|
20
|
+
const MERCADO_LIVRE_OAUTH_QUERY_KEYS = [
|
|
21
|
+
'code',
|
|
22
|
+
'state',
|
|
23
|
+
'error',
|
|
24
|
+
'error_description',
|
|
25
|
+
'mercadolivre_connected',
|
|
26
|
+
'mercadolivre_error',
|
|
27
|
+
'mercadolivre_message',
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export const resolveFrontOAuthRedirectUri = () => {
|
|
31
|
+
if (Platform.OS !== 'web' || typeof window === 'undefined') {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const url = new URL(window.location.href);
|
|
36
|
+
MERCADO_LIVRE_OAUTH_QUERY_KEYS.forEach(key => url.searchParams.delete(key));
|
|
37
|
+
url.hash = '';
|
|
38
|
+
|
|
39
|
+
return url.toString();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const replaceFrontOAuthStatus = statusParams => {
|
|
43
|
+
if (Platform.OS !== 'web' || typeof window === 'undefined') {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const url = new URL(window.location.href);
|
|
48
|
+
MERCADO_LIVRE_OAUTH_QUERY_KEYS.forEach(key => url.searchParams.delete(key));
|
|
49
|
+
Object.entries(statusParams || {}).forEach(([key, value]) => {
|
|
50
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
51
|
+
url.searchParams.set(key, String(value));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
window.history.replaceState({}, document.title, url.toString());
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const formatOAuthStatusError = (error, message) => {
|
|
58
|
+
const messageText = normalizeTextValue(message);
|
|
59
|
+
if (messageText) {
|
|
60
|
+
return `${
|
|
61
|
+
tt('marketplace_error', 'mercadoLivreConnectWithMessage') ||
|
|
62
|
+
'Nao foi possivel conectar o Mercado Livre:'
|
|
63
|
+
} ${messageText}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const errorText = normalizeTextValue(error);
|
|
67
|
+
if (!errorText) {
|
|
68
|
+
return (
|
|
69
|
+
tt('marketplace_error', 'mercadoLivreConnect') ||
|
|
70
|
+
'Nao foi possivel conectar o Mercado Livre.'
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return `${
|
|
75
|
+
tt('marketplace_error', 'mercadoLivreConnect') ||
|
|
76
|
+
'Nao foi possivel conectar o Mercado Livre.'
|
|
77
|
+
} (${errorText}).`;
|
|
78
|
+
};
|
|
79
|
+
|
|
@@ -141,9 +141,23 @@ const installSession = async (page, {companyId = 3} = {}) => {
|
|
|
141
141
|
active: 1,
|
|
142
142
|
mycompany: companyId,
|
|
143
143
|
roles: ['ROLE_ADMIN'],
|
|
144
|
+
name: 'Test User',
|
|
145
|
+
realname: 'Test User',
|
|
146
|
+
username: 'tester',
|
|
144
147
|
}),
|
|
145
148
|
);
|
|
146
149
|
set('config', JSON.stringify({language: 'pt-br'}));
|
|
150
|
+
// Resolve menu labels locally; the mock API does not provide translations.
|
|
151
|
+
const labels = {
|
|
152
|
+
home: 'Início', opportunities: 'Oportunidades',
|
|
153
|
+
customers: 'Clientes', profile: 'Perfil',
|
|
154
|
+
};
|
|
155
|
+
const companyMessages = {
|
|
156
|
+
menu: {menu: labels}, configs: {toolbar: labels},
|
|
157
|
+
};
|
|
158
|
+
set('translates', JSON.stringify({
|
|
159
|
+
'pt-br': {companies: {3: companyMessages, 9: companyMessages}},
|
|
160
|
+
}));
|
|
147
161
|
set('app-type', 'MANAGER');
|
|
148
162
|
set(
|
|
149
163
|
'device',
|
|
@@ -64,6 +64,13 @@ const mockConnectionsApi = async page => {
|
|
|
64
64
|
return route.fulfill({status: 204, headers: CORS_HEADERS, body: ''});
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
if (pathname === 'people/companies/my') {
|
|
68
|
+
return route.fulfill({
|
|
69
|
+
status: 200, headers: jsonHeaders(),
|
|
70
|
+
body: JSON.stringify(collection([company])),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
67
74
|
if (pathname === 'companies' || pathname.startsWith('people/')) {
|
|
68
75
|
return route.fulfill({
|
|
69
76
|
status: 200,
|
|
@@ -103,9 +110,20 @@ const mockConnectionsApi = async page => {
|
|
|
103
110
|
active: 1,
|
|
104
111
|
mycompany: 3,
|
|
105
112
|
roles: ['ROLE_ADMIN'],
|
|
113
|
+
name: 'Test User',
|
|
114
|
+
realname: 'Test User',
|
|
115
|
+
username: 'tester',
|
|
106
116
|
}),
|
|
107
117
|
);
|
|
108
118
|
set('config', JSON.stringify({language: 'pt-br'}));
|
|
119
|
+
set('translates', JSON.stringify({
|
|
120
|
+
'pt-br': {companies: {3: {configs: {
|
|
121
|
+
connections_title: {connections: 'Conexões'},
|
|
122
|
+
connections_label: {
|
|
123
|
+
whatsApp: 'WhatsApp', search: 'Buscar conexao, telefone ou status',
|
|
124
|
+
},
|
|
125
|
+
}}}},
|
|
126
|
+
}));
|
|
109
127
|
set('app-type', 'ERP');
|
|
110
128
|
set(
|
|
111
129
|
'device',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const {installManagerSession} = require('./managerSession.fixture');
|
|
1
2
|
/**
|
|
2
3
|
* Smoke browser: Manager /device-detail alias save updates header without refresh.
|
|
3
4
|
* fluxo: manager-devices
|
|
@@ -86,6 +87,7 @@ const MODULES_MAX_500 = [
|
|
|
86
87
|
];
|
|
87
88
|
|
|
88
89
|
const mockDevicesApi = async (page) => {
|
|
90
|
+
await installManagerSession(page);
|
|
89
91
|
const company = {
|
|
90
92
|
id: 3,
|
|
91
93
|
name: 'Teste',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const {installManagerSession} = require('./managerSession.fixture');
|
|
1
2
|
/**
|
|
2
3
|
* Smoke browser: Manager /device-detail copy configs from another device.
|
|
3
4
|
* fluxo: manager-devices
|
|
@@ -110,6 +111,7 @@ const otherTenant = createDeviceConfig({
|
|
|
110
111
|
});
|
|
111
112
|
|
|
112
113
|
const mockCopyApi = async (page) => {
|
|
114
|
+
await installManagerSession(page);
|
|
113
115
|
const company = {
|
|
114
116
|
id: 3,
|
|
115
117
|
name: 'Teste',
|
|
@@ -328,6 +330,10 @@ test.describe('device-detail copy config (browser smoke #629)', () => {
|
|
|
328
330
|
await expect(page.getByTestId('copy-device-config-hint')).toContainText(
|
|
329
331
|
DEST_ALIAS,
|
|
330
332
|
);
|
|
333
|
+
// The translated prefix cannot supply a fixture alias: target identity is dynamic.
|
|
334
|
+
await expect(page.getByTestId('copy-device-config-hint')).not.toContainText(
|
|
335
|
+
SRC_ALIAS,
|
|
336
|
+
);
|
|
331
337
|
await shot('02-copy-modal-picker.png');
|
|
332
338
|
|
|
333
339
|
await expect(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const {installManagerSession} = require('./managerSession.fixture');
|
|
1
2
|
/**
|
|
2
3
|
* Smoke browser: DeviceConfig PDV detail opens without currentCompany ReferenceError.
|
|
3
4
|
* fluxo: device-configuracao
|
|
@@ -91,6 +92,7 @@ const createDeviceConfig = ({id, type, device = currentDevice}) => ({
|
|
|
91
92
|
});
|
|
92
93
|
|
|
93
94
|
const mockDevicesApi = async page => {
|
|
95
|
+
await installManagerSession(page);
|
|
94
96
|
const company = {
|
|
95
97
|
id: 3,
|
|
96
98
|
name: 'Teste',
|
|
@@ -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
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const {installManagerSession} = require('./managerSession.fixture');
|
|
1
2
|
const {expect, test} = require('playwright/test');
|
|
2
3
|
const packageJson = require('../../../../../../../package.json');
|
|
3
4
|
const {API_ORIGIN} = require('../../../../../../../src/tests/browser/apiOrigin');
|
|
@@ -76,6 +77,7 @@ const createDeviceConfig = ({id, type, device = currentDevice, alias}) => ({
|
|
|
76
77
|
* (or omit type for All). Multi-type filters expand to sequential single-type GETs.
|
|
77
78
|
*/
|
|
78
79
|
const mockDevicesTypeFilterApi = async page => {
|
|
80
|
+
await installManagerSession(page);
|
|
79
81
|
const company = {
|
|
80
82
|
id: 3,
|
|
81
83
|
name: 'Teste',
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Match the authenticated session contract used by the application shell.
|
|
2
|
+
const installManagerSession = async page => {
|
|
3
|
+
await page.addInitScript(() => {
|
|
4
|
+
localStorage.setItem('session', JSON.stringify({
|
|
5
|
+
id: 7,
|
|
6
|
+
people: '/people/7',
|
|
7
|
+
api_key: 'test-api-key',
|
|
8
|
+
active: 1,
|
|
9
|
+
mycompany: 3,
|
|
10
|
+
roles: ['ROLE_SUPER'],
|
|
11
|
+
name: 'Test User',
|
|
12
|
+
realname: 'Test User',
|
|
13
|
+
username: 'tester',
|
|
14
|
+
}));
|
|
15
|
+
localStorage.setItem('app-type', 'MANAGER');
|
|
16
|
+
localStorage.setItem('translates', JSON.stringify({
|
|
17
|
+
'pt-br': {companies: {3: {configs: {
|
|
18
|
+
device_label: {currentDevice: 'Este dispositivo'},
|
|
19
|
+
device_action: {
|
|
20
|
+
copyConfigHint: 'Escolha o device origem. As configurações serão aplicadas em',
|
|
21
|
+
copyConfigIdentityHint: 'identidade do destino não muda',
|
|
22
|
+
},
|
|
23
|
+
}}}},
|
|
24
|
+
}));
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = {installManagerSession};
|