@controleonline/ui-crm 1.0.42

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 (141) hide show
  1. package/.github/actions/workers/manager/action.yml +147 -0
  2. package/.github/actions/workers/qa/action.yml +44 -0
  3. package/.github/actions/workers/security/action.yml +44 -0
  4. package/.github/actions/workers/technical-documenter/action.yml +51 -0
  5. package/.github/workflows/manager-worker.yml +167 -0
  6. package/.github/workflows/publish-npm.yml +40 -0
  7. package/.github/workflows/pull-request-checks.yml +29 -0
  8. package/.scrutinizer.yml +24 -0
  9. package/AGENTS.md +56 -0
  10. package/FUNDING.yml +1 -0
  11. package/docs/technical/Cliente-Vendedor-Vinculo-e-Permissoes.md +121 -0
  12. package/docs/technical/Income-Statements-Demonstrativo.md +38 -0
  13. package/docs/technical/Oportunidades-Ordenacao-por-Data-de-Retorno.md +134 -0
  14. package/docs/technical/Propostas-Filtro-de-Status.md +147 -0
  15. package/docs/technical/Royalties-a-pagar-Franqueado.md +51 -0
  16. package/docs/technical/Visao-Vendedor-Comissoes.md +58 -0
  17. package/docs/wiki.md +1 -0
  18. package/package.json +43 -0
  19. package/scripts/validate-wiki-pointer.cjs +13 -0
  20. package/src/react/components/AnimatedModal.js +149 -0
  21. package/src/react/components/AnimatedModal.styles.js +21 -0
  22. package/src/react/components/CreateContractModal.js +151 -0
  23. package/src/react/components/CreateContractModal.styles.js +43 -0
  24. package/src/react/hooks/useToastMessage.js +59 -0
  25. package/src/react/index.js +4 -0
  26. package/src/react/pages/ModelTemplatesPage.js +1461 -0
  27. package/src/react/pages/ModelTemplatesPage.styles.js +441 -0
  28. package/src/react/pages/comissions/IncomeStatementDetailsModal.js +102 -0
  29. package/src/react/pages/comissions/IncomeStatementsFilters.js +120 -0
  30. package/src/react/pages/comissions/SellerCommissionsPage.js +368 -0
  31. package/src/react/pages/comissions/SellerCommissionsPage.styles.js +219 -0
  32. package/src/react/pages/comissions/incomeStatementsHelpers.js +233 -0
  33. package/src/react/pages/comissions/index.js +309 -0
  34. package/src/react/pages/comissions/index.styles.js +381 -0
  35. package/src/react/pages/comissions/sellerCommissionsHelpers.js +222 -0
  36. package/src/react/pages/crm/components/CrmHeader.js +117 -0
  37. package/src/react/pages/crm/components/MarketingEventsSection.js +142 -0
  38. package/src/react/pages/crm/components/MarketingEventsSection.styles.js +105 -0
  39. package/src/react/pages/crm/components/OpportunityCard.js +138 -0
  40. package/src/react/pages/crm/components/OpportunityFormModal.js +279 -0
  41. package/src/react/pages/crm/components/OpportunityList.js +113 -0
  42. package/src/react/pages/crm/components/OpportunitySkeletons.js +53 -0
  43. package/src/react/pages/crm/components/ProviderSelectModal.js +166 -0
  44. package/src/react/pages/crm/components/SelectModal.js +178 -0
  45. package/src/react/pages/crm/conversation.js +342 -0
  46. package/src/react/pages/crm/conversation.styles.js +206 -0
  47. package/src/react/pages/crm/hooks/useCrmData.js +494 -0
  48. package/src/react/pages/crm/hooks/useOpportunityForms.js +306 -0
  49. package/src/react/pages/crm/index.js +262 -0
  50. package/src/react/pages/crm/index.styles.js +13 -0
  51. package/src/react/pages/crm/marketingEventsHelpers.js +41 -0
  52. package/src/react/pages/crm/styles/card.styles.js +178 -0
  53. package/src/react/pages/crm/styles/layout.styles.js +184 -0
  54. package/src/react/pages/crm/styles/modal.styles.js +347 -0
  55. package/src/react/pages/home/index.js +559 -0
  56. package/src/react/pages/home/index.styles.js +268 -0
  57. package/src/react/pages/proposals/CreateProposalsModal.js +466 -0
  58. package/src/react/pages/proposals/CreateProposalsModal.styles.js +344 -0
  59. package/src/react/pages/proposals/CreateProposalsPickers.js +187 -0
  60. package/src/react/pages/proposals/CreateProposalsProductSection.js +117 -0
  61. package/src/react/pages/proposals/ProposalCard.js +112 -0
  62. package/src/react/pages/proposals/ProposalDetails.js +263 -0
  63. package/src/react/pages/proposals/ProposalDetails.styles.js +195 -0
  64. package/src/react/pages/proposals/index.js +488 -0
  65. package/src/react/pages/proposals/index.styles.js +248 -0
  66. package/src/react/pages/proposals/proposalListHelpers.js +216 -0
  67. package/src/react/pages/proposals/proposalNavigation.js +26 -0
  68. package/src/react/pages/royalties/ReceivablePage.js +233 -0
  69. package/src/react/pages/royalties/RoyaltiesPayablePage.js +260 -0
  70. package/src/react/pages/royalties/index.js +2 -0
  71. package/src/react/pages/royalties/royaltiesReceivableHelpers.js +68 -0
  72. package/src/react/pages/settings/GeneralSettings.js +317 -0
  73. package/src/react/pages/settings/GeneralSettings.shared.js +490 -0
  74. package/src/react/pages/settings/GeneralSettings.styles.js +746 -0
  75. package/src/react/pages/settings/GeneralSettingsSection.js +57 -0
  76. package/src/react/pages/settings/generalSettingsActiveTab.js +85 -0
  77. package/src/react/pages/settings/sections/CrmSection.js +281 -0
  78. package/src/react/pages/settings/sections/DeviceRuntimeFooterSection.js +128 -0
  79. package/src/react/pages/settings/sections/DisplayPreparationSection.js +155 -0
  80. package/src/react/pages/settings/sections/IntegrationsSection.js +392 -0
  81. package/src/react/pages/settings/sections/LogSection.js +322 -0
  82. package/src/react/pages/settings/sections/LoginSection.js +137 -0
  83. package/src/react/pages/settings/sections/LoyaltyProductPicker.js +230 -0
  84. package/src/react/pages/settings/sections/LoyaltySection.js +451 -0
  85. package/src/react/pages/settings/sections/MaintenanceSection.js +205 -0
  86. package/src/react/pages/settings/sections/MapsSection.js +629 -0
  87. package/src/react/pages/settings/sections/MenuCatalogSection.js +405 -0
  88. package/src/react/pages/settings/sections/OperationsSection.js +303 -0
  89. package/src/react/pages/settings/sections/OrderPaymentSection.js +379 -0
  90. package/src/react/pages/settings/sections/OrderPrintSection.js +308 -0
  91. package/src/react/pages/settings/sections/ShopSection.js +490 -0
  92. package/src/react/pages/settings/sections/shop/FranchiseMapPreview.js +124 -0
  93. package/src/react/pages/settings/sections/shop/ShopDomainCreateForm.js +57 -0
  94. package/src/react/pages/settings/sections/shop/ShopDomainPanel.js +184 -0
  95. package/src/react/pages/settings/sections/shop/ShopDomainShowcasesSection.js +237 -0
  96. package/src/react/pages/settings/sections/shop/ShopDomainShowcasesSection.styles.js +256 -0
  97. package/src/react/pages/settings/sections/shop/ShopDomainTabs.js +61 -0
  98. package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +526 -0
  99. package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +426 -0
  100. package/src/react/pages/settings/sections/shop/ShopSettingsSection.js +10 -0
  101. package/src/react/pages/settings/sections/shop/mapsFranchiseMapHelpers.js +163 -0
  102. package/src/react/pages/settings/sections/shop/shopDomainShowcasesUtils.js +68 -0
  103. package/src/react/pages/settings/sections/shop/shopFranchiseVisibility.js +158 -0
  104. package/src/react/pages/settings/sections/shop/shopSettingsShared.js +427 -0
  105. package/src/react/router/routes.js +135 -0
  106. package/src/react/utils/opportunityDate.js +82 -0
  107. package/src/react/utils/opportunityEditorReferences.js +76 -0
  108. package/src/react/utils/opportunityEmptyState.js +20 -0
  109. package/src/react/utils/opportunityPeople.js +111 -0
  110. package/src/react/utils/opportunityPhone.js +82 -0
  111. package/src/react/utils/opportunityStage.js +30 -0
  112. package/src/react/utils/opportunityStatusFilter.js +54 -0
  113. package/src/react/utils/proposalCreateHelpers.js +61 -0
  114. package/src/react/utils/proposalProductSelection.js +71 -0
  115. package/src/react/utils/royaltiesPayableParams.js +37 -0
  116. package/src/react/utils/translateWithFallback.js +42 -0
  117. package/src/store/crm/index.js +2 -0
  118. package/src/store/model/index.js +104 -0
  119. package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +149 -0
  120. package/src/tests/browser/crm/crm-index-status-filter.spec.js +263 -0
  121. package/src/tests/browser/crm/crm-opportunity-category-editor.spec.js +269 -0
  122. package/src/tests/browser/crm/royalties-payable.spec.js +122 -0
  123. package/src/tests/browser/crm/royalties-receivable.spec.js +121 -0
  124. package/src/tests/browser/crm/seller-commissions.spec.js +214 -0
  125. package/src/tests/browser/manager/general-settings-maps.spec.js +400 -0
  126. package/src/tests/react/pages/comissions/incomeStatementsHelpers.test.js +181 -0
  127. package/src/tests/react/pages/comissions/sellerCommissionsHelpers.test.js +132 -0
  128. package/src/tests/react/pages/crm/marketingEventsHelpers.test.cjs +53 -0
  129. package/src/tests/react/pages/crm/opportunitySearchParams.test.cjs +44 -0
  130. package/src/tests/react/pages/proposals/navigation.test.js +71 -0
  131. package/src/tests/react/pages/proposals/proposalListHelpers.test.js +42 -0
  132. package/src/tests/react/pages/royalties/royaltiesReceivableHelpers.test.js +60 -0
  133. package/src/tests/react/pages/settings/generalSettings.shared.test.js +102 -0
  134. package/src/tests/react/pages/settings/sections/shop/shopDomainShowcasesUtils.test.js +60 -0
  135. package/src/tests/react/pages/settings/sections/shop/shopFranchiseVisibility.test.js +80 -0
  136. package/src/tests/react/utils/opportunityEditorReferences.test.js +70 -0
  137. package/src/tests/react/utils/opportunityEmptyState.test.js +39 -0
  138. package/src/tests/react/utils/opportunityStatusFilter.test.cjs +81 -0
  139. package/src/tests/react/utils/proposalCreateHelpers.test.js +25 -0
  140. package/src/tests/react/utils/proposalProductSelection.test.js +76 -0
  141. package/src/tests/react/utils/royaltiesPayableParams.test.js +44 -0
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Smoke: Visão Vendedor — Minhas comissões (invoice tipo comission).
3
+ * Runs inside app-community browser harness (playwright + API mock).
4
+ * Acceptance: route SellerCommissionsPage loads under seller context,
5
+ * year/month/client filters and empty/list states with testIDs are exercised.
6
+ */
7
+ const {expect, test} = require('playwright/test');
8
+ const path = require('path');
9
+
10
+ // Relative to modules/controleonline/ui-crm/src/tests/browser/crm/ → app-community root
11
+ const APP_ROOT = path.resolve(__dirname, '../../../../../../..');
12
+ let packageJson = {};
13
+ let API_ORIGIN = '';
14
+ try {
15
+ packageJson = require(path.join(APP_ROOT, 'package.json'));
16
+ } catch {
17
+ packageJson = {version: '1.0.0'};
18
+ }
19
+ try {
20
+ ({API_ORIGIN} = require(path.join(APP_ROOT, 'src/tests/browser/apiOrigin.js')));
21
+ } catch {
22
+ API_ORIGIN = process.env.API_ENTRYPOINT || 'https://api.controleonline.com';
23
+ }
24
+
25
+ const APP_VERSION = packageJson?.version || '1.0.0';
26
+
27
+ const CORS_HEADERS = {
28
+ 'access-control-allow-origin': '*',
29
+ 'access-control-allow-headers':
30
+ 'API-TOKEN, APP-DOMAIN, DEVICE, ACCEPT, CONTENT-TYPE, X-Requested-With',
31
+ 'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',
32
+ };
33
+
34
+ const jsonHeaders = () => ({
35
+ ...CORS_HEADERS,
36
+ 'content-type': 'application/ld+json; charset=utf-8',
37
+ });
38
+
39
+ const collection = member => ({
40
+ member,
41
+ 'hydra:member': member,
42
+ totalItems: member.length,
43
+ 'hydra:totalItems': member.length,
44
+ });
45
+
46
+ const company = {
47
+ id: 3,
48
+ name: 'Empresa Demo',
49
+ alias: 'DEMO',
50
+ panel_enabled: true,
51
+ enabled: true,
52
+ commercial_enabled: true,
53
+ theme: {colors: {primary: '#0EA5E9'}},
54
+ };
55
+
56
+ const sellerPeopleId = 42;
57
+ const sampleComissions = [
58
+ {
59
+ id: 501,
60
+ price: 150,
61
+ invoiceType: 'comission',
62
+ dueDate: '2026-03-15T12:00:00Z',
63
+ order: [{order: {client: {id: 11, name: 'Cliente Demo'}}}],
64
+ },
65
+ {
66
+ id: 502,
67
+ price: 80,
68
+ invoiceType: 'comission',
69
+ dueDate: '2026-03-20T12:00:00Z',
70
+ order: [{order: {client: {id: 12, name: 'Cliente Beta'}}}],
71
+ },
72
+ ];
73
+
74
+ const mockSellerCommissionsApi = async page => {
75
+ await page.route(`${API_ORIGIN}/**`, async route => {
76
+ const request = route.request();
77
+ const url = new URL(request.url());
78
+ const pathname = url.pathname.replace(/^\/+/, '');
79
+ const method = request.method().toUpperCase();
80
+
81
+ if (method === 'OPTIONS') {
82
+ return route.fulfill({status: 204, headers: CORS_HEADERS, body: ''});
83
+ }
84
+
85
+ if (
86
+ pathname === 'companies' ||
87
+ pathname.startsWith('people/') ||
88
+ pathname === 'people'
89
+ ) {
90
+ return route.fulfill({
91
+ status: 200,
92
+ headers: jsonHeaders(),
93
+ body: JSON.stringify(company),
94
+ });
95
+ }
96
+
97
+ if (pathname === 'finance/comission' || pathname.startsWith('finance/comission')) {
98
+ return route.fulfill({
99
+ status: 200,
100
+ headers: jsonHeaders(),
101
+ body: JSON.stringify(collection(sampleComissions)),
102
+ });
103
+ }
104
+
105
+ if (pathname === 'invoices' || pathname.startsWith('invoices')) {
106
+ return route.fulfill({
107
+ status: 200,
108
+ headers: jsonHeaders(),
109
+ body: JSON.stringify(collection(sampleComissions)),
110
+ });
111
+ }
112
+
113
+ // Default empty collection for other endpoints
114
+ return route.fulfill({
115
+ status: 200,
116
+ headers: jsonHeaders(),
117
+ body: JSON.stringify(collection([])),
118
+ });
119
+ });
120
+
121
+ await page.addInitScript(
122
+ ({appVersion, peopleId}) => {
123
+ const set = (k, v) => {
124
+ try {
125
+ localStorage.setItem(k, v);
126
+ } catch {}
127
+ };
128
+ set(
129
+ 'session',
130
+ JSON.stringify({
131
+ id: 7,
132
+ people: `/people/${peopleId}`,
133
+ people_id: peopleId,
134
+ api_key: 'test-api-key',
135
+ active: 1,
136
+ mycompany: 3,
137
+ roles: ['ROLE_SALESMAN', 'ROLE_ADMIN'],
138
+ }),
139
+ );
140
+ set('config', JSON.stringify({language: 'pt-br'}));
141
+ set('app-type', 'ERP');
142
+ set(
143
+ 'device',
144
+ JSON.stringify({
145
+ id: 'web-erp',
146
+ device: 'web-erp',
147
+ type: 'WEB',
148
+ appName: 'Browser ERP',
149
+ appVersion,
150
+ buildNumber: appVersion,
151
+ systemName: 'web',
152
+ systemVersion: 'web',
153
+ deviceType: 'web',
154
+ metadata: {},
155
+ }),
156
+ );
157
+ },
158
+ {appVersion: APP_VERSION, peopleId: sellerPeopleId},
159
+ );
160
+ };
161
+
162
+ test.describe('Seller commissions (comission) — visão vendedor', () => {
163
+ test('loads Minhas comissões, exercises year/month/client filters and list state', async ({
164
+ page,
165
+ }) => {
166
+ await mockSellerCommissionsApi(page);
167
+
168
+ // Primary path used by skeleton and route name SellerCommissionsPage
169
+ await page.goto('/seller-commissions');
170
+
171
+ // Page root testID must be present (acceptance)
172
+ await expect(page.getByTestId('seller-commissions-page')).toBeVisible({
173
+ timeout: 20000,
174
+ });
175
+
176
+ // Year controls
177
+ await expect(page.getByTestId('seller-commissions-year-input')).toBeVisible({
178
+ timeout: 10000,
179
+ });
180
+ const yearDec = page.getByTestId('seller-commissions-year-dec');
181
+ const yearInc = page.getByTestId('seller-commissions-year-inc');
182
+ await expect(yearDec).toBeVisible();
183
+ await expect(yearInc).toBeVisible();
184
+
185
+ // Month chips (at least "Todos" / id 0 and one month)
186
+ await expect(page.getByTestId('seller-commissions-month-chip-0')).toBeVisible({
187
+ timeout: 8000,
188
+ });
189
+ // Click a specific month to exercise filter
190
+ const marchChip = page.getByTestId('seller-commissions-month-chip-3');
191
+ if (await marchChip.isVisible().catch(() => false)) {
192
+ await marchChip.click();
193
+ }
194
+
195
+ // Client chips (all + derived from sample data)
196
+ await expect(
197
+ page.getByTestId('seller-commissions-client-chip-all'),
198
+ ).toBeVisible({timeout: 8000});
199
+
200
+ // List or empty state must resolve
201
+ const list = page.getByTestId('seller-commissions-list');
202
+ const empty = page.getByTestId('seller-commissions-empty');
203
+ await expect(list.or(empty).first()).toBeVisible({timeout: 15000});
204
+
205
+ // Prefer list with sample data
206
+ if (await list.isVisible().catch(() => false)) {
207
+ await expect(page.getByTestId('seller-commission-month-2026-03')).toBeVisible({
208
+ timeout: 8000,
209
+ }).catch(() => {
210
+ // month key format may vary; presence of list is enough
211
+ });
212
+ }
213
+ });
214
+ });
@@ -0,0 +1,400 @@
1
+ /**
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
5
+ * flowchartIds: [1]
6
+ * Refs: app-community#792
7
+ *
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
13
+ */
14
+ const { expect, test } = require('playwright/test');
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+ const packageJson = require('../../../../../../../package.json');
18
+ const { API_ORIGIN } = require('../../../../../../../src/tests/browser/apiOrigin');
19
+
20
+ const APP_VERSION = packageJson?.version || '1.0.0';
21
+ const CURRENT_DEVICE_ID = 'web-7';
22
+
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
+ };
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
+ };
86
+
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
+ }
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)', () => {
281
+ test('MapsSection and ShopFranchiseLocator respect 500-line limit', async () => {
282
+ for (const file of MODULES_MAX_500) {
283
+ expect(fs.existsSync(file), `missing ${file}`).toBe(true);
284
+ const lines = fs.readFileSync(file, 'utf8').split(/\r?\n/).length;
285
+ expect(lines, `${path.basename(file)} has ${lines} lines (max 500)`).toBeLessThanOrEqual(
286
+ 500,
287
+ );
288
+ }
289
+ });
290
+
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/);
296
+ });
297
+
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
+ }
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);
315
+
316
+ await page.goto('/general-settings');
317
+ await captureEvidence(page, testInfo, '01-general-settings-entry', 'Tela inicial de General Settings', evidence);
318
+
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();
324
+ }
325
+
326
+ // Wait for settings shell
327
+ await expect(page.getByText(/Configurador geral|Mapas|Dispositivos/i).first()).toBeVisible({
328
+ timeout: 20000,
329
+ });
330
+
331
+ // Activate Mapas tab (label or role)
332
+ const mapsTab = page.getByText('Mapas', { exact: true }).first();
333
+ await expect(mapsTab).toBeVisible({ timeout: 15000 });
334
+ await mapsTab.click();
335
+ await captureEvidence(page, testInfo, '02-mapas-tab', 'Aba MAPAS aberta', evidence);
336
+
337
+ // Section title / labels
338
+ await expect(page.getByText('Tela principal do shop').first()).toBeVisible({
339
+ timeout: 15000,
340
+ });
341
+ await expect(page.getByText('Localizador de franquias').first()).toBeVisible({
342
+ timeout: 10000,
343
+ });
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
351
+ const primaryOptions = page.getByTestId('maps-primary-entry-options');
352
+ await expect(primaryOptions).toBeVisible({ timeout: 10000 });
353
+
354
+ // Franchise locator block on the Maps tab itself
355
+ await expect(page.getByTestId('maps-franchise-locator')).toBeVisible({
356
+ timeout: 10000,
357
+ });
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})),
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);
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
392
+ const bodyText = await page.locator('body').innerText();
393
+ expect(bodyText).not.toMatch(/permanece na aba Shop/i);
394
+ expect(bodyText).not.toMatch(/Visibilidade detalhada por franquia\/endereço no mapa: aba Shop/i);
395
+
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([]);
399
+ });
400
+ });