@controleonline/ui-crm 1.0.44 → 1.0.45

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.
Files changed (43) hide show
  1. package/.github/workflows/integration-source-gate.yml +1 -15
  2. package/.github/workflows/manager-worker.yml +155 -7
  3. package/.github/workflows/publish-npm.yml +22 -73
  4. package/AGENTS.md +0 -2
  5. package/package.json +2 -2
  6. package/src/react/pages/crm/hooks/useCrmData.js +17 -23
  7. package/src/react/pages/mcp/McpPage.js +301 -0
  8. package/src/react/pages/mcp/McpPage.styles.js +116 -0
  9. package/src/react/pages/proposals/CreateProposalsModal.js +0 -1
  10. package/src/react/pages/proposals/index.js +33 -14
  11. package/src/react/pages/settings/GeneralSettings.js +17 -9
  12. package/src/react/pages/settings/GeneralSettings.shared.js +20 -20
  13. package/src/react/pages/settings/GeneralSettings.styles.js +0 -2
  14. package/src/react/pages/settings/sections/AiProvidersSection.js +263 -0
  15. package/src/react/pages/settings/sections/DeviceRuntimeFooterSection.js +11 -11
  16. package/src/react/pages/settings/sections/IntegrationsSection.js +17 -17
  17. package/src/react/pages/settings/sections/LogSection.js +10 -10
  18. package/src/react/pages/settings/sections/LoginSection.js +13 -13
  19. package/src/react/pages/settings/sections/LoyaltyProductPicker.js +145 -58
  20. package/src/react/pages/settings/sections/LoyaltySection.js +9 -35
  21. package/src/react/pages/settings/sections/MaintenanceSection.js +16 -16
  22. package/src/react/pages/settings/sections/MapsSection.js +257 -81
  23. package/src/react/pages/settings/sections/ShopSection.js +2 -2
  24. package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +28 -7
  25. package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +8 -54
  26. package/src/react/pages/settings/sections/shop/shopSettingsShared.js +11 -32
  27. package/src/react/router/routes.js +14 -0
  28. package/src/react/utils/proposalProductSelection.js +13 -103
  29. package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +0 -25
  30. package/src/tests/browser/manager/general-settings-maps.spec.js +347 -173
  31. package/src/tests/react/utils/proposalProductSelection.test.js +1 -57
  32. package/src/react/pages/settings/sections/MapsFranchisePreview.js +0 -102
  33. package/src/react/pages/settings/sections/MapsMapasControls.js +0 -262
  34. package/src/react/pages/settings/sections/loyaltyProductCompany.js +0 -57
  35. package/src/react/pages/settings/sections/mapsSectionHelpers.js +0 -137
  36. package/src/react/utils/clientDetailsNavigation.js +0 -56
  37. package/src/react/utils/clientSellerVisibility.js +0 -60
  38. package/src/react/utils/proposalStatus.js +0 -160
  39. package/src/tests/react/pages/settings/sections/loyaltyProductCompany.test.js +0 -41
  40. package/src/tests/react/pages/settings/sections/mapsSectionHelpers.test.js +0 -38
  41. package/src/tests/react/utils/clientDetailsNavigation.test.js +0 -98
  42. package/src/tests/react/utils/clientSellerVisibility.test.js +0 -74
  43. package/src/tests/react/utils/proposalStatus.test.mjs +0 -77
@@ -1,226 +1,400 @@
1
1
  /**
2
- * fluxo: manager-general-settings-maps
2
+ * Smoke browser: Manager /general-settings → aba Mapas (#792).
3
+ * fluxo: outros | etapa: general-settings-maps
4
+ * wikiPage: https://github.com/ControleOnline/app-community/wiki/Smoke-Test-Flows
3
5
  * flowchartIds: [1]
4
- * app-community#360 — General Settings / Mapas (tela principal + localizador).
6
+ * Refs: app-community#792
5
7
  *
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.
8
+ * Criteria:
9
+ * - Aba Mapas visível com seletor de tela principal (quando opções ativas)
10
+ * - Lista/secao de franquias/endereços presente na aba Mapas (sem apontar aba Shop)
11
+ * - Helper de lat/long e seção de mapa sem mensagem residual "aba Shop"
12
+ * - Módulos de settings ≤ 500 linhas
11
13
  */
