@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,269 @@
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 jsonHeaders = () => ({
13
+ ...CORS_HEADERS,
14
+ 'content-type': 'application/ld+json; charset=utf-8',
15
+ });
16
+
17
+ const textHeaders = () => ({
18
+ ...CORS_HEADERS,
19
+ 'content-type': 'text/css; charset=utf-8',
20
+ });
21
+
22
+ const collection = member => ({
23
+ member,
24
+ 'hydra:member': member,
25
+ totalItems: member.length,
26
+ 'hydra:totalItems': member.length,
27
+ });
28
+
29
+ const company = {
30
+ '@id': '/people/2',
31
+ id: 2,
32
+ name: 'CONTROLE ONLINE',
33
+ alias: 'CONTROLE ONLINE',
34
+ panel_enabled: true,
35
+ enabled: true,
36
+ commercial_enabled: true,
37
+ configs: {},
38
+ };
39
+
40
+ const statuses = [
41
+ {
42
+ '@id': '/statuses/1',
43
+ id: 1,
44
+ status: 'Aberto',
45
+ realStatus: 'open',
46
+ color: '#3b82f6',
47
+ },
48
+ ];
49
+
50
+ const categories = [
51
+ { '@id': '/categories/1', id: 1, context: 'relationship', name: 'Comercial' },
52
+ { '@id': '/categories/4', id: 4, context: 'relationship', name: 'Inbound' },
53
+ {
54
+ '@id': '/categories/2',
55
+ id: 2,
56
+ context: 'relationship-criticality',
57
+ name: 'Normal',
58
+ },
59
+ {
60
+ '@id': '/categories/3',
61
+ id: 3,
62
+ context: 'relationship-reason',
63
+ name: 'Indicação',
64
+ },
65
+ ];
66
+
67
+ const people = [
68
+ {
69
+ '@id': '/people/31',
70
+ id: 31,
71
+ name: 'CLIENTE CATEGORIA',
72
+ alias: 'CAT',
73
+ peopleType: 'J',
74
+ },
75
+ ];
76
+
77
+ // API returns category as plain reference (not expanded) — the bug under test
78
+ const opportunities = [
79
+ {
80
+ id: 201,
81
+ client: people[0],
82
+ category: '/categories/4',
83
+ criticality: '/categories/2',
84
+ reason: '/categories/3',
85
+ taskStatus: '/statuses/1',
86
+ dueDate: '2026-08-20',
87
+ alterDate: '2026-08-10',
88
+ announce: '',
89
+ },
90
+ ];
91
+
92
+ const mockCrmApi = async page => {
93
+ const savedPayloads = [];
94
+
95
+ await page.route(`${API_ORIGIN}/**`, async route => {
96
+ const request = route.request();
97
+ const url = new URL(request.url());
98
+ const pathname = url.pathname.replace(/^\/+/, '');
99
+
100
+ if (request.method().toUpperCase() === '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: #1C8FBD; --secondary: #0169D9; }',
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/companies/my') {
121
+ return route.fulfill({
122
+ status: 200,
123
+ headers: jsonHeaders(),
124
+ body: JSON.stringify(collection([company])),
125
+ });
126
+ }
127
+
128
+ if (pathname === 'people/company/default') {
129
+ return route.fulfill({
130
+ status: 200,
131
+ headers: jsonHeaders(),
132
+ body: JSON.stringify(company),
133
+ });
134
+ }
135
+
136
+ if (pathname === 'statuses') {
137
+ return route.fulfill({
138
+ status: 200,
139
+ headers: jsonHeaders(),
140
+ body: JSON.stringify(collection(statuses)),
141
+ });
142
+ }
143
+
144
+ if (pathname === 'categories') {
145
+ return route.fulfill({
146
+ status: 200,
147
+ headers: jsonHeaders(),
148
+ body: JSON.stringify(collection(categories)),
149
+ });
150
+ }
151
+
152
+ if (pathname === 'people') {
153
+ return route.fulfill({
154
+ status: 200,
155
+ headers: jsonHeaders(),
156
+ body: JSON.stringify(collection(people)),
157
+ });
158
+ }
159
+
160
+ if (pathname === 'tasks' || pathname.startsWith('tasks/')) {
161
+ if (request.method().toUpperCase() === 'PUT' || request.method().toUpperCase() === 'POST') {
162
+ try {
163
+ savedPayloads.push(JSON.parse(request.postData() || '{}'));
164
+ } catch {
165
+ savedPayloads.push({});
166
+ }
167
+ return route.fulfill({
168
+ status: 200,
169
+ headers: jsonHeaders(),
170
+ body: JSON.stringify({ id: 201, ...opportunities[0] }),
171
+ });
172
+ }
173
+
174
+ return route.fulfill({
175
+ status: 200,
176
+ headers: jsonHeaders(),
177
+ body: JSON.stringify(collection(opportunities)),
178
+ });
179
+ }
180
+
181
+ if (pathname === 'menus-people') {
182
+ return route.fulfill({
183
+ status: 200,
184
+ headers: jsonHeaders(),
185
+ body: JSON.stringify({ modules: {} }),
186
+ });
187
+ }
188
+
189
+ if (pathname === 'configs/discovery-configs') {
190
+ return route.fulfill({
191
+ status: 200,
192
+ headers: jsonHeaders(),
193
+ body: JSON.stringify({ configs: {} }),
194
+ });
195
+ }
196
+
197
+ return route.fulfill({
198
+ status: 200,
199
+ headers: jsonHeaders(),
200
+ body: JSON.stringify(collection([])),
201
+ });
202
+ });
203
+
204
+ await page.addInitScript(
205
+ ({ version }) => {
206
+ localStorage.setItem(
207
+ 'session',
208
+ JSON.stringify({
209
+ id: 19,
210
+ people: 19,
211
+ api_key: 'test-api-key',
212
+ active: 1,
213
+ mycompany: 2,
214
+ roles: ['ROLE_SUPER'],
215
+ }),
216
+ );
217
+ localStorage.setItem('app-type', 'CRM');
218
+ localStorage.setItem('config', JSON.stringify({ language: 'pt-br' }));
219
+ localStorage.setItem(
220
+ 'device',
221
+ JSON.stringify({
222
+ id: 'web-crm',
223
+ device: 'web-crm',
224
+ type: 'WEB',
225
+ appName: 'Browser CRM',
226
+ appVersion: version,
227
+ buildNumber: version,
228
+ systemName: 'web',
229
+ systemVersion: 'web',
230
+ deviceType: 'web',
231
+ metadata: {},
232
+ }),
233
+ );
234
+ },
235
+ { version: appVersion },
236
+ );
237
+
238
+ return savedPayloads;
239
+ };
240
+
241
+ test.describe('crm opportunity category editor', () => {
242
+ test('normalizes category reference when opening edit modal', async ({ page }) => {
243
+ await mockCrmApi(page);
244
+
245
+ await page.goto('/crm-index');
246
+
247
+ await expect(page.getByText('CLIENTE CATEGORIA')).toBeVisible();
248
+
249
+ // Open edit — UI typically exposes an edit control on the card
250
+ const editTrigger = page
251
+ .getByRole('button', { name: /edit|editar/i })
252
+ .or(page.locator('[data-testid="edit-opportunity"]'))
253
+ .or(page.locator('text=CLIENTE CATEGORIA').locator('..').getByRole('button').first());
254
+
255
+ // Fallback: click any pencil / edit icon near the card
256
+ if (await editTrigger.count()) {
257
+ await editTrigger.first().click();
258
+ } else {
259
+ await page.locator('text=CLIENTE CATEGORIA').click({ button: 'right' }).catch(() => {});
260
+ const pencil = page.locator('[class*="edit"], [name="edit"], [name="pencil"]').first();
261
+ if (await pencil.count()) {
262
+ await pencil.click();
263
+ }
264
+ }
265
+
266
+ // After normalize, the expanded option name "Inbound" must appear in the form
267
+ await expect(page.getByText('Inbound')).toBeVisible({ timeout: 10000 });
268
+ });
269
+ });
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Smoke: Franqueado — Royalties a pagar (ui-crm#24)
3
+ * Navigates to RoyaltiesPayablePage and asserts list shell loads
4
+ * with payer-scoped invoice request (mocked).
5
+ *
6
+ * Requires app-community browser harness (same pattern as
7
+ * royalties-receivable.spec.js / seller-commissions.spec.js).
8
+ * When run outside that harness, this file documents the acceptance
9
+ * scenario for QA.
10
+ */
11
+ const { expect, test } = require('playwright/test');
12
+
13
+ const API_ORIGIN =
14
+ process.env.API_ORIGIN ||
15
+ process.env.EXPO_PUBLIC_API_URL ||
16
+ 'https://api.controleonline.com';
17
+
18
+ const CORS_HEADERS = {
19
+ 'access-control-allow-origin': '*',
20
+ 'access-control-allow-headers':
21
+ 'API-TOKEN, APP-DOMAIN, DEVICE, ACCEPT, CONTENT-TYPE, X-Requested-With',
22
+ 'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',
23
+ };
24
+
25
+ const jsonHeaders = () => ({
26
+ ...CORS_HEADERS,
27
+ 'content-type': 'application/ld+json; charset=utf-8',
28
+ });
29
+
30
+ const collection = member => ({
31
+ member,
32
+ 'hydra:member': member,
33
+ totalItems: member.length,
34
+ 'hydra:totalItems': member.length,
35
+ summary: {
36
+ sum: { price: 150 },
37
+ financial: { totalAmount: 150, openAmount: 150, paidAmount: 0 },
38
+ },
39
+ });
40
+
41
+ const company = {
42
+ id: 88,
43
+ name: 'Franqueado Alpha',
44
+ alias: 'ALPHA',
45
+ panel_enabled: true,
46
+ enabled: true,
47
+ commercial_enabled: true,
48
+ theme: { colors: { primary: '#0EA5E9' } },
49
+ };
50
+
51
+ const royaltyInvoice = {
52
+ id: 502,
53
+ invoiceType: 'royalties',
54
+ price: 150,
55
+ dueDate: '2026-08-20',
56
+ payer: { id: 88, name: 'Franqueado Alpha', alias: 'ALPHA' },
57
+ receiver: { id: 3, name: 'Franqueadora Teste', alias: 'FRANQ' },
58
+ category: { id: 12, name: 'Royalties' },
59
+ status: { id: 1, realStatus: 'open' },
60
+ };
61
+
62
+ test.describe('Royalties a pagar (franqueado)', () => {
63
+ test('loads RoyaltiesPayablePage and lists royalty invoices for payer company', async ({
64
+ page,
65
+ }) => {
66
+ let invoicesQuery = '';
67
+
68
+ await page.route(`${API_ORIGIN}/**`, async route => {
69
+ const request = route.request();
70
+ const url = new URL(request.url());
71
+ const pathname = url.pathname.replace(/^\/+/, '');
72
+ const method = request.method().toUpperCase();
73
+
74
+ if (method === 'OPTIONS') {
75
+ return route.fulfill({ status: 204, headers: CORS_HEADERS, body: '' });
76
+ }
77
+
78
+ if (
79
+ pathname === 'companies' ||
80
+ pathname.startsWith('people/') ||
81
+ pathname === 'people'
82
+ ) {
83
+ return route.fulfill({
84
+ status: 200,
85
+ headers: jsonHeaders(),
86
+ body: JSON.stringify(company),
87
+ });
88
+ }
89
+
90
+ if (pathname === 'invoices' || pathname.startsWith('invoices')) {
91
+ invoicesQuery = url.search || '';
92
+ return route.fulfill({
93
+ status: 200,
94
+ headers: jsonHeaders(),
95
+ body: JSON.stringify(collection([royaltyInvoice])),
96
+ });
97
+ }
98
+
99
+ return route.fulfill({
100
+ status: 200,
101
+ headers: jsonHeaders(),
102
+ body: JSON.stringify({ member: [], 'hydra:member': [] }),
103
+ });
104
+ });
105
+
106
+ // Deep-link / navigate as the app shell would for the registered route
107
+ await page.goto(
108
+ process.env.SMOKE_APP_URL ||
109
+ 'http://localhost:8081/?route=RoyaltiesPayablePage',
110
+ );
111
+
112
+ // Shell: page testID or title
113
+ const pageRoot = page.getByTestId('royalties-payable-page').or(
114
+ page.getByText(/Royalties a pagar/i),
115
+ );
116
+ await expect(pageRoot.first()).toBeVisible({ timeout: 30000 });
117
+
118
+ // Request should scope to payer (franqueado) + invoiceType=royalties
119
+ expect(invoicesQuery).toMatch(/invoiceType=royalties|invoiceType%3Droyalties/);
120
+ expect(invoicesQuery).toMatch(/payer=88|payer%3D88/);
121
+ });
122
+ });
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Smoke: Franqueadora — Royalties a receber (ui-crm#23)
3
+ * Navigates to RoyaltiesReceivablePage and asserts list shell loads
4
+ * with receiver-scoped invoice request (mocked).
5
+ *
6
+ * Requires app-community browser harness (same pattern as ui-financial
7
+ * financial-entries-create.spec.js). When run outside that harness,
8
+ * this file documents the acceptance scenario for QA.
9
+ */
10
+ const { expect, test } = require('playwright/test');
11
+
12
+ const API_ORIGIN =
13
+ process.env.API_ORIGIN ||
14
+ process.env.EXPO_PUBLIC_API_URL ||
15
+ 'https://api.controleonline.com';
16
+
17
+ const CORS_HEADERS = {
18
+ 'access-control-allow-origin': '*',
19
+ 'access-control-allow-headers':
20
+ 'API-TOKEN, APP-DOMAIN, DEVICE, ACCEPT, CONTENT-TYPE, X-Requested-With',
21
+ 'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',
22
+ };
23
+
24
+ const jsonHeaders = () => ({
25
+ ...CORS_HEADERS,
26
+ 'content-type': 'application/ld+json; charset=utf-8',
27
+ });
28
+
29
+ const collection = member => ({
30
+ member,
31
+ 'hydra:member': member,
32
+ totalItems: member.length,
33
+ 'hydra:totalItems': member.length,
34
+ summary: {
35
+ sum: { price: 150 },
36
+ financial: { totalAmount: 150, openAmount: 150, paidAmount: 0 },
37
+ },
38
+ });
39
+
40
+ const company = {
41
+ id: 3,
42
+ name: 'Franqueadora Teste',
43
+ alias: 'FRANQ',
44
+ panel_enabled: true,
45
+ enabled: true,
46
+ commercial_enabled: true,
47
+ theme: { colors: { primary: '#0EA5E9' } },
48
+ };
49
+
50
+ const royaltyInvoice = {
51
+ id: 501,
52
+ invoiceType: 'invoice',
53
+ price: 150,
54
+ dueDate: '2026-08-20',
55
+ payer: { id: 88, name: 'Franqueado Alpha', alias: 'ALPHA' },
56
+ receiver: { id: 3, name: 'Franqueadora Teste', alias: 'FRANQ' },
57
+ category: { id: 12, name: 'Royalties' },
58
+ status: { id: 1, realStatus: 'open' },
59
+ };
60
+
61
+ test.describe('Royalties a receber (franqueadora)', () => {
62
+ test('loads RoyaltiesReceivablePage and lists royalty invoices for receiver company', async ({
63
+ page,
64
+ }) => {
65
+ let invoicesQuery = '';
66
+
67
+ await page.route(`${API_ORIGIN}/**`, async route => {
68
+ const request = route.request();
69
+ const url = new URL(request.url());
70
+ const pathname = url.pathname.replace(/^\/+/, '');
71
+ const method = request.method().toUpperCase();
72
+
73
+ if (method === 'OPTIONS') {
74
+ return route.fulfill({ status: 204, headers: CORS_HEADERS, body: '' });
75
+ }
76
+
77
+ if (
78
+ pathname === 'companies' ||
79
+ pathname.startsWith('people/') ||
80
+ pathname === 'people'
81
+ ) {
82
+ return route.fulfill({
83
+ status: 200,
84
+ headers: jsonHeaders(),
85
+ body: JSON.stringify(company),
86
+ });
87
+ }
88
+
89
+ if (pathname === 'invoices' || pathname.startsWith('invoices')) {
90
+ invoicesQuery = url.search || '';
91
+ return route.fulfill({
92
+ status: 200,
93
+ headers: jsonHeaders(),
94
+ body: JSON.stringify(collection([royaltyInvoice])),
95
+ });
96
+ }
97
+
98
+ return route.fulfill({
99
+ status: 200,
100
+ headers: jsonHeaders(),
101
+ body: JSON.stringify({ member: [], 'hydra:member': [] }),
102
+ });
103
+ });
104
+
105
+ // Deep-link / navigate as the app shell would for the registered route
106
+ await page.goto(
107
+ process.env.SMOKE_APP_URL ||
108
+ 'http://localhost:8081/?route=RoyaltiesReceivablePage',
109
+ );
110
+
111
+ // Shell: page testID or title
112
+ const pageRoot = page.getByTestId('royalties-receivable-page').or(
113
+ page.getByText(/Royalties a receber/i),
114
+ );
115
+ await expect(pageRoot.first()).toBeVisible({ timeout: 30000 });
116
+
117
+ // Request should scope to receiver (franqueadora)
118
+ expect(invoicesQuery).toMatch(/invoiceType=royalties|invoiceType%3Droyalties/);
119
+ expect(invoicesQuery).toMatch(/receiver=3|receiver%3D3/);
120
+ });
121
+ });