@controleonline/ui-customers 1.0.81
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/.github/agents/developer.agent.md +30 -0
- package/.github/agents/devops.agent.md +30 -0
- package/.github/agents/qa.agent.md +30 -0
- package/.github/agents/security.agent.md +30 -0
- package/.scrutinizer.yml +20 -0
- package/AGENTS.md +50 -0
- package/FUNDING.yml +1 -0
- package/README.md +23 -0
- package/docs/technical/Client-Details-Franquia-Filial.md +18 -0
- package/docs/technical/Client-Details-People-Name-Case.md +103 -0
- package/docs/technical/Cliente-Vendedor-Vinculo-e-Permissoes.md +152 -0
- package/docs/wiki.md +1 -0
- package/package.json +32 -0
- package/scripts/validate-wiki-pointer.cjs +13 -0
- package/src/react/components/tabs/AddressesTab.js +494 -0
- package/src/react/components/tabs/CategoriesTab.js +196 -0
- package/src/react/components/tabs/ClassificationChips.js +494 -0
- package/src/react/components/tabs/ContactTab.js +621 -0
- package/src/react/components/tabs/ContactTab.styles.js +119 -0
- package/src/react/components/tabs/ContractsTab.js +13 -0
- package/src/react/components/tabs/DocumentsTab.js +463 -0
- package/src/react/components/tabs/DocumentsTab.styles.js +133 -0
- package/src/react/components/tabs/EmployeeContactRow.js +83 -0
- package/src/react/components/tabs/EmployeesTab.js +454 -0
- package/src/react/components/tabs/EmployeesTab.styles.js +172 -0
- package/src/react/components/tabs/FiscalTab.js +6 -0
- package/src/react/components/tabs/FranchiseCommissionSection.js +307 -0
- package/src/react/components/tabs/FranchiseLinksManageModal.js +215 -0
- package/src/react/components/tabs/FranchiseLinksTab.js +282 -0
- package/src/react/components/tabs/GeneralTab.js +466 -0
- package/src/react/components/tabs/GeneralTab.styles.js +101 -0
- package/src/react/components/tabs/MediaTab.js +356 -0
- package/src/react/components/tabs/PeopleCategoriesPanel.js +601 -0
- package/src/react/components/tabs/ProductsTab.js +236 -0
- package/src/react/components/tabs/ProductsTab.styles.js +143 -0
- package/src/react/components/tabs/SalesmanCommissionBlock.js +120 -0
- package/src/react/components/tabs/SalesmanManageModal.js +208 -0
- package/src/react/components/tabs/SalesmanTab.js +436 -0
- package/src/react/components/tabs/SalesmanTab.styles.js +4 -0
- package/src/react/components/tabs/UserApiKeyModal.js +90 -0
- package/src/react/components/tabs/UserFormModal.js +301 -0
- package/src/react/components/tabs/UsersTab.js +426 -0
- package/src/react/components/tabs/UsersTab.styles.js +283 -0
- package/src/react/components/tabs/UsersTab.styles.test.js +42 -0
- package/src/react/components/tabs/contactMutationMessage.js +18 -0
- package/src/react/components/tabs/employeeContacts.js +214 -0
- package/src/react/components/tabs/employeeUnlink.js +68 -0
- package/src/react/components/tabs/employeesTabHelpers.js +227 -0
- package/src/react/components/tabs/franchiseCommissionHelpers.js +134 -0
- package/src/react/components/tabs/franchiseLinksTab.helpers.js +247 -0
- package/src/react/components/tabs/generalTabHelpers.js +120 -0
- package/src/react/components/tabs/salesmanTab.helpers.js +114 -0
- package/src/react/components/tabs/salesmanTabHelpers.js +173 -0
- package/src/react/components/tabs/salesmanTabMedia.js +55 -0
- package/src/react/components/tabs/salesmanTabSession.js +39 -0
- package/src/react/components/tabs/useEmployeeUnlink.js +58 -0
- package/src/react/components/tabs/useFranchiseLinksManage.js +215 -0
- package/src/react/components/tabs/useSalesmanManage.js +222 -0
- package/src/react/components/tabs/usersTabHelpers.js +221 -0
- package/src/react/domain/productSupplierFlow.js +37 -0
- package/src/react/index.js +4 -0
- package/src/react/pages/ClientDetailsSkeleton.js +84 -0
- package/src/react/pages/clientDetailsHelpers.js +17 -0
- package/src/react/pages/clients.js +27 -0
- package/src/react/pages/details.js +529 -0
- package/src/react/pages/details.page.styles.js +105 -0
- package/src/react/pages/details.styles.js +15 -0
- package/src/react/pages/employees.js +69 -0
- package/src/react/pages/franchisees.js +30 -0
- package/src/react/pages/prospects.js +21 -0
- package/src/react/pages/provider.js +21 -0
- package/src/react/router/routes.js +104 -0
- package/src/react/styles/details.js +571 -0
- package/src/store/people_categories/index.js +72 -0
- package/src/tests/browser/manager/client-details-create-user.spec.js +321 -0
- package/src/tests/browser/manager/client-details-employee-unlink.spec.js +215 -0
- package/src/tests/browser/manager/client-details-employees-refresh.spec.js +271 -0
- package/src/tests/browser/manager/client-details-enable.spec.js +241 -0
- package/src/tests/browser/manager/client-details-fiscal-tabs.spec.js +410 -0
- package/src/tests/browser/manager/client-details-franchise-commission.spec.js +318 -0
- package/src/tests/browser/manager/client-details-franchise-links.spec.js +365 -0
- package/src/tests/browser/manager/client-details-media.spec.js +405 -0
- package/src/tests/browser/manager/client-details-relationships.spec.js +313 -0
- package/src/tests/browser/manager/client-details-salesman-commission.spec.js +291 -0
- package/src/tests/browser/manager/client-details-salesman-manage.spec.js +448 -0
- package/src/tests/react/components/tabs/contactMutationMessage.test.js +25 -0
- package/src/tests/react/components/tabs/employeeContacts.test.js +266 -0
- package/src/tests/react/components/tabs/employeeUnlink.test.js +67 -0
- package/src/tests/react/components/tabs/employeesTabHelpers.media.test.js +78 -0
- package/src/tests/react/components/tabs/employeesTabHelpers.test.js +64 -0
- package/src/tests/react/components/tabs/fiscalTabContract.test.mjs +29 -0
- package/src/tests/react/components/tabs/franchiseCommissionHelpers.test.js +128 -0
- package/src/tests/react/components/tabs/franchiseLinksTab.helpers.test.mjs +166 -0
- package/src/tests/react/components/tabs/generalTabHelpers.test.js +130 -0
- package/src/tests/react/components/tabs/peopleMediaTabs.test.js +322 -0
- package/src/tests/react/components/tabs/salesmanTab.helpers.test.mjs +75 -0
- package/src/tests/react/components/tabs/salesmanTabHelpers.test.js +142 -0
- package/src/tests/react/components/tabs/salesmanTabHelpers.test.mjs +92 -0
- package/src/tests/react/components/tabs/usersTabHelpers.test.js +59 -0
- package/src/tests/react/domain/productSupplierFlow.test.mjs +55 -0
- package/src/tests/react/pages/clientDetailsHelpers.test.js +98 -0
- package/src/tests/react/pages/employees.test.js +44 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smoke: EmployeesTab list refresh on focus after edit (app-community#375)
|
|
3
|
+
*
|
|
4
|
+
* Covers acceptance:
|
|
5
|
+
* 1. Open Client Details → aba Colaboradores/contacts
|
|
6
|
+
* 2. List shows initial employee name from people_links GET
|
|
7
|
+
* 3. Simulate leave + return (focus regain, same path as edit→back)
|
|
8
|
+
* 4. List shows updated payload from subsequent people_links GET without full F5
|
|
9
|
+
*/
|
|
10
|
+
const {expect, test} = require('playwright/test');
|
|
11
|
+
const {API_ORIGIN} = require('../../../../../../../src/tests/browser/apiOrigin');
|
|
12
|
+
const {version: appVersion} = require('../../../../../../../package.json');
|
|
13
|
+
|
|
14
|
+
const CORS_HEADERS = {
|
|
15
|
+
'access-control-allow-origin': '*',
|
|
16
|
+
'access-control-allow-headers':
|
|
17
|
+
'API-TOKEN, APP-DOMAIN, DEVICE, ACCEPT, CONTENT-TYPE, X-Requested-With',
|
|
18
|
+
'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const jsonHeaders = () => ({
|
|
22
|
+
...CORS_HEADERS,
|
|
23
|
+
'content-type': 'application/ld+json; charset=utf-8',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const textHeaders = () => ({
|
|
27
|
+
...CORS_HEADERS,
|
|
28
|
+
'content-type': 'text/css; charset=utf-8',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const collection = (member = []) => ({
|
|
32
|
+
member,
|
|
33
|
+
'hydra:member': member,
|
|
34
|
+
totalItems: member.length,
|
|
35
|
+
'hydra:totalItems': member.length,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const company = {
|
|
39
|
+
'@id': '/people/2',
|
|
40
|
+
id: 2,
|
|
41
|
+
name: 'CONTROLE ONLINE',
|
|
42
|
+
alias: 'CONTROLE ONLINE',
|
|
43
|
+
panel_enabled: true,
|
|
44
|
+
enabled: true,
|
|
45
|
+
commercial_enabled: true,
|
|
46
|
+
theme: {
|
|
47
|
+
colors: {
|
|
48
|
+
primary: '#0EA5E9',
|
|
49
|
+
secondary: '#F97316',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
configs: {},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const client = {
|
|
56
|
+
'@id': '/people/31487',
|
|
57
|
+
id: 31487,
|
|
58
|
+
name: 'CLIENTE TESTE LTDA',
|
|
59
|
+
alias: 'CLIENTE TESTE',
|
|
60
|
+
peopleType: 'J',
|
|
61
|
+
enable: true,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const employeeBefore = {
|
|
65
|
+
'@id': '/people/90010',
|
|
66
|
+
id: 90010,
|
|
67
|
+
name: 'COLABORADOR ANTIGO',
|
|
68
|
+
alias: 'ANTIGO',
|
|
69
|
+
peopleType: 'F',
|
|
70
|
+
enable: true,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const employeeAfter = {
|
|
74
|
+
'@id': '/people/90010',
|
|
75
|
+
id: 90010,
|
|
76
|
+
name: 'COLABORADOR ATUALIZADO',
|
|
77
|
+
alias: 'ATUALIZADO',
|
|
78
|
+
peopleType: 'F',
|
|
79
|
+
enable: true,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const buildPeopleLink = person => ({
|
|
83
|
+
'@id': '/people_links/501',
|
|
84
|
+
id: 501,
|
|
85
|
+
linkType: 'employee',
|
|
86
|
+
people: person,
|
|
87
|
+
company: {id: 31487, '@id': '/people/31487'},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const mockEmployeesRefreshApi = async page => {
|
|
91
|
+
let peopleLinksGetCount = 0;
|
|
92
|
+
const peopleLinksGetUrls = [];
|
|
93
|
+
|
|
94
|
+
await page.route(`${API_ORIGIN}/**`, async route => {
|
|
95
|
+
const request = route.request();
|
|
96
|
+
const url = new URL(request.url());
|
|
97
|
+
const pathname = url.pathname.replace(/^\/+/, '');
|
|
98
|
+
const method = request.method().toUpperCase();
|
|
99
|
+
|
|
100
|
+
if (method === 'OPTIONS') {
|
|
101
|
+
return route.fulfill({status: 204, headers: CORS_HEADERS, body: ''});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (pathname === 'themes-colors.css') {
|
|
105
|
+
return route.fulfill({
|
|
106
|
+
status: 200,
|
|
107
|
+
headers: textHeaders(),
|
|
108
|
+
body: ':root { --primary: #0ea5e9; --secondary: #f97316; }',
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (pathname === 'runtime/ip') {
|
|
113
|
+
return route.fulfill({
|
|
114
|
+
status: 200,
|
|
115
|
+
headers: jsonHeaders(),
|
|
116
|
+
body: JSON.stringify({ip: '127.0.0.1'}),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (pathname === 'people/company/default') {
|
|
121
|
+
return route.fulfill({
|
|
122
|
+
status: 200,
|
|
123
|
+
headers: jsonHeaders(),
|
|
124
|
+
body: JSON.stringify(company),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (pathname === 'people/companies/my') {
|
|
129
|
+
return route.fulfill({
|
|
130
|
+
status: 200,
|
|
131
|
+
headers: jsonHeaders(),
|
|
132
|
+
body: JSON.stringify(collection([company])),
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (pathname === 'people/31487' && method === 'GET') {
|
|
137
|
+
return route.fulfill({
|
|
138
|
+
status: 200,
|
|
139
|
+
headers: jsonHeaders(),
|
|
140
|
+
body: JSON.stringify(client),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (pathname === 'people/90010' && method === 'GET') {
|
|
145
|
+
return route.fulfill({
|
|
146
|
+
status: 200,
|
|
147
|
+
headers: jsonHeaders(),
|
|
148
|
+
body: JSON.stringify(
|
|
149
|
+
peopleLinksGetCount > 1 ? employeeAfter : employeeBefore,
|
|
150
|
+
),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (
|
|
155
|
+
(pathname === 'people_links' || pathname === 'people-links') &&
|
|
156
|
+
method === 'GET'
|
|
157
|
+
) {
|
|
158
|
+
peopleLinksGetCount += 1;
|
|
159
|
+
peopleLinksGetUrls.push(request.url());
|
|
160
|
+
const person = peopleLinksGetCount === 1 ? employeeBefore : employeeAfter;
|
|
161
|
+
return route.fulfill({
|
|
162
|
+
status: 200,
|
|
163
|
+
headers: jsonHeaders(),
|
|
164
|
+
body: JSON.stringify(collection([buildPeopleLink(person)])),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (pathname.startsWith('people/') && method === 'GET') {
|
|
169
|
+
return route.fulfill({
|
|
170
|
+
status: 200,
|
|
171
|
+
headers: jsonHeaders(),
|
|
172
|
+
body: JSON.stringify({
|
|
173
|
+
id: Number(pathname.split('/')[1]) || 0,
|
|
174
|
+
name: 'X',
|
|
175
|
+
peopleType: 'F',
|
|
176
|
+
}),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (method === 'GET') {
|
|
181
|
+
return route.fulfill({
|
|
182
|
+
status: 200,
|
|
183
|
+
headers: jsonHeaders(),
|
|
184
|
+
body: JSON.stringify(collection([])),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return route.fulfill({
|
|
189
|
+
status: 200,
|
|
190
|
+
headers: jsonHeaders(),
|
|
191
|
+
body: JSON.stringify({}),
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
await page.addInitScript(
|
|
196
|
+
({version}) => {
|
|
197
|
+
localStorage.setItem(
|
|
198
|
+
'session',
|
|
199
|
+
JSON.stringify({
|
|
200
|
+
id: 19,
|
|
201
|
+
people: '/people/19',
|
|
202
|
+
api_key: 'test-api-key',
|
|
203
|
+
active: 1,
|
|
204
|
+
mycompany: 2,
|
|
205
|
+
roles: ['ROLE_SUPER'],
|
|
206
|
+
}),
|
|
207
|
+
);
|
|
208
|
+
localStorage.setItem('app-type', 'MANAGER');
|
|
209
|
+
localStorage.setItem('config', JSON.stringify({language: 'pt-br'}));
|
|
210
|
+
localStorage.setItem(
|
|
211
|
+
'device',
|
|
212
|
+
JSON.stringify({
|
|
213
|
+
id: 'web-manager',
|
|
214
|
+
device: 'web-manager',
|
|
215
|
+
type: 'WEB',
|
|
216
|
+
appName: 'Browser Manager',
|
|
217
|
+
appVersion: version,
|
|
218
|
+
buildNumber: version,
|
|
219
|
+
systemName: 'web',
|
|
220
|
+
systemVersion: 'web',
|
|
221
|
+
deviceType: 'web',
|
|
222
|
+
metadata: {},
|
|
223
|
+
}),
|
|
224
|
+
);
|
|
225
|
+
},
|
|
226
|
+
{version: appVersion},
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
return {
|
|
230
|
+
getPeopleLinksGetCount: () => peopleLinksGetCount,
|
|
231
|
+
getPeopleLinksGetUrls: () => peopleLinksGetUrls,
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
test.describe('client-details employees list refresh on focus (#375)', () => {
|
|
236
|
+
test('refetches people_links on focus and shows updated employee without full reload', async ({
|
|
237
|
+
page,
|
|
238
|
+
}) => {
|
|
239
|
+
const api = await mockEmployeesRefreshApi(page);
|
|
240
|
+
|
|
241
|
+
await page.goto(
|
|
242
|
+
'/client-details?clientId=31487&contextKey=contacts&initialTab=contacts&parentCompanyId=8&linkType=employee',
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
await expect(
|
|
246
|
+
page.getByText('CLIENTE TESTE', {exact: false}).first(),
|
|
247
|
+
).toBeVisible({timeout: 15000});
|
|
248
|
+
|
|
249
|
+
// Initial list from first people_links GET
|
|
250
|
+
await expect(
|
|
251
|
+
page.getByText(/COLABORADOR ANTIGO/i).first(),
|
|
252
|
+
).toBeVisible({timeout: 15000});
|
|
253
|
+
|
|
254
|
+
const firstCount = api.getPeopleLinksGetCount();
|
|
255
|
+
expect(firstCount).toBeGreaterThanOrEqual(1);
|
|
256
|
+
|
|
257
|
+
// Simulate edit→back: leave the screen and return (triggers useFocusEffect refetch)
|
|
258
|
+
await page.goto('/clients');
|
|
259
|
+
await page.goto(
|
|
260
|
+
'/client-details?clientId=31487&contextKey=contacts&initialTab=contacts&parentCompanyId=8&linkType=employee',
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
await expect(
|
|
264
|
+
page.getByText(/COLABORADOR ATUALIZADO/i).first(),
|
|
265
|
+
).toBeVisible({timeout: 15000});
|
|
266
|
+
|
|
267
|
+
await expect(page.getByText(/COLABORADOR ANTIGO/i)).toHaveCount(0);
|
|
268
|
+
|
|
269
|
+
expect(api.getPeopleLinksGetCount()).toBeGreaterThan(firstCount);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
const {expect, test} = require('playwright/test');
|
|
2
|
+
const {API_ORIGIN} = require('../../../../../../../src/tests/browser/apiOrigin');
|
|
3
|
+
const {version: appVersion} = require('../../../../../../../package.json');
|
|
4
|
+
|
|
5
|
+
const CORS_HEADERS = {
|
|
6
|
+
'access-control-allow-origin': '*',
|
|
7
|
+
'access-control-allow-headers':
|
|
8
|
+
'API-TOKEN, APP-DOMAIN, DEVICE, ACCEPT, CONTENT-TYPE, X-Requested-With',
|
|
9
|
+
'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const collection = (member = [], summary = {}) => ({
|
|
13
|
+
member,
|
|
14
|
+
'hydra:member': member,
|
|
15
|
+
totalItems: member.length,
|
|
16
|
+
'hydra:totalItems': member.length,
|
|
17
|
+
summary,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const jsonHeaders = () => ({
|
|
21
|
+
...CORS_HEADERS,
|
|
22
|
+
'content-type': 'application/ld+json; charset=utf-8',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const textHeaders = () => ({
|
|
26
|
+
...CORS_HEADERS,
|
|
27
|
+
'content-type': 'text/css; charset=utf-8',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const createCompany = () => ({
|
|
31
|
+
id: 3,
|
|
32
|
+
name: 'Controle Online',
|
|
33
|
+
alias: 'CONTROLE ONLINE',
|
|
34
|
+
panel_enabled: true,
|
|
35
|
+
enabled: true,
|
|
36
|
+
commercial_enabled: true,
|
|
37
|
+
theme: {
|
|
38
|
+
colors: {
|
|
39
|
+
primary: '#0EA5E9',
|
|
40
|
+
secondary: '#F97316',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
configs: {},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const mockClientDetailsEnableApi = async page => {
|
|
47
|
+
const company = createCompany();
|
|
48
|
+
let peopleEnable = false;
|
|
49
|
+
const peopleLinkWriteMethods = [];
|
|
50
|
+
|
|
51
|
+
await page.route(`${API_ORIGIN}/**`, async route => {
|
|
52
|
+
const request = route.request();
|
|
53
|
+
const url = new URL(request.url());
|
|
54
|
+
const pathname = url.pathname.replace(/^\/+/, '');
|
|
55
|
+
const method = request.method().toUpperCase();
|
|
56
|
+
|
|
57
|
+
if (method === 'OPTIONS') {
|
|
58
|
+
return route.fulfill({
|
|
59
|
+
status: 204,
|
|
60
|
+
headers: CORS_HEADERS,
|
|
61
|
+
body: '',
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (pathname === 'themes-colors.css') {
|
|
66
|
+
return route.fulfill({
|
|
67
|
+
status: 200,
|
|
68
|
+
headers: textHeaders(),
|
|
69
|
+
body: ':root { --primary: #0ea5e9; --secondary: #f97316; }',
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (pathname === 'runtime/ip') {
|
|
74
|
+
return route.fulfill({
|
|
75
|
+
status: 200,
|
|
76
|
+
headers: jsonHeaders(),
|
|
77
|
+
body: JSON.stringify({ip: '127.0.0.1'}),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (pathname === 'people/company/default') {
|
|
82
|
+
return route.fulfill({
|
|
83
|
+
status: 200,
|
|
84
|
+
headers: jsonHeaders(),
|
|
85
|
+
body: JSON.stringify(company),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (pathname === 'people/companies/my') {
|
|
90
|
+
return route.fulfill({
|
|
91
|
+
status: 200,
|
|
92
|
+
headers: jsonHeaders(),
|
|
93
|
+
body: JSON.stringify(collection([company])),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (pathname === 'people/30') {
|
|
98
|
+
if (method === 'PUT' || method === 'PATCH') {
|
|
99
|
+
const body = await request.postDataJSON().catch(() => ({}));
|
|
100
|
+
if (typeof body.enable === 'boolean') {
|
|
101
|
+
peopleEnable = body.enable;
|
|
102
|
+
}
|
|
103
|
+
return route.fulfill({
|
|
104
|
+
status: 200,
|
|
105
|
+
headers: jsonHeaders(),
|
|
106
|
+
body: JSON.stringify({
|
|
107
|
+
'@id': '/people/30',
|
|
108
|
+
id: 30,
|
|
109
|
+
name: 'JOAO SILVA',
|
|
110
|
+
alias: 'JOAO SILVA',
|
|
111
|
+
peopleType: 'F',
|
|
112
|
+
enable: peopleEnable,
|
|
113
|
+
}),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return route.fulfill({
|
|
118
|
+
status: 200,
|
|
119
|
+
headers: jsonHeaders(),
|
|
120
|
+
body: JSON.stringify({
|
|
121
|
+
'@id': '/people/30',
|
|
122
|
+
id: 30,
|
|
123
|
+
name: 'JOAO SILVA',
|
|
124
|
+
alias: 'JOAO SILVA',
|
|
125
|
+
peopleType: 'F',
|
|
126
|
+
enable: peopleEnable,
|
|
127
|
+
}),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (pathname === 'people_links' || pathname.startsWith('people_links')) {
|
|
132
|
+
if (method !== 'GET') {
|
|
133
|
+
peopleLinkWriteMethods.push(method);
|
|
134
|
+
return route.fulfill({
|
|
135
|
+
status: 405,
|
|
136
|
+
headers: jsonHeaders(),
|
|
137
|
+
body: JSON.stringify({code: -1001, detail: 'Method Not Allowed'}),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return route.fulfill({
|
|
141
|
+
status: 200,
|
|
142
|
+
headers: jsonHeaders(),
|
|
143
|
+
body: JSON.stringify(collection([])),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (pathname === 'menus-people') {
|
|
148
|
+
return route.fulfill({
|
|
149
|
+
status: 200,
|
|
150
|
+
headers: jsonHeaders(),
|
|
151
|
+
body: JSON.stringify({modules: {}}),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (pathname === 'configs/discovery-configs') {
|
|
156
|
+
return route.fulfill({
|
|
157
|
+
status: 200,
|
|
158
|
+
headers: jsonHeaders(),
|
|
159
|
+
body: JSON.stringify({configs: {}}),
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return route.fulfill({
|
|
164
|
+
status: 200,
|
|
165
|
+
headers: jsonHeaders(),
|
|
166
|
+
body: JSON.stringify(collection([])),
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
await page.addInitScript(
|
|
171
|
+
({appVersion}) => {
|
|
172
|
+
const setLocalStorageItem = (key, value) => {
|
|
173
|
+
try {
|
|
174
|
+
localStorage.setItem(key, value);
|
|
175
|
+
} catch {
|
|
176
|
+
// ignore
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
setLocalStorageItem(
|
|
181
|
+
'session',
|
|
182
|
+
JSON.stringify({
|
|
183
|
+
id: 7,
|
|
184
|
+
people: '/people/7',
|
|
185
|
+
api_key: 'test-api-key',
|
|
186
|
+
active: 1,
|
|
187
|
+
mycompany: 3,
|
|
188
|
+
roles: ['ROLE_SUPER'],
|
|
189
|
+
}),
|
|
190
|
+
);
|
|
191
|
+
setLocalStorageItem('config', JSON.stringify({language: 'pt-br'}));
|
|
192
|
+
setLocalStorageItem('app-type', 'MANAGER');
|
|
193
|
+
setLocalStorageItem(
|
|
194
|
+
'device',
|
|
195
|
+
JSON.stringify({
|
|
196
|
+
id: 'web-manager',
|
|
197
|
+
device: 'web-manager',
|
|
198
|
+
type: 'WEB',
|
|
199
|
+
appName: 'Browser Manager',
|
|
200
|
+
appVersion,
|
|
201
|
+
buildNumber: appVersion,
|
|
202
|
+
systemName: 'web',
|
|
203
|
+
systemVersion: 'web',
|
|
204
|
+
deviceType: 'web',
|
|
205
|
+
metadata: {},
|
|
206
|
+
}),
|
|
207
|
+
);
|
|
208
|
+
},
|
|
209
|
+
{appVersion},
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
return {getPeopleLinkWriteMethods: () => peopleLinkWriteMethods};
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
test.describe('client details enable toggle browser smoke', () => {
|
|
216
|
+
test('toggles enable (Bloqueado → Liberado) and saves without people_link write', async ({
|
|
217
|
+
page,
|
|
218
|
+
}) => {
|
|
219
|
+
const api = await mockClientDetailsEnableApi(page);
|
|
220
|
+
|
|
221
|
+
await page.goto('/client-details?clientId=30&contextKey=contacts&parentCompanyId=29');
|
|
222
|
+
|
|
223
|
+
await expect(page.getByText('Dados Cadastrais', {exact: true})).toBeVisible({
|
|
224
|
+
timeout: 15000,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
await expect(page.getByText('Bloqueado', {exact: true})).toBeVisible();
|
|
228
|
+
|
|
229
|
+
await page.getByRole('switch').first().click();
|
|
230
|
+
|
|
231
|
+
await expect(page.getByText('Liberado', {exact: true})).toBeVisible();
|
|
232
|
+
|
|
233
|
+
await page.getByText(/Save Changes|Salvar alterações/i).click();
|
|
234
|
+
|
|
235
|
+
await expect(page.getByText(/registrationUpdated|atualizado|sucesso/i)).toBeVisible({
|
|
236
|
+
timeout: 10000,
|
|
237
|
+
}).catch(() => {});
|
|
238
|
+
|
|
239
|
+
expect(api.getPeopleLinkWriteMethods()).toEqual([]);
|
|
240
|
+
});
|
|
241
|
+
});
|