14
+ const { expect, test } = require('playwright/test');
12
15
  const fs = require('fs');
13
16
  const path = require('path');
14
- const { expect, test } = require('playwright/test');
15
17
  const packageJson = require('../../../../../../../package.json');
18
+ const { API_ORIGIN } = require('../../../../../../../src/tests/browser/apiOrigin');
16
19
 
17
20
  const APP_VERSION = packageJson?.version || '1.0.0';
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
- );
21
+ const CURRENT_DEVICE_ID = 'web-7';
23
22
 
24
- const MODULES_MAX_500 = [
25
- path.join(__dirname, '../../../react/pages/settings/sections/MapsSection.js'),
26
- path.join(
27
- __dirname,
28
- '../../../react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js',
29
- ),
30
- ];
23
+ const captureEvidence = async (page, testInfo, stepId, title, steps) => {
24
+ const outputDir = path.join(testInfo.outputDir, 'manual-qa', 'issue-792');
25
+ fs.mkdirSync(outputDir, {recursive: true});
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
+ };
31
30
 
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(),
44
- });
45
- return filePath;
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',
46
36
  };
47
37
 
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'),
75
- );
76
- return manifest;
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
+ },
77
65
  };
78
66
 
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;
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
+ ],
103
85
  };
104
86
 
105
- test.describe('general-settings maps (browser smoke #360)', () => {
106
- test.describe.configure({ timeout: 90000 });
87
+ const MODULES_MAX_500 = [
88
+ path.join(__dirname, '../../../react/pages/settings/sections/shop/FranchiseMapPreview.js'),
89
+ path.join(__dirname, '../../../react/pages/settings/sections/shop/mapsFranchiseMapHelpers.js'),
90
+ ];
91
+
92
+ const mockGeneralSettingsApi = async page => {
93
+ await page.route(/https:\/\/(?:api|s)\.controleonline\.com\/.*/, async route => {
94
+ const request = route.request();
95
+ const url = new URL(request.url());
96
+ const pathname = url.pathname.replace(/^\/+/, '');
97
+ const method = request.method().toUpperCase();
98
+
99
+ if (method === 'OPTIONS') {
100
+ return route.fulfill({ status: 204, headers: CORS_HEADERS, body: '' });
101
+ }
102
+
103
+ if (pathname === 'themes-colors.css') {
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
+ }
107
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
+ });
241
+ });
242
+
243
+ await page.addInitScript(
244
+ ({ appVersion }) => {
245
+ localStorage.setItem('token', 'smoke-token-360');
246
+ // CheckLogin restores authentication from the session object on web.
247
+ localStorage.setItem(
248
+ 'session',
249
+ JSON.stringify({
250
+ id: 360,
251
+ active: 1,
252
+ type: 'MANAGER',
253
+ people: 3,
254
+ api_key: 'smoke-token-360',
255
+ name: 'Manager Smoke',
256
+ }),
257
+ );
258
+ localStorage.setItem('app-type', 'MANAGER');
259
+ localStorage.setItem('config', JSON.stringify({ language: 'pt-br' }));
260
+ localStorage.setItem(
261
+ 'device',
262
+ JSON.stringify({
263
+ id: CURRENT_DEVICE_ID,
264
+ device: CURRENT_DEVICE_ID,
265
+ type: 'MANAGER',
266
+ appName: 'Browser Manager',
267
+ appVersion,
268
+ buildNumber: appVersion,
269
+ systemName: 'web',
270
+ systemVersion: 'web',
271
+ deviceType: 'web',
272
+ metadata: { runtime: 'web' },
273
+ }),
274
+ );
275
+ },
276
+ { appVersion: APP_VERSION },
277
+ );
278
+ };
279
+
280
+ test.describe('general-settings maps (browser smoke #792)', () => {
108
281
  test('MapsSection and ShopFranchiseLocator respect 500-line limit', async () => {
109
282
  for (const file of MODULES_MAX_500) {
110
283
  expect(fs.existsSync(file), `missing ${file}`).toBe(true);
111
284
  const lines = fs.readFileSync(file, 'utf8').split(/\r?\n/).length;
112
- expect(
113
- lines,
114
- `${path.basename(file)} has ${lines} lines (max 500)`,
115
- ).toBeLessThanOrEqual(500);
285
+ expect(lines, `${path.basename(file)} has ${lines} lines (max 500)`).toBeLessThanOrEqual(
286
+ 500,
287
+ );
116
288
  }
117
289
  });
118
290
 
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/);
291
+ test('Map preview keeps the safe Leaflet helper', async () => {
292
+ const mapsPath = MODULES_MAX_500[0];
293
+ const source = fs.readFileSync(mapsPath, 'utf8');
294
+ expect(source).toMatch(/buildLeafletMapHtml/);
295
+ expect(source).toMatch(/srcDoc/);
125
296
  });
126
297
 
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),
298
+ test('open /general-settings → aba Mapas shows primary entry + franchise locator', async ({page}, testInfo) => {
299
+ const evidence = [];
300
+ const consoleIssues = [];
301
+ const apiRequestCounts = new Map();
302
+ page.on("console", message => {
303
+ if (message.type() === "error" || message.type() === "warning") {
304
+ consoleIssues.push(message.type() + ": " + message.text());
305
+ }
134
306
  });
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);
135
315
 
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);
144
316
  await page.goto('/general-settings');
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
- }
317
+ await captureEvidence(page, testInfo, '01-general-settings-entry', 'Tela inicial de General Settings', evidence);
160
318
 
