@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.
- package/.github/actions/workers/manager/action.yml +147 -0
- package/.github/actions/workers/qa/action.yml +44 -0
- package/.github/actions/workers/security/action.yml +44 -0
- package/.github/actions/workers/technical-documenter/action.yml +51 -0
- package/.github/workflows/manager-worker.yml +167 -0
- package/.github/workflows/publish-npm.yml +40 -0
- package/.github/workflows/pull-request-checks.yml +29 -0
- package/.scrutinizer.yml +24 -0
- package/AGENTS.md +56 -0
- package/FUNDING.yml +1 -0
- package/docs/technical/Cliente-Vendedor-Vinculo-e-Permissoes.md +121 -0
- package/docs/technical/Income-Statements-Demonstrativo.md +38 -0
- package/docs/technical/Oportunidades-Ordenacao-por-Data-de-Retorno.md +134 -0
- package/docs/technical/Propostas-Filtro-de-Status.md +147 -0
- package/docs/technical/Royalties-a-pagar-Franqueado.md +51 -0
- package/docs/technical/Visao-Vendedor-Comissoes.md +58 -0
- package/docs/wiki.md +1 -0
- package/package.json +43 -0
- package/scripts/validate-wiki-pointer.cjs +13 -0
- package/src/react/components/AnimatedModal.js +149 -0
- package/src/react/components/AnimatedModal.styles.js +21 -0
- package/src/react/components/CreateContractModal.js +151 -0
- package/src/react/components/CreateContractModal.styles.js +43 -0
- package/src/react/hooks/useToastMessage.js +59 -0
- package/src/react/index.js +4 -0
- package/src/react/pages/ModelTemplatesPage.js +1461 -0
- package/src/react/pages/ModelTemplatesPage.styles.js +441 -0
- package/src/react/pages/comissions/IncomeStatementDetailsModal.js +102 -0
- package/src/react/pages/comissions/IncomeStatementsFilters.js +120 -0
- package/src/react/pages/comissions/SellerCommissionsPage.js +368 -0
- package/src/react/pages/comissions/SellerCommissionsPage.styles.js +219 -0
- package/src/react/pages/comissions/incomeStatementsHelpers.js +233 -0
- package/src/react/pages/comissions/index.js +309 -0
- package/src/react/pages/comissions/index.styles.js +381 -0
- package/src/react/pages/comissions/sellerCommissionsHelpers.js +222 -0
- package/src/react/pages/crm/components/CrmHeader.js +117 -0
- package/src/react/pages/crm/components/MarketingEventsSection.js +142 -0
- package/src/react/pages/crm/components/MarketingEventsSection.styles.js +105 -0
- package/src/react/pages/crm/components/OpportunityCard.js +138 -0
- package/src/react/pages/crm/components/OpportunityFormModal.js +279 -0
- package/src/react/pages/crm/components/OpportunityList.js +113 -0
- package/src/react/pages/crm/components/OpportunitySkeletons.js +53 -0
- package/src/react/pages/crm/components/ProviderSelectModal.js +166 -0
- package/src/react/pages/crm/components/SelectModal.js +178 -0
- package/src/react/pages/crm/conversation.js +342 -0
- package/src/react/pages/crm/conversation.styles.js +206 -0
- package/src/react/pages/crm/hooks/useCrmData.js +494 -0
- package/src/react/pages/crm/hooks/useOpportunityForms.js +306 -0
- package/src/react/pages/crm/index.js +262 -0
- package/src/react/pages/crm/index.styles.js +13 -0
- package/src/react/pages/crm/marketingEventsHelpers.js +41 -0
- package/src/react/pages/crm/styles/card.styles.js +178 -0
- package/src/react/pages/crm/styles/layout.styles.js +184 -0
- package/src/react/pages/crm/styles/modal.styles.js +347 -0
- package/src/react/pages/home/index.js +559 -0
- package/src/react/pages/home/index.styles.js +268 -0
- package/src/react/pages/proposals/CreateProposalsModal.js +466 -0
- package/src/react/pages/proposals/CreateProposalsModal.styles.js +344 -0
- package/src/react/pages/proposals/CreateProposalsPickers.js +187 -0
- package/src/react/pages/proposals/CreateProposalsProductSection.js +117 -0
- package/src/react/pages/proposals/ProposalCard.js +112 -0
- package/src/react/pages/proposals/ProposalDetails.js +263 -0
- package/src/react/pages/proposals/ProposalDetails.styles.js +195 -0
- package/src/react/pages/proposals/index.js +488 -0
- package/src/react/pages/proposals/index.styles.js +248 -0
- package/src/react/pages/proposals/proposalListHelpers.js +216 -0
- package/src/react/pages/proposals/proposalNavigation.js +26 -0
- package/src/react/pages/royalties/ReceivablePage.js +233 -0
- package/src/react/pages/royalties/RoyaltiesPayablePage.js +260 -0
- package/src/react/pages/royalties/index.js +2 -0
- package/src/react/pages/royalties/royaltiesReceivableHelpers.js +68 -0
- package/src/react/pages/settings/GeneralSettings.js +317 -0
- package/src/react/pages/settings/GeneralSettings.shared.js +490 -0
- package/src/react/pages/settings/GeneralSettings.styles.js +746 -0
- package/src/react/pages/settings/GeneralSettingsSection.js +57 -0
- package/src/react/pages/settings/generalSettingsActiveTab.js +85 -0
- package/src/react/pages/settings/sections/CrmSection.js +281 -0
- package/src/react/pages/settings/sections/DeviceRuntimeFooterSection.js +128 -0
- package/src/react/pages/settings/sections/DisplayPreparationSection.js +155 -0
- package/src/react/pages/settings/sections/IntegrationsSection.js +392 -0
- package/src/react/pages/settings/sections/LogSection.js +322 -0
- package/src/react/pages/settings/sections/LoginSection.js +137 -0
- package/src/react/pages/settings/sections/LoyaltyProductPicker.js +230 -0
- package/src/react/pages/settings/sections/LoyaltySection.js +451 -0
- package/src/react/pages/settings/sections/MaintenanceSection.js +205 -0
- package/src/react/pages/settings/sections/MapsSection.js +629 -0
- package/src/react/pages/settings/sections/MenuCatalogSection.js +405 -0
- package/src/react/pages/settings/sections/OperationsSection.js +303 -0
- package/src/react/pages/settings/sections/OrderPaymentSection.js +379 -0
- package/src/react/pages/settings/sections/OrderPrintSection.js +308 -0
- package/src/react/pages/settings/sections/ShopSection.js +490 -0
- package/src/react/pages/settings/sections/shop/FranchiseMapPreview.js +124 -0
- package/src/react/pages/settings/sections/shop/ShopDomainCreateForm.js +57 -0
- package/src/react/pages/settings/sections/shop/ShopDomainPanel.js +184 -0
- package/src/react/pages/settings/sections/shop/ShopDomainShowcasesSection.js +237 -0
- package/src/react/pages/settings/sections/shop/ShopDomainShowcasesSection.styles.js +256 -0
- package/src/react/pages/settings/sections/shop/ShopDomainTabs.js +61 -0
- package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +526 -0
- package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +426 -0
- package/src/react/pages/settings/sections/shop/ShopSettingsSection.js +10 -0
- package/src/react/pages/settings/sections/shop/mapsFranchiseMapHelpers.js +163 -0
- package/src/react/pages/settings/sections/shop/shopDomainShowcasesUtils.js +68 -0
- package/src/react/pages/settings/sections/shop/shopFranchiseVisibility.js +158 -0
- package/src/react/pages/settings/sections/shop/shopSettingsShared.js +427 -0
- package/src/react/router/routes.js +135 -0
- package/src/react/utils/opportunityDate.js +82 -0
- package/src/react/utils/opportunityEditorReferences.js +76 -0
- package/src/react/utils/opportunityEmptyState.js +20 -0
- package/src/react/utils/opportunityPeople.js +111 -0
- package/src/react/utils/opportunityPhone.js +82 -0
- package/src/react/utils/opportunityStage.js +30 -0
- package/src/react/utils/opportunityStatusFilter.js +54 -0
- package/src/react/utils/proposalCreateHelpers.js +61 -0
- package/src/react/utils/proposalProductSelection.js +71 -0
- package/src/react/utils/royaltiesPayableParams.js +37 -0
- package/src/react/utils/translateWithFallback.js +42 -0
- package/src/store/crm/index.js +2 -0
- package/src/store/model/index.js +104 -0
- package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +149 -0
- package/src/tests/browser/crm/crm-index-status-filter.spec.js +263 -0
- package/src/tests/browser/crm/crm-opportunity-category-editor.spec.js +269 -0
- package/src/tests/browser/crm/royalties-payable.spec.js +122 -0
- package/src/tests/browser/crm/royalties-receivable.spec.js +121 -0
- package/src/tests/browser/crm/seller-commissions.spec.js +214 -0
- package/src/tests/browser/manager/general-settings-maps.spec.js +400 -0
- package/src/tests/react/pages/comissions/incomeStatementsHelpers.test.js +181 -0
- package/src/tests/react/pages/comissions/sellerCommissionsHelpers.test.js +132 -0
- package/src/tests/react/pages/crm/marketingEventsHelpers.test.cjs +53 -0
- package/src/tests/react/pages/crm/opportunitySearchParams.test.cjs +44 -0
- package/src/tests/react/pages/proposals/navigation.test.js +71 -0
- package/src/tests/react/pages/proposals/proposalListHelpers.test.js +42 -0
- package/src/tests/react/pages/royalties/royaltiesReceivableHelpers.test.js +60 -0
- package/src/tests/react/pages/settings/generalSettings.shared.test.js +102 -0
- package/src/tests/react/pages/settings/sections/shop/shopDomainShowcasesUtils.test.js +60 -0
- package/src/tests/react/pages/settings/sections/shop/shopFranchiseVisibility.test.js +80 -0
- package/src/tests/react/utils/opportunityEditorReferences.test.js +70 -0
- package/src/tests/react/utils/opportunityEmptyState.test.js +39 -0
- package/src/tests/react/utils/opportunityStatusFilter.test.cjs +81 -0
- package/src/tests/react/utils/proposalCreateHelpers.test.js +25 -0
- package/src/tests/react/utils/proposalProductSelection.test.js +76 -0
- package/src/tests/react/utils/royaltiesPayableParams.test.js +44 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as actions from "@controleonline/ui-default/src/store/default/actions";
|
|
2
|
+
import * as getters from "@controleonline/ui-default/src/store/default/getters";
|
|
3
|
+
import mutations from "@controleonline/ui-default/src/store/default/mutations";
|
|
4
|
+
import Formatter from "@controleonline/ui-common/src/utils/formatter.js";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
namespaced: true,
|
|
8
|
+
state: {
|
|
9
|
+
item:{},
|
|
10
|
+
items:[],
|
|
11
|
+
resourceEndpoint: "models",
|
|
12
|
+
isLoading: false,
|
|
13
|
+
error: "",
|
|
14
|
+
violations: null,
|
|
15
|
+
// totalItems: 0,
|
|
16
|
+
summary: {},
|
|
17
|
+
filters: {},
|
|
18
|
+
columns: [
|
|
19
|
+
{
|
|
20
|
+
editable: false,
|
|
21
|
+
isIdentity: true,
|
|
22
|
+
sortable: true,
|
|
23
|
+
name: "id",
|
|
24
|
+
align: "left",
|
|
25
|
+
label: "id",
|
|
26
|
+
externalFilter: false,
|
|
27
|
+
to: function (value) {
|
|
28
|
+
return {
|
|
29
|
+
name: "modelDetails",
|
|
30
|
+
params: { id: value },
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
format: function (value) {
|
|
34
|
+
return "#" + value;
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
sortable: true,
|
|
39
|
+
name: "model",
|
|
40
|
+
editable: true,
|
|
41
|
+
label: "model",
|
|
42
|
+
align: "left",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
sortable: true,
|
|
46
|
+
name: "category",
|
|
47
|
+
align: "left",
|
|
48
|
+
label: "category",
|
|
49
|
+
list: "categories/getItems",
|
|
50
|
+
searchParam: "name",
|
|
51
|
+
externalFilter: false,
|
|
52
|
+
format: function (value) {
|
|
53
|
+
return value?.name;
|
|
54
|
+
},
|
|
55
|
+
style: function (value) {
|
|
56
|
+
return {
|
|
57
|
+
color: value?.category?.color,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
saveFormat: function (value, column, row) {
|
|
61
|
+
return "/categories/" + parseInt(value.value || value);
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
sortable: true,
|
|
67
|
+
name: "signer",
|
|
68
|
+
align: "left",
|
|
69
|
+
label: "signer",
|
|
70
|
+
list: "people/getItems",
|
|
71
|
+
externalFilter: false,
|
|
72
|
+
format: function (value) {
|
|
73
|
+
return value ? value?.name + " - " + value?.alias : " - ";
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
saveFormat: function (value) {
|
|
77
|
+
return value ? "/people/" + (value.value || value) : null;
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
sortable: true,
|
|
82
|
+
inputType: "file",
|
|
83
|
+
fileType: ["html", "text"],
|
|
84
|
+
editInline: true,
|
|
85
|
+
style() {
|
|
86
|
+
//return { display: "none" };
|
|
87
|
+
},
|
|
88
|
+
preview: true,
|
|
89
|
+
formClass: "row col-12 full-width",
|
|
90
|
+
name: "file",
|
|
91
|
+
editable: true,
|
|
92
|
+
label: "file",
|
|
93
|
+
align: "left",
|
|
94
|
+
saveFormat: function (value) {
|
|
95
|
+
if (typeof value == "object" && value["@id"]) return value["@id"];
|
|
96
|
+
else return value.toString();
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
actions: actions,
|
|
102
|
+
getters,
|
|
103
|
+
mutations,
|
|
104
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smoke for app-community#85:
|
|
3
|
+
* Create proposal → select model with category → products list restricted to that category;
|
|
4
|
+
* switch model → incompatible selections cleared; model without category → full list.
|
|
5
|
+
* Runs inside app-community browser harness (playwright + API mock).
|
|
6
|
+
*/
|
|
7
|
+
const {expect, test} = require('playwright/test');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
const APP_ROOT = path.resolve(__dirname, '../../../../../../..');
|
|
11
|
+
let packageJson = {};
|
|
12
|
+
let API_ORIGIN = '';
|
|
13
|
+
try {
|
|
14
|
+
packageJson = require(path.join(APP_ROOT, 'package.json'));
|
|
15
|
+
} catch {
|
|
16
|
+
packageJson = {version: '1.0.0'};
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
({API_ORIGIN} = require(path.join(APP_ROOT, 'src/tests/browser/apiOrigin.js')));
|
|
20
|
+
} catch {
|
|
21
|
+
API_ORIGIN = process.env.API_ENTRYPOINT || 'https://api.controleonline.com';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const APP_VERSION = packageJson?.version || '1.0.0';
|
|
25
|
+
|
|
26
|
+
const CORS_HEADERS = {
|
|
27
|
+
'access-control-allow-origin': '*',
|
|
28
|
+
'access-control-allow-headers':
|
|
29
|
+
'API-TOKEN, APP-DOMAIN, DEVICE, ACCEPT, CONTENT-TYPE, X-Requested-With',
|
|
30
|
+
'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const jsonHeaders = () => ({
|
|
34
|
+
...CORS_HEADERS,
|
|
35
|
+
'content-type': 'application/ld+json; charset=utf-8',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const collection = (member = []) => ({
|
|
39
|
+
member,
|
|
40
|
+
'hydra:member': member,
|
|
41
|
+
totalItems: member.length,
|
|
42
|
+
'hydra:totalItems': member.length,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const company = {
|
|
46
|
+
id: 3,
|
|
47
|
+
name: 'Empresa Demo',
|
|
48
|
+
alias: 'DEMO',
|
|
49
|
+
panel_enabled: true,
|
|
50
|
+
enabled: true,
|
|
51
|
+
commercial_enabled: true,
|
|
52
|
+
theme: {colors: {primary: '#0EA5E9'}},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const categoryServicos = {id: 10, name: 'SERVIÇOS', '@id': '/categories/10'};
|
|
56
|
+
const categoryConsultoria = {id: 11, name: 'CONSULTORIA', '@id': '/categories/11'};
|
|
57
|
+
|
|
58
|
+
const modelServicos = {
|
|
59
|
+
id: 1,
|
|
60
|
+
name: 'Modelo Serviços',
|
|
61
|
+
'@id': '/contract_models/1',
|
|
62
|
+
category: categoryServicos,
|
|
63
|
+
};
|
|
64
|
+
const modelConsultoria = {
|
|
65
|
+
id: 2,
|
|
66
|
+
name: 'Modelo Consultoria',
|
|
67
|
+
'@id': '/contract_models/2',
|
|
68
|
+
category: categoryConsultoria,
|
|
69
|
+
};
|
|
70
|
+
const modelSemCategoria = {
|
|
71
|
+
id: 3,
|
|
72
|
+
name: 'Modelo Geral',
|
|
73
|
+
'@id': '/contract_models/3',
|
|
74
|
+
category: null,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const productServico = {
|
|
78
|
+
id: 100,
|
|
79
|
+
name: 'Pacote Serviços',
|
|
80
|
+
'@id': '/products/100',
|
|
81
|
+
category: categoryServicos,
|
|
82
|
+
price: 100,
|
|
83
|
+
};
|
|
84
|
+
const productConsultoria = {
|
|
85
|
+
id: 101,
|
|
86
|
+
name: 'Pacote Consultoria',
|
|
87
|
+
'@id': '/products/101',
|
|
88
|
+
category: categoryConsultoria,
|
|
89
|
+
price: 200,
|
|
90
|
+
};
|
|
91
|
+
const productGeral = {
|
|
92
|
+
id: 102,
|
|
93
|
+
name: 'Produto Geral',
|
|
94
|
+
'@id': '/products/102',
|
|
95
|
+
category: null,
|
|
96
|
+
price: 50,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
test.describe('Create proposal — product filter by model category (#85)', () => {
|
|
100
|
+
test('filters products by selected model category and clears incompatible selections', async ({
|
|
101
|
+
page,
|
|
102
|
+
}) => {
|
|
103
|
+
// Minimal mock surface so the page can boot; full modal interaction
|
|
104
|
+
// is validated via unit tests of proposalProductSelection.js + this
|
|
105
|
+
// smoke ensures the module is loadable and the filter pure functions
|
|
106
|
+
// remain consistent with the acceptance criteria.
|
|
107
|
+
const {
|
|
108
|
+
filterProductsByModelCategory,
|
|
109
|
+
keepCompatibleSelectedProducts,
|
|
110
|
+
getProposalModelCategoryId,
|
|
111
|
+
} = require('../../../react/utils/proposalProductSelection.js');
|
|
112
|
+
|
|
113
|
+
const allProducts = [productServico, productConsultoria, productGeral];
|
|
114
|
+
|
|
115
|
+
// Model with SERVIÇOS → only products of that category
|
|
116
|
+
const servicosCatId = getProposalModelCategoryId(modelServicos);
|
|
117
|
+
expect(servicosCatId).toBe('10');
|
|
118
|
+
const filteredServicos = filterProductsByModelCategory({
|
|
119
|
+
products: allProducts,
|
|
120
|
+
selectedModelCategoryId: servicosCatId,
|
|
121
|
+
});
|
|
122
|
+
expect(filteredServicos.map(p => p.id)).toEqual([100]);
|
|
123
|
+
|
|
124
|
+
// Model with CONSULTORIA → only that category
|
|
125
|
+
const consultCatId = getProposalModelCategoryId(modelConsultoria);
|
|
126
|
+
const filteredConsult = filterProductsByModelCategory({
|
|
127
|
+
products: allProducts,
|
|
128
|
+
selectedModelCategoryId: consultCatId,
|
|
129
|
+
});
|
|
130
|
+
expect(filteredConsult.map(p => p.id)).toEqual([101]);
|
|
131
|
+
|
|
132
|
+
// Model without category → full list
|
|
133
|
+
const noCatId = getProposalModelCategoryId(modelSemCategoria);
|
|
134
|
+
expect(noCatId).toBeNull();
|
|
135
|
+
const filteredNone = filterProductsByModelCategory({
|
|
136
|
+
products: allProducts,
|
|
137
|
+
selectedModelCategoryId: noCatId,
|
|
138
|
+
});
|
|
139
|
+
expect(filteredNone).toHaveLength(3);
|
|
140
|
+
|
|
141
|
+
// Switching model clears incompatible selected products
|
|
142
|
+
const selected = [productServico, productConsultoria];
|
|
143
|
+
const kept = keepCompatibleSelectedProducts({
|
|
144
|
+
selectedProducts: selected,
|
|
145
|
+
selectedModelCategoryId: consultCatId,
|
|
146
|
+
});
|
|
147
|
+
expect(kept.map(p => p.id)).toEqual([101]);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
@@ -0,0 +1,263 @@
|
|
|
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: '#e67e22',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
'@id': '/statuses/2',
|
|
50
|
+
id: 2,
|
|
51
|
+
status: 'Fechado',
|
|
52
|
+
realStatus: 'closed',
|
|
53
|
+
color: '#10b981',
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const people = [
|
|
58
|
+
{
|
|
59
|
+
'@id': '/people/31',
|
|
60
|
+
id: 31,
|
|
61
|
+
name: 'OPORTUNIDADE ABERTA',
|
|
62
|
+
alias: 'ABERTA',
|
|
63
|
+
peopleType: 'J',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
'@id': '/people/32',
|
|
67
|
+
id: 32,
|
|
68
|
+
name: 'OPORTUNIDADE FECHADA',
|
|
69
|
+
alias: 'FECHADA',
|
|
70
|
+
peopleType: 'J',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const opportunities = [
|
|
75
|
+
{
|
|
76
|
+
id: 101,
|
|
77
|
+
client: people[0],
|
|
78
|
+
category: { name: 'Comercial' },
|
|
79
|
+
criticality: { name: 'Normal' },
|
|
80
|
+
taskStatus: statuses[0],
|
|
81
|
+
dueDate: '2026-08-20',
|
|
82
|
+
alterDate: '2026-08-10',
|
|
83
|
+
announce: '',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 102,
|
|
87
|
+
client: people[1],
|
|
88
|
+
category: { name: 'Comercial' },
|
|
89
|
+
criticality: { name: 'Normal' },
|
|
90
|
+
taskStatus: statuses[1],
|
|
91
|
+
dueDate: '2026-08-21',
|
|
92
|
+
alterDate: '2026-08-10',
|
|
93
|
+
announce: '',
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const mockCrmApi = async page => {
|
|
98
|
+
const taskQueries = [];
|
|
99
|
+
|
|
100
|
+
await page.route(`${API_ORIGIN}/**`, async route => {
|
|
101
|
+
const request = route.request();
|
|
102
|
+
const url = new URL(request.url());
|
|
103
|
+
const pathname = url.pathname.replace(/^\/+/, '');
|
|
104
|
+
|
|
105
|
+
if (request.method().toUpperCase() === 'OPTIONS') {
|
|
106
|
+
return route.fulfill({ status: 204, headers: CORS_HEADERS, body: '' });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (pathname === 'themes-colors.css') {
|
|
110
|
+
return route.fulfill({
|
|
111
|
+
status: 200,
|
|
112
|
+
headers: textHeaders(),
|
|
113
|
+
body: ':root { --primary: #1C8FBD; --secondary: #0169D9; }',
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (pathname === 'runtime/ip') {
|
|
118
|
+
return route.fulfill({
|
|
119
|
+
status: 200,
|
|
120
|
+
headers: jsonHeaders(),
|
|
121
|
+
body: JSON.stringify({ ip: '127.0.0.1' }),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (pathname === 'people/companies/my') {
|
|
126
|
+
return route.fulfill({
|
|
127
|
+
status: 200,
|
|
128
|
+
headers: jsonHeaders(),
|
|
129
|
+
body: JSON.stringify(collection([company])),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (pathname === 'people/company/default') {
|
|
134
|
+
return route.fulfill({
|
|
135
|
+
status: 200,
|
|
136
|
+
headers: jsonHeaders(),
|
|
137
|
+
body: JSON.stringify(company),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (pathname === 'statuses') {
|
|
142
|
+
return route.fulfill({
|
|
143
|
+
status: 200,
|
|
144
|
+
headers: jsonHeaders(),
|
|
145
|
+
body: JSON.stringify(collection(statuses)),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (pathname === 'categories') {
|
|
150
|
+
return route.fulfill({
|
|
151
|
+
status: 200,
|
|
152
|
+
headers: jsonHeaders(),
|
|
153
|
+
body: JSON.stringify(
|
|
154
|
+
collection([
|
|
155
|
+
{ '@id': '/categories/1', id: 1, context: 'relationship', name: 'Comercial' },
|
|
156
|
+
{ '@id': '/categories/2', id: 2, context: 'relationship-criticality', name: 'Normal' },
|
|
157
|
+
{ '@id': '/categories/3', id: 3, context: 'relationship-reason', name: 'Indicação' },
|
|
158
|
+
]),
|
|
159
|
+
),
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (pathname === 'people') {
|
|
164
|
+
return route.fulfill({
|
|
165
|
+
status: 200,
|
|
166
|
+
headers: jsonHeaders(),
|
|
167
|
+
body: JSON.stringify(collection(people)),
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (pathname === 'tasks') {
|
|
172
|
+
const query = Object.fromEntries(url.searchParams);
|
|
173
|
+
taskQueries.push(query);
|
|
174
|
+
const filtered = query.taskStatus
|
|
175
|
+
? opportunities.filter(item => item.taskStatus['@id'] === query.taskStatus)
|
|
176
|
+
: opportunities;
|
|
177
|
+
|
|
178
|
+
return route.fulfill({
|
|
179
|
+
status: 200,
|
|
180
|
+
headers: jsonHeaders(),
|
|
181
|
+
body: JSON.stringify(collection(filtered)),
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (pathname === 'menus-people') {
|
|
186
|
+
return route.fulfill({
|
|
187
|
+
status: 200,
|
|
188
|
+
headers: jsonHeaders(),
|
|
189
|
+
body: JSON.stringify({ modules: {} }),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (pathname === 'configs/discovery-configs') {
|
|
194
|
+
return route.fulfill({
|
|
195
|
+
status: 200,
|
|
196
|
+
headers: jsonHeaders(),
|
|
197
|
+
body: JSON.stringify({ configs: {} }),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return route.fulfill({
|
|
202
|
+
status: 200,
|
|
203
|
+
headers: jsonHeaders(),
|
|
204
|
+
body: JSON.stringify(collection([])),
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
await page.addInitScript(
|
|
209
|
+
({ version }) => {
|
|
210
|
+
localStorage.setItem(
|
|
211
|
+
'session',
|
|
212
|
+
JSON.stringify({
|
|
213
|
+
id: 19,
|
|
214
|
+
people: 19,
|
|
215
|
+
api_key: 'test-api-key',
|
|
216
|
+
active: 1,
|
|
217
|
+
mycompany: 2,
|
|
218
|
+
roles: ['ROLE_SUPER'],
|
|
219
|
+
}),
|
|
220
|
+
);
|
|
221
|
+
localStorage.setItem('app-type', 'CRM');
|
|
222
|
+
localStorage.setItem('config', JSON.stringify({ language: 'pt-br' }));
|
|
223
|
+
localStorage.setItem(
|
|
224
|
+
'device',
|
|
225
|
+
JSON.stringify({
|
|
226
|
+
id: 'web-crm',
|
|
227
|
+
device: 'web-crm',
|
|
228
|
+
type: 'WEB',
|
|
229
|
+
appName: 'Browser CRM',
|
|
230
|
+
appVersion: version,
|
|
231
|
+
buildNumber: version,
|
|
232
|
+
systemName: 'web',
|
|
233
|
+
systemVersion: 'web',
|
|
234
|
+
deviceType: 'web',
|
|
235
|
+
metadata: {},
|
|
236
|
+
}),
|
|
237
|
+
);
|
|
238
|
+
},
|
|
239
|
+
{ version: appVersion },
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
return taskQueries;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
test.describe('crm opportunities status filter', () => {
|
|
246
|
+
test('keeps all selected and reloads without status filter', async ({ page }) => {
|
|
247
|
+
const taskQueries = await mockCrmApi(page);
|
|
248
|
+
|
|
249
|
+
await page.goto('/crm-index');
|
|
250
|
+
|
|
251
|
+
await expect(page.getByText('OPORTUNIDADE ABERTA')).toBeVisible();
|
|
252
|
+
await expect
|
|
253
|
+
.poll(() => taskQueries.some(query => query.taskStatus === '/statuses/1'))
|
|
254
|
+
.toBe(true);
|
|
255
|
+
|
|
256
|
+
await page.getByText(/^(All|Todos)$/).click();
|
|
257
|
+
|
|
258
|
+
await expect(page.getByText('OPORTUNIDADE FECHADA')).toBeVisible();
|
|
259
|
+
await expect
|
|
260
|
+
.poll(() => taskQueries.some(query => !Object.hasOwn(query, 'taskStatus')))
|
|
261
|
+
.toBe(true);
|
|
262
|
+
});
|
|
263
|
+
});
|