@controleonline/ui-crm 1.0.42 → 1.0.44
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/workflows/integration-source-gate.yml +82 -0
- package/.github/workflows/manager-worker.yml +7 -155
- package/.github/workflows/publish-npm.yml +73 -22
- package/AGENTS.md +2 -0
- package/package.json +2 -2
- package/src/react/pages/crm/hooks/useCrmData.js +23 -17
- package/src/react/pages/proposals/CreateProposalsModal.js +1 -0
- package/src/react/pages/proposals/index.js +14 -33
- package/src/react/pages/settings/GeneralSettings.styles.js +2 -0
- package/src/react/pages/settings/sections/LoyaltyProductPicker.js +58 -145
- package/src/react/pages/settings/sections/LoyaltySection.js +35 -9
- package/src/react/pages/settings/sections/MapsFranchisePreview.js +102 -0
- package/src/react/pages/settings/sections/MapsMapasControls.js +262 -0
- package/src/react/pages/settings/sections/MapsSection.js +71 -247
- package/src/react/pages/settings/sections/loyaltyProductCompany.js +57 -0
- package/src/react/pages/settings/sections/mapsSectionHelpers.js +137 -0
- package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +7 -28
- package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +54 -8
- package/src/react/pages/settings/sections/shop/shopSettingsShared.js +32 -11
- package/src/react/utils/clientDetailsNavigation.js +56 -0
- package/src/react/utils/clientSellerVisibility.js +60 -0
- package/src/react/utils/proposalProductSelection.js +103 -13
- package/src/react/utils/proposalStatus.js +160 -0
- package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +25 -0
- package/src/tests/browser/manager/general-settings-maps.spec.js +173 -347
- package/src/tests/react/pages/settings/sections/loyaltyProductCompany.test.js +41 -0
- package/src/tests/react/pages/settings/sections/mapsSectionHelpers.test.js +38 -0
- package/src/tests/react/utils/clientDetailsNavigation.test.js +98 -0
- package/src/tests/react/utils/clientSellerVisibility.test.js +74 -0
- package/src/tests/react/utils/proposalProductSelection.test.js +57 -1
- package/src/tests/react/utils/proposalStatus.test.mjs +77 -0
|
@@ -1,400 +1,226 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* fluxo: outros | etapa: general-settings-maps
|
|
4
|
-
* wikiPage: https://github.com/ControleOnline/app-community/wiki/Smoke-Test-Flows
|
|
2
|
+
* fluxo: manager-general-settings-maps
|
|
5
3
|
* flowchartIds: [1]
|
|
6
|
-
*
|
|
4
|
+
* app-community#360 — General Settings / Mapas (tela principal + localizador).
|
|
7
5
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
6
|
+
* Justificativa flowchartIds [1]: catálogo admin não tem entry de general-settings
|
|
7
|
+
* (ids históricos 1, 3, 4, 5). Âncora no flowchart habilitado #1.
|
|
8
|
+
*
|
|
9
|
+
* Sem page.route em endpoints de produto (people, people_links, configs, addresses).
|
|
10
|
+
* Sessão via SMOKE_API_TOKEN (localStorage) quando presente; senão UI de login real.
|
|
13
11
|
*/
|
|
14
|
-
const { expect, test } = require('playwright/test');
|
|
15
12
|
const fs = require('fs');
|
|
16
13
|
const path = require('path');
|
|
14
|
+
const { expect, test } = require('playwright/test');
|
|
17
15
|
const packageJson = require('../../../../../../../package.json');
|
|
18
|
-
const { API_ORIGIN } = require('../../../../../../../src/tests/browser/apiOrigin');
|
|
19
16
|
|
|
20
17
|
const APP_VERSION = packageJson?.version || '1.0.0';
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const screenshot = `${stepId}.png`;
|
|
27
|
-
await page.screenshot({path: path.join(outputDir, screenshot), fullPage: true});
|
|
28
|
-
steps.push({id: stepId, title, screenshot, viewport: page.viewportSize(), url: page.url()});
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const CORS_HEADERS = {
|
|
32
|
-
'access-control-allow-origin': '*',
|
|
33
|
-
'access-control-allow-headers':
|
|
34
|
-
'API-TOKEN, APP-DOMAIN, DEVICE, ACCEPT, CONTENT-TYPE, X-Requested-With',
|
|
35
|
-
'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const jsonHeaders = () => ({
|
|
39
|
-
...CORS_HEADERS,
|
|
40
|
-
'content-type': 'application/ld+json; charset=utf-8',
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const collection = member => ({
|
|
44
|
-
member,
|
|
45
|
-
'hydra:member': member,
|
|
46
|
-
totalItems: member.length,
|
|
47
|
-
'hydra:totalItems': member.length,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const company = {
|
|
51
|
-
'@id': '/people/3',
|
|
52
|
-
id: 3,
|
|
53
|
-
name: 'GYROS SMOKE',
|
|
54
|
-
alias: 'GYROS',
|
|
55
|
-
panel_enabled: true,
|
|
56
|
-
enabled: true,
|
|
57
|
-
commercial_enabled: true,
|
|
58
|
-
configs: {
|
|
59
|
-
'shop-sales-page-enabled': true,
|
|
60
|
-
'shop-franchise-locator-enabled': true,
|
|
61
|
-
'shop-primary-entry': 'franchise-locator',
|
|
62
|
-
'shop-franchise-visible-company-ids': '[]',
|
|
63
|
-
'shop-franchise-visible-address-ids': '[]',
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const franchiseCompany = {
|
|
68
|
-
'@id': '/people/31',
|
|
69
|
-
id: 31,
|
|
70
|
-
name: 'FRANQUIA SMOKE',
|
|
71
|
-
alias: 'FRANQUIA',
|
|
72
|
-
peopleType: 'J',
|
|
73
|
-
shopAddresses: [
|
|
74
|
-
{
|
|
75
|
-
'@id': '/addresses/501',
|
|
76
|
-
id: 501,
|
|
77
|
-
nickname: 'Matriz',
|
|
78
|
-
street: 'Av Paulista',
|
|
79
|
-
number: '1000',
|
|
80
|
-
city: 'São Paulo',
|
|
81
|
-
latitude: -23.5614,
|
|
82
|
-
longitude: -46.6558,
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
};
|
|
18
|
+
const FLOW_ID = 'manager-general-settings-maps';
|
|
19
|
+
const FLOWCHART_IDS = [1];
|
|
20
|
+
const FLOWCHART_LINKS = FLOWCHART_IDS.map(
|
|
21
|
+
id => `https://admin.controleonline.com/admin/flowcharts/${id}`,
|
|
22
|
+
);
|
|
86
23
|
|
|
87
24
|
const MODULES_MAX_500 = [
|
|
88
|
-
path.join(__dirname, '../../../react/pages/settings/sections/
|
|
89
|
-
path.join(
|
|
25
|
+
path.join(__dirname, '../../../react/pages/settings/sections/MapsSection.js'),
|
|
26
|
+
path.join(
|
|
27
|
+
__dirname,
|
|
28
|
+
'../../../react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js',
|
|
29
|
+
),
|
|
90
30
|
];
|
|
91
31
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return route.fulfill({
|
|
105
|
-
status: 200,
|
|
106
|
-
headers: { ...CORS_HEADERS, 'content-type': 'text/css; charset=utf-8' },
|
|
107
|
-
body: ':root { --primary: #0ea5e9; }',
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (pathname === 'runtime/ip') {
|
|
112
|
-
return route.fulfill({
|
|
113
|
-
status: 200,
|
|
114
|
-
headers: jsonHeaders(),
|
|
115
|
-
body: JSON.stringify({ ip: '127.0.0.1' }),
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (pathname === 'token' || pathname === 'token/') {
|
|
120
|
-
return route.fulfill({
|
|
121
|
-
status: 200,
|
|
122
|
-
headers: jsonHeaders(),
|
|
123
|
-
body: JSON.stringify({
|
|
124
|
-
id: 360,
|
|
125
|
-
// Keep the fixture identical to the API contract used by the
|
|
126
|
-
// production token response and the auth store's numeric checks.
|
|
127
|
-
active: 1,
|
|
128
|
-
type: 'MANAGER',
|
|
129
|
-
people: 3,
|
|
130
|
-
api_key: 'smoke-token-360',
|
|
131
|
-
}),
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (pathname === 'menus-people') {
|
|
136
|
-
return route.fulfill({
|
|
137
|
-
status: 200,
|
|
138
|
-
headers: jsonHeaders(),
|
|
139
|
-
body: JSON.stringify({ modules: {} }),
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (pathname === 'people/companies/my' || pathname === 'people') {
|
|
144
|
-
return route.fulfill({
|
|
145
|
-
status: 200,
|
|
146
|
-
headers: jsonHeaders(),
|
|
147
|
-
body: JSON.stringify(collection([company])),
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (pathname === 'people/3' || pathname === 'people/3/') {
|
|
152
|
-
return route.fulfill({
|
|
153
|
-
status: 200,
|
|
154
|
-
headers: jsonHeaders(),
|
|
155
|
-
body: JSON.stringify(company),
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (pathname === 'configs' || pathname.startsWith('configs')) {
|
|
160
|
-
return route.fulfill({
|
|
161
|
-
status: 200,
|
|
162
|
-
headers: jsonHeaders(),
|
|
163
|
-
body: JSON.stringify(collection([])),
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (pathname === 'shop/franchises' || pathname.startsWith('shop/franchises')) {
|
|
168
|
-
return route.fulfill({
|
|
169
|
-
status: 200,
|
|
170
|
-
headers: jsonHeaders(),
|
|
171
|
-
body: JSON.stringify(collection([franchiseCompany])),
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (pathname === 'people_links' || pathname.startsWith('people_links')) {
|
|
176
|
-
return route.fulfill({
|
|
177
|
-
status: 200,
|
|
178
|
-
headers: jsonHeaders(),
|
|
179
|
-
body: JSON.stringify(
|
|
180
|
-
collection([
|
|
181
|
-
{
|
|
182
|
-
company: '/people/3',
|
|
183
|
-
people: franchiseCompany,
|
|
184
|
-
linkType: 'franchisee',
|
|
185
|
-
},
|
|
186
|
-
]),
|
|
187
|
-
),
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (pathname === 'categories' || pathname.startsWith('categories')) {
|
|
192
|
-
return route.fulfill({
|
|
193
|
-
status: 200,
|
|
194
|
-
headers: jsonHeaders(),
|
|
195
|
-
body: JSON.stringify(collection([])),
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (pathname === 'devices' || pathname.startsWith('devices')) {
|
|
200
|
-
return route.fulfill({
|
|
201
|
-
status: 200,
|
|
202
|
-
headers: jsonHeaders(),
|
|
203
|
-
body: JSON.stringify(
|
|
204
|
-
collection([
|
|
205
|
-
{
|
|
206
|
-
'@id': '/devices/1',
|
|
207
|
-
id: 1,
|
|
208
|
-
device: CURRENT_DEVICE_ID,
|
|
209
|
-
alias: 'Smoke Manager',
|
|
210
|
-
type: 'MANAGER',
|
|
211
|
-
},
|
|
212
|
-
]),
|
|
213
|
-
),
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (pathname === 'device_configs' || pathname.startsWith('device_configs')) {
|
|
218
|
-
return route.fulfill({
|
|
219
|
-
status: 200,
|
|
220
|
-
headers: jsonHeaders(),
|
|
221
|
-
body: JSON.stringify(
|
|
222
|
-
collection([
|
|
223
|
-
{
|
|
224
|
-
'@id': '/device_configs/1',
|
|
225
|
-
id: 1,
|
|
226
|
-
type: 'MANAGER',
|
|
227
|
-
people: '/people/3',
|
|
228
|
-
device: { id: 1, device: CURRENT_DEVICE_ID, alias: 'Smoke Manager' },
|
|
229
|
-
configs: JSON.stringify({ 'config-version': APP_VERSION }),
|
|
230
|
-
},
|
|
231
|
-
]),
|
|
232
|
-
),
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
return route.fulfill({
|
|
237
|
-
status: 200,
|
|
238
|
-
headers: jsonHeaders(),
|
|
239
|
-
body: JSON.stringify(collection([])),
|
|
240
|
-
});
|
|
32
|
+
const evidenceSteps = [];
|
|
33
|
+
|
|
34
|
+
const writeEvidence = async (page, outputDir, stepId, title) => {
|
|
35
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
36
|
+
const fileName = `${stepId}.png`;
|
|
37
|
+
const filePath = path.join(outputDir, fileName);
|
|
38
|
+
await page.screenshot({ path: filePath, fullPage: true });
|
|
39
|
+
evidenceSteps.push({
|
|
40
|
+
id: stepId,
|
|
41
|
+
title,
|
|
42
|
+
screenshot: fileName,
|
|
43
|
+
url: page.url(),
|
|
241
44
|
});
|
|
45
|
+
return filePath;
|
|
46
|
+
};
|
|
242
47
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
systemVersion: 'web',
|
|
271
|
-
deviceType: 'web',
|
|
272
|
-
metadata: { runtime: 'web' },
|
|
273
|
-
}),
|
|
274
|
-
);
|
|
275
|
-
},
|
|
276
|
-
{ appVersion: APP_VERSION },
|
|
48
|
+
const writeManifest = outputDir => {
|
|
49
|
+
const manifest = {
|
|
50
|
+
fluxo: FLOW_ID,
|
|
51
|
+
flowchartIds: FLOWCHART_IDS,
|
|
52
|
+
flowchartLinks: FLOWCHART_LINKS,
|
|
53
|
+
title: 'General Settings / Mapas: tela principal + localizador de franquias',
|
|
54
|
+
issue: 'ControleOnline/app-community#360',
|
|
55
|
+
steps: evidenceSteps,
|
|
56
|
+
};
|
|
57
|
+
fs.writeFileSync(
|
|
58
|
+
path.join(outputDir, 'manifest.json'),
|
|
59
|
+
`${JSON.stringify(manifest, null, 2)}\n`,
|
|
60
|
+
);
|
|
61
|
+
fs.writeFileSync(
|
|
62
|
+
path.join(outputDir, 'MANIFEST.md'),
|
|
63
|
+
[
|
|
64
|
+
`# ${manifest.title}`,
|
|
65
|
+
'',
|
|
66
|
+
`- fluxo: ${FLOW_ID}`,
|
|
67
|
+
`- flowchartIds: ${JSON.stringify(FLOWCHART_IDS)}`,
|
|
68
|
+
`- issue: ${manifest.issue}`,
|
|
69
|
+
'',
|
|
70
|
+
...evidenceSteps.map(
|
|
71
|
+
step => `- ${step.id}: ${step.title} (${step.screenshot})`,
|
|
72
|
+
),
|
|
73
|
+
'',
|
|
74
|
+
].join('\n'),
|
|
277
75
|
);
|
|
76
|
+
return manifest;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const seedApiSession = async page => {
|
|
80
|
+
const token = String(
|
|
81
|
+
process.env.SMOKE_API_TOKEN ||
|
|
82
|
+
process.env.SMOKE_ADMIN_API_TOKEN ||
|
|
83
|
+
process.env.API_TOKEN ||
|
|
84
|
+
'',
|
|
85
|
+
).trim();
|
|
86
|
+
if (!token) return false;
|
|
87
|
+
const peopleId = String(
|
|
88
|
+
process.env.SMOKE_ADMIN_PEOPLE_ID || process.env.ADMIN_PEOPLE_ID || '7',
|
|
89
|
+
).trim();
|
|
90
|
+
const userId = String(
|
|
91
|
+
process.env.SMOKE_ADMIN_USER_ID || process.env.ADMIN_USER_ID || peopleId,
|
|
92
|
+
).trim();
|
|
93
|
+
const session = {
|
|
94
|
+
id: Number(userId) || userId,
|
|
95
|
+
people: `/people/${peopleId}`,
|
|
96
|
+
api_key: token,
|
|
97
|
+
active: 1,
|
|
98
|
+
};
|
|
99
|
+
await page.addInitScript(payload => {
|
|
100
|
+
window.localStorage.setItem('session', JSON.stringify(payload));
|
|
101
|
+
}, session);
|
|
102
|
+
return true;
|
|
278
103
|
};
|
|
279
104
|
|
|
280
|
-
test.describe('general-settings maps (browser smoke #
|
|
105
|
+
test.describe('general-settings maps (browser smoke #360)', () => {
|
|
106
|
+
test.describe.configure({ timeout: 90000 });
|
|
107
|
+
|
|
281
108
|
test('MapsSection and ShopFranchiseLocator respect 500-line limit', async () => {
|
|
282
109
|
for (const file of MODULES_MAX_500) {
|
|
283
110
|
expect(fs.existsSync(file), `missing ${file}`).toBe(true);
|
|
284
111
|
const lines = fs.readFileSync(file, 'utf8').split(/\r?\n/).length;
|
|
285
|
-
expect(
|
|
286
|
-
|
|
287
|
-
|
|
112
|
+
expect(
|
|
113
|
+
lines,
|
|
114
|
+
`${path.basename(file)} has ${lines} lines (max 500)`,
|
|
115
|
+
).toBeLessThanOrEqual(500);
|
|
288
116
|
}
|
|
289
117
|
});
|
|
290
118
|
|
|
291
|
-
test('
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
expect(source).toMatch(/
|
|
295
|
-
expect(source).toMatch(/
|
|
119
|
+
test('MapsSection does not reference residual aba Shop', async () => {
|
|
120
|
+
const source = fs.readFileSync(MODULES_MAX_500[0], 'utf8');
|
|
121
|
+
expect(source).not.toMatch(/aba Shop/i);
|
|
122
|
+
expect(source).toMatch(/ShopFranchiseLocatorSection/);
|
|
123
|
+
expect(source).toMatch(/visibleFranchiseCompanyIds/);
|
|
124
|
+
expect(source).toMatch(/mapMarkers/);
|
|
296
125
|
});
|
|
297
126
|
|
|
298
|
-
test('open /general-settings → aba Mapas
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
127
|
+
test('open /general-settings → aba Mapas on live API', async ({
|
|
128
|
+
page,
|
|
129
|
+
}, testInfo) => {
|
|
130
|
+
testInfo.annotations.push({ type: 'fluxo', description: FLOW_ID });
|
|
131
|
+
testInfo.annotations.push({
|
|
132
|
+
type: 'flowchartIds',
|
|
133
|
+
description: JSON.stringify(FLOWCHART_IDS),
|
|
306
134
|
});
|
|
307
|
-
page.on("request", request => {
|
|
308
|
-
const url = new URL(request.url());
|
|
309
|
-
if (!/^https:\/\/(?:api|s)\.controleonline\.com\//.test(url.href)) return;
|
|
310
|
-
if (request.method().toUpperCase() === "OPTIONS") return;
|
|
311
|
-
const key = request.method().toUpperCase() + " " + url.pathname + url.search;
|
|
312
|
-
apiRequestCounts.set(key, (apiRequestCounts.get(key) || 0) + 1);
|
|
313
|
-
});
|
|
314
|
-
await mockGeneralSettingsApi(page);
|
|
315
135
|
|
|
136
|
+
const outputDir = path.join(
|
|
137
|
+
testInfo.outputDir,
|
|
138
|
+
'manual-qa',
|
|
139
|
+
'issue-360',
|
|
140
|
+
);
|
|
141
|
+
evidenceSteps.length = 0;
|
|
142
|
+
|
|
143
|
+
const seeded = await seedApiSession(page);
|
|
316
144
|
await page.goto('/general-settings');
|
|
317
|
-
await
|
|
145
|
+
await writeEvidence(page, outputDir, '01-general-settings-entry', 'Abrir /general-settings');
|
|
146
|
+
|
|
147
|
+
const loginVisible = await page
|
|
148
|
+
.getByPlaceholder('Email')
|
|
149
|
+
.isVisible()
|
|
150
|
+
.catch(() => false);
|
|
151
|
+
if (loginVisible && !seeded) {
|
|
152
|
+
await writeEvidence(page, outputDir, '01b-login-gate', 'Tela de login (sem SMOKE_API_TOKEN)');
|
|
153
|
+
writeManifest(outputDir);
|
|
154
|
+
test.info().annotations.push({
|
|
155
|
+
type: 'note',
|
|
156
|
+
description:
|
|
157
|
+
'SMOKE_API_TOKEN ausente; runner precisa credencial para ultrapassar o login',
|
|
158
|
+
});
|
|
159
|
+
}
|
|
318
160
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
await page.getByPlaceholder('Email').fill('smoke@example.com');
|
|
322
|
-
await page.getByPlaceholder('Senha').fill('smoke-password');
|
|
323
|
-
await page.getByText('Entrar', {exact: true}).click();
|
|
161
|
+
if (loginVisible && seeded) {
|
|
162
|
+
await page.reload();
|
|
324
163
|
}
|
|
325
164
|
|
|
326
|
-
|
|
327
|
-
await expect(
|
|
328
|
-
timeout: 20000,
|
|
329
|
-
});
|
|
165
|
+
const mapsHint = page.getByText(/Configurador geral|Mapas|Dispositivos/i).first();
|
|
166
|
+
await expect(mapsHint).toBeVisible({ timeout: 25000 });
|
|
330
167
|
|
|
331
|
-
// Activate Mapas tab (label or role)
|
|
332
168
|
const mapsTab = page.getByText('Mapas', { exact: true }).first();
|
|
333
|
-
await expect(mapsTab).toBeVisible({ timeout:
|
|
169
|
+
await expect(mapsTab).toBeVisible({ timeout: 20000 });
|
|
334
170
|
await mapsTab.click();
|
|
335
|
-
await
|
|
171
|
+
await writeEvidence(page, outputDir, '02-maps-tab', 'Aba Mapas aberta');
|
|
336
172
|
|
|
337
|
-
// Section title / labels
|
|
338
173
|
await expect(page.getByText('Tela principal do shop').first()).toBeVisible({
|
|
339
|
-
timeout:
|
|
174
|
+
timeout: 20000,
|
|
340
175
|
});
|
|
341
176
|
await expect(page.getByText('Localizador de franquias').first()).toBeVisible({
|
|
342
|
-
timeout:
|
|
177
|
+
timeout: 15000,
|
|
343
178
|
});
|
|
344
179
|
|
|
345
|
-
const locatorToggle = page.getByTestId('maps-franchise-locator-toggle');
|
|
346
|
-
if ((await locatorToggle.innerText()).includes('Desativado')) {
|
|
347
|
-
await locatorToggle.click();
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// Primary entry options when both toggles are on
|
|
351
180
|
const primaryOptions = page.getByTestId('maps-primary-entry-options');
|
|
352
|
-
await
|
|
181
|
+
if (await primaryOptions.count()) {
|
|
182
|
+
await expect(primaryOptions.first()).toBeVisible({ timeout: 10000 });
|
|
183
|
+
}
|
|
184
|
+
await writeEvidence(
|
|
185
|
+
page,
|
|
186
|
+
outputDir,
|
|
187
|
+
'03-maps-primary-entry',
|
|
188
|
+
'Seletor de tela principal / toggles',
|
|
189
|
+
);
|
|
353
190
|
|
|
354
|
-
|
|
355
|
-
await expect(
|
|
191
|
+
const locator = page.getByTestId('maps-franchise-locator');
|
|
192
|
+
await expect(locator).toBeVisible({ timeout: 20000 });
|
|
193
|
+
await expect(page.getByTestId('maps-franchise-map')).toBeVisible({
|
|
356
194
|
timeout: 10000,
|
|
357
195
|
});
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
await checkbox.click();
|
|
364
|
-
await expect(page.getByTestId('maps-franchise-map')).toBeVisible();
|
|
365
|
-
await captureEvidence(page, testInfo, '04-pins-checkbox-map', 'Checkbox de pin e mapa carregado', evidence);
|
|
366
|
-
|
|
367
|
-
const mapFrame = page.frameLocator('iframe[title="Mapa das franquias"]');
|
|
368
|
-
await expect(mapFrame.locator('.leaflet-marker-icon').first()).toBeVisible({
|
|
369
|
-
timeout: 15000,
|
|
370
|
-
});
|
|
371
|
-
await mapFrame.locator('.leaflet-marker-icon').first().evaluate(marker =>
|
|
372
|
-
marker.dispatchEvent(new MouseEvent('click', {bubbles: true})),
|
|
196
|
+
await writeEvidence(
|
|
197
|
+
page,
|
|
198
|
+
outputDir,
|
|
199
|
+
'04-maps-franchise-locator',
|
|
200
|
+
'Bloco localizador de franquias (API real)',
|
|
373
201
|
);
|
|
374
|
-
await expect(mapFrame.locator('.leaflet-popup').first()).toBeVisible({
|
|
375
|
-
timeout: 5000,
|
|
376
|
-
});
|
|
377
|
-
await captureEvidence(page, testInfo, '04b-pin-popup', 'Pin aberto com popup no mapa', evidence);
|
|
378
|
-
|
|
379
|
-
await page.setViewportSize({width: 480, height: 900});
|
|
380
|
-
await captureEvidence(page, testInfo, '05-responsive-resize', 'Viewport estreito após resize', evidence);
|
|
381
|
-
const scrollWidth = await page.evaluate(() => document.documentElement.scrollWidth);
|
|
382
|
-
const clientWidth = await page.evaluate(() => document.documentElement.clientWidth);
|
|
383
|
-
expect(scrollWidth).toBeLessThanOrEqual(clientWidth + 1);
|
|
384
202
|
|
|
385
|
-
await page.setViewportSize({width: 1280, height: 900});
|
|
386
|
-
await captureEvidence(page, testInfo, '06-desktop-final', 'Desktop final com mapa e pins', evidence);
|
|
387
|
-
const outputDir = path.join(testInfo.outputDir, 'manual-qa', 'issue-792');
|
|
388
|
-
fs.writeFileSync(path.join(outputDir, 'manifest.json'), JSON.stringify({wikiPage: 'https://github.com/ControleOnline/app-community/wiki/Smoke-Test-Flows', fluxo: 'outros', flowchartIds: [1], issue: 'ControleOnline/app-community#792', build: APP_VERSION, steps: evidence}, null, 2) + '\n'
|
|
389
|
-
);
|
|
390
|
-
|
|
391
|
-
// No residual guidance pointing to non-existent Shop tab
|
|
392
203
|
const bodyText = await page.locator('body').innerText();
|
|
393
204
|
expect(bodyText).not.toMatch(/permanece na aba Shop/i);
|
|
394
|
-
expect(bodyText).not.toMatch(
|
|
205
|
+
expect(bodyText).not.toMatch(
|
|
206
|
+
/Visibilidade detalhada por franquia\/endereço no mapa: aba Shop/i,
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
const lat = page.getByTestId('address-latitude-input');
|
|
210
|
+
const lon = page.getByTestId('address-longitude-input');
|
|
211
|
+
if ((await lat.count()) || (await lon.count())) {
|
|
212
|
+
await writeEvidence(
|
|
213
|
+
page,
|
|
214
|
+
outputDir,
|
|
215
|
+
'05-address-lat-long',
|
|
216
|
+
'Campos Latitude/Longitude visíveis',
|
|
217
|
+
);
|
|
218
|
+
}
|
|
395
219
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
expect(
|
|
220
|
+
const manifest = writeManifest(outputDir);
|
|
221
|
+
expect(manifest.fluxo).toBe(FLOW_ID);
|
|
222
|
+
expect(manifest.flowchartIds).toEqual(FLOWCHART_IDS);
|
|
223
|
+
expect(manifest.steps.length).toBeGreaterThanOrEqual(3);
|
|
224
|
+
expect(APP_VERSION).toBeTruthy();
|
|
399
225
|
});
|
|
400
226
|
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const {
|
|
2
|
+
normalizeLoyaltyCompanyId,
|
|
3
|
+
productBelongsToCompany,
|
|
4
|
+
filterProductsByCompany,
|
|
5
|
+
} = require('../../../../../react/pages/settings/sections/loyaltyProductCompany');
|
|
6
|
+
|
|
7
|
+
describe('loyaltyProductCompany', () => {
|
|
8
|
+
test('normalizes IRI, object and digits', () => {
|
|
9
|
+
expect(normalizeLoyaltyCompanyId('/people/42')).toBe('42');
|
|
10
|
+
expect(normalizeLoyaltyCompanyId({id: 7})).toBe('7');
|
|
11
|
+
expect(normalizeLoyaltyCompanyId({['@id']: '/people/9'})).toBe('9');
|
|
12
|
+
expect(normalizeLoyaltyCompanyId('')).toBe('');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('keeps products without company field when company is selected', () => {
|
|
16
|
+
expect(productBelongsToCompany({id: 1, product: 'X'}, 10)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('drops products owned by another company', () => {
|
|
20
|
+
expect(
|
|
21
|
+
productBelongsToCompany({id: 1, company: '/people/99'}, 10),
|
|
22
|
+
).toBe(false);
|
|
23
|
+
expect(
|
|
24
|
+
productBelongsToCompany({id: 2, company: {id: 10}}, '10'),
|
|
25
|
+
).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('filterProductsByCompany returns empty without company', () => {
|
|
29
|
+
expect(filterProductsByCompany([{id: 1}], '')).toEqual([]);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('filterProductsByCompany keeps only matching company', () => {
|
|
33
|
+
const items = [
|
|
34
|
+
{id: 1, company: 10},
|
|
35
|
+
{id: 2, company: 11},
|
|
36
|
+
{id: 3},
|
|
37
|
+
];
|
|
38
|
+
const filtered = filterProductsByCompany(items, 10);
|
|
39
|
+
expect(filtered.map(item => item.id)).toEqual([1, 3]);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const {describe, it} = require('node:test');
|
|
2
|
+
const assert = require('node:assert/strict');
|
|
3
|
+
|
|
4
|
+
describe('mapsSectionHelpers', () => {
|
|
5
|
+
it('parses coordinates and builds a static map URL', async () => {
|
|
6
|
+
const mod = await import(
|
|
7
|
+
'../../../../../react/pages/settings/sections/mapsSectionHelpers.js'
|
|
8
|
+
);
|
|
9
|
+
const {parseCoord, resolveAddressCoords, buildStaticMapUrl, PRIMARY_ENTRY_LABELS} =
|
|
10
|
+
mod;
|
|
11
|
+
|
|
12
|
+
assert.equal(parseCoord(''), null);
|
|
13
|
+
assert.equal(parseCoord(undefined), null);
|
|
14
|
+
assert.equal(parseCoord('0'), null);
|
|
15
|
+
assert.equal(parseCoord('-23.5614'), -23.5614);
|
|
16
|
+
|
|
17
|
+
assert.equal(resolveAddressCoords({latitude: 0, longitude: 0}), null);
|
|
18
|
+
assert.deepEqual(resolveAddressCoords({latitude: -23.56, longitude: -46.65}), {
|
|
19
|
+
lat: -23.56,
|
|
20
|
+
lng: -46.65,
|
|
21
|
+
});
|
|
22
|
+
assert.deepEqual(resolveAddressCoords({lat: -10.1, lon: -20.2}), {
|
|
23
|
+
lat: -10.1,
|
|
24
|
+
lng: -20.2,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
assert.equal(buildStaticMapUrl({apiKey: '', markers: [{lat: 1, lng: 2}]}), null);
|
|
28
|
+
const url = buildStaticMapUrl({
|
|
29
|
+
apiKey: 'abc',
|
|
30
|
+
markers: [{lat: -23.56, lng: -46.65}],
|
|
31
|
+
});
|
|
32
|
+
assert.ok(String(url).includes('maps.googleapis.com'));
|
|
33
|
+
assert.ok(String(url).includes('abc'));
|
|
34
|
+
|
|
35
|
+
assert.equal(typeof PRIMARY_ENTRY_LABELS, 'object');
|
|
36
|
+
assert.ok(Object.keys(PRIMARY_ENTRY_LABELS).length >= 2);
|
|
37
|
+
});
|
|
38
|
+
});
|