161
- if (loginVisible && seeded) {
162
- await page.reload();
319
+ // Keep the smoke self-contained if the app rejects the synthetic session.
320
+ if (await page.getByPlaceholder('Email').isVisible().catch(() => false)) {
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();
163
324
  }
164
325
 
165
- const mapsHint = page.getByText(/Configurador geral|Mapas|Dispositivos/i).first();
166
- await expect(mapsHint).toBeVisible({ timeout: 25000 });
326
+ // Wait for settings shell
327
+ await expect(page.getByText(/Configurador geral|Mapas|Dispositivos/i).first()).toBeVisible({
328
+ timeout: 20000,
329
+ });
167
330
 
331
+ // Activate Mapas tab (label or role)
168
332
  const mapsTab = page.getByText('Mapas', { exact: true }).first();
169
- await expect(mapsTab).toBeVisible({ timeout: 20000 });
333
+ await expect(mapsTab).toBeVisible({ timeout: 15000 });
170
334
  await mapsTab.click();
171
- await writeEvidence(page, outputDir, '02-maps-tab', 'Aba Mapas aberta');
335
+ await captureEvidence(page, testInfo, '02-mapas-tab', 'Aba MAPAS aberta', evidence);
172
336
 
337
+ // Section title / labels
173
338
  await expect(page.getByText('Tela principal do shop').first()).toBeVisible({
174
- timeout: 20000,
339
+ timeout: 15000,
175
340
  });
176
341
  await expect(page.getByText('Localizador de franquias').first()).toBeVisible({
177
- timeout: 15000,
342
+ timeout: 10000,
178
343
  });
179
344
 
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
180
351
  const primaryOptions = page.getByTestId('maps-primary-entry-options');
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
- );
352
+ await expect(primaryOptions).toBeVisible({ timeout: 10000 });
190
353
 
191
- const locator = page.getByTestId('maps-franchise-locator');
192
- await expect(locator).toBeVisible({ timeout: 20000 });
193
- await expect(page.getByTestId('maps-franchise-map')).toBeVisible({
354
+ // Franchise locator block on the Maps tab itself
355
+ await expect(page.getByTestId('maps-franchise-locator')).toBeVisible({
194
356
  timeout: 10000,
195
357
  });
196
- await writeEvidence(
197
- page,
198
- outputDir,
199
- '04-maps-franchise-locator',
200
- 'Bloco localizador de franquias (API real)',
358
+
359
+ await captureEvidence(page, testInfo, '03-franchise-list', 'Lista de franquias e toggle visíveis', evidence);
360
+
361
+ const checkbox = page.getByLabel(/Exibir FRANQUIA no mapa/);
362
+ await expect(checkbox).toBeVisible();
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})),
201
373
  );
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);
202
384
 
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
203
392
  const bodyText = await page.locator('body').innerText();
204
393
  expect(bodyText).not.toMatch(/permanece na aba Shop/i);
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
- }
394
+ expect(bodyText).not.toMatch(/Visibilidade detalhada por franquia\/endereço no mapa: aba Shop/i);
219
395
 
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();
396
+ expect(consoleIssues, "browser console issues: " + consoleIssues.join("\n")).toEqual([]);
397
+ const duplicateRequests = [...apiRequestCounts.entries()].filter(([, count]) => count > 1);
398
+ expect(duplicateRequests, "duplicate API requests: " + JSON.stringify(duplicateRequests)).toEqual([]);
225
399
  });
226
400
  });
@@ -2,13 +2,11 @@ const test = require('node:test');
2
2
  const assert = require('node:assert/strict');
3
3
 
4
4
  const {
5
- collectProductCategoryIds,
6
5
  filterProductsByModelCategory,
7
6
  getProposalModelCategoryId,
8
7
  getProposalModelCategoryName,
9
8
  keepCompatibleSelectedProducts,
10
9
  normalizeCategoryId,
11
- productMatchesModelCategory,
12
10
  } = require('../../../react/utils/proposalProductSelection');
13
11
 
14
12
  test('normalizeCategoryId resolves nested category references', () => {
@@ -34,19 +32,7 @@ test('getProposalModelCategoryName returns human label when present', () => {
34
32
  assert.equal(getProposalModelCategoryName({ category: {} }), '');
35
33
  });
36
34
 
37
- test('collectProductCategoryIds reads productCategory join collection', () => {
38
- const product = {
39
- '@id': '/products/1',
40
- productCategory: [
41
- { category: { '@id': '/categories/4' } },
42
- { category: '/categories/9' },
43
- ],
44
- };
45
-
46
- assert.deepEqual([...collectProductCategoryIds(product)].sort(), ['4', '9']);
47
- });
48
-
49
- test('filterProductsByModelCategory keeps matching products via product.category', () => {
35
+ test('filterProductsByModelCategory keeps only matching products when a category is selected', () => {
50
36
  const products = [
51
37
  { '@id': '/products/1', category: { '@id': '/categories/4' } },
52
38
  { '@id': '/products/2', category: { '@id': '/categories/7' } },
@@ -62,40 +48,6 @@ test('filterProductsByModelCategory keeps matching products via product.category
62
48
  );
63
49
  });
64
50
 
65
- test('filterProductsByModelCategory keeps matching products via productCategory join', () => {
66
- const products = [
67
- {
68
- '@id': '/products/10',
69
- productCategory: [{ category: { '@id': '/categories/4', name: 'Serviços' } }],
70
- },
71
- {
72
- '@id': '/products/11',
73
- productCategory: [{ category: { '@id': '/categories/8' } }],
74
- },
75
- ];
76
-
77
- assert.deepEqual(
78
- filterProductsByModelCategory({
79
- products,
80
- selectedModelCategoryId: '4',
81
- }),
82
- [products[0]],
83
- );
84
- });
85
-
86
- test('filterProductsByModelCategory keeps sparse products when categories are not embedded', () => {
87
- // product:read often omits productCategory; API filter is the source of truth.
88
- const products = [{ '@id': '/products/1' }, { '@id': '/products/2' }];
89
-
90
- assert.deepEqual(
91
- filterProductsByModelCategory({
92
- products,
93
- selectedModelCategoryId: '4',
94
- }),
95
- products,
96
- );
97
- });
98
-
99
51
  test('filterProductsByModelCategory preserves the original list when the model has no category', () => {
100
52
  const products = [{ '@id': '/products/1' }, { '@id': '/products/2' }];
101
53
 
@@ -122,11 +74,3 @@ test('keepCompatibleSelectedProducts drops selections outside the model category
122
74
  [selectedProducts[0]],
123
75
  );
124
76
  });
125
-
126
- test('productMatchesModelCategory accepts join-based membership', () => {
127
- const product = {
128
- productCategory: [{ category: '/categories/15' }],
129
- };
130
- assert.equal(productMatchesModelCategory(product, '15'), true);
131
- assert.equal(productMatchesModelCategory(product, '99'), false);
132
- });