-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-clients.js
More file actions
265 lines (255 loc) Β· 11.6 KB
/
test-clients.js
File metadata and controls
265 lines (255 loc) Β· 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/usr/bin/env node
/**
* Comprehensive Client Test for Logo Objects REST API Client SDK
*
* This script validates:
* - Individual client class imports
* - LogoApiClient integration
* - All entity clients accessibility
* - Method availability on all clients
*
* Usage: node test-clients.js
*/
const {
LogoApiClient,
AdditionalTaxesClient,
ArpGroupAssignmentsClient,
ArpMLDescriptionsClient,
ArpsClient,
ArpShipmentLocationClient,
ArpSlipsClient,
AuthorizationCodesClient,
BankAccountsClient,
BankCreditClient,
BankMLDescriptionClient,
BankSlipClient,
BomStandardCostsClient,
BomsClient,
BanksClient,
CAPIClient,
CharacteristicsClient,
CharacteristicSetsClient,
ChequeAndPnoteRollsClient,
ChequeAndPnotesClient,
CitiesClient,
CollateralRollsClient,
ContactsClient,
CostDistributionSlipsClient,
CountriesClient,
CustomerMLDescriptionsClient,
CustomersClient,
CustomersOfSalesmenClient,
CustomsOfficesClient,
DbInfoClient,
DefinitionsClient,
DeliveryCodesClient,
DemandPeggingsClient,
DemandSlipsClient,
DistributionOrdersClient,
DistributionRoutesClient,
DistributionTemplatesClient,
DistrictsClient,
EmployeeCostsClient,
EmployeeGroupsClient,
EmployeeStandardCostsClient,
EmployeesClient,
EngineeringChangesClient,
ExportCreditLettersClient,
ExportCreditsClient,
ExportMovementSlipsClient,
GLAccountsClient,
ItemsClient,
OpportunitiesClient,
ProjectsClient,
PurchaseInvoicesClient,
PurchaseOrdersClient,
SalesInvoicesClient,
SalesOrdersClient,
SpecialCodesClient,
UnitSetsClient,
WorkstationStandardCostsClient,
} = require('./dist/index.js');
console.log('π§ͺ Testing Logo API Client SDK - All Clients\n');
// Test individual client imports
console.log('π¦ Testing individual client imports:');
const clients = [
{ name: 'AdditionalTaxesClient', client: AdditionalTaxesClient },
{ name: 'ArpGroupAssignmentsClient', client: ArpGroupAssignmentsClient },
{ name: 'ArpMLDescriptionsClient', client: ArpMLDescriptionsClient },
{ name: 'ArpsClient', client: ArpsClient },
{ name: 'ArpShipmentLocationClient', client: ArpShipmentLocationClient },
{ name: 'ArpSlipsClient', client: ArpSlipsClient },
{ name: 'AuthorizationCodesClient', client: AuthorizationCodesClient },
{ name: 'BankAccountsClient', client: BankAccountsClient },
{ name: 'BankCreditClient', client: BankCreditClient },
{ name: 'BankMLDescriptionClient', client: BankMLDescriptionClient },
{ name: 'BankSlipClient', client: BankSlipClient },
{ name: 'BomStandardCostsClient', client: BomStandardCostsClient },
{ name: 'BomsClient', client: BomsClient },
{ name: 'BanksClient', client: BanksClient },
{ name: 'CAPIClient', client: CAPIClient },
{ name: 'CharacteristicsClient', client: CharacteristicsClient },
{ name: 'CharacteristicSetsClient', client: CharacteristicSetsClient },
{ name: 'ChequeAndPnoteRollsClient', client: ChequeAndPnoteRollsClient },
{ name: 'ChequeAndPnotesClient', client: ChequeAndPnotesClient },
{ name: 'CitiesClient', client: CitiesClient },
{ name: 'CollateralRollsClient', client: CollateralRollsClient },
{ name: 'ContactsClient', client: ContactsClient },
{ name: 'CostDistributionSlipsClient', client: CostDistributionSlipsClient },
{ name: 'CountriesClient', client: CountriesClient },
{ name: 'CustomerMLDescriptionsClient', client: CustomerMLDescriptionsClient },
{ name: 'CustomersClient', client: CustomersClient },
{ name: 'CustomersOfSalesmenClient', client: CustomersOfSalesmenClient },
{ name: 'CustomsOfficesClient', client: CustomsOfficesClient },
{ name: 'DbInfoClient', client: DbInfoClient },
{ name: 'DefinitionsClient', client: DefinitionsClient },
{ name: 'DeliveryCodesClient', client: DeliveryCodesClient },
{ name: 'DemandPeggingsClient', client: DemandPeggingsClient },
{ name: 'DemandSlipsClient', client: DemandSlipsClient },
{ name: 'DistributionOrdersClient', client: DistributionOrdersClient },
{ name: 'DistributionRoutesClient', client: DistributionRoutesClient },
{ name: 'DistributionTemplatesClient', client: DistributionTemplatesClient },
{ name: 'DistrictsClient', client: DistrictsClient },
{ name: 'EmployeeCostsClient', client: EmployeeCostsClient },
{ name: 'EmployeeGroupsClient', client: EmployeeGroupsClient },
{ name: 'EmployeeStandardCostsClient', client: EmployeeStandardCostsClient },
{ name: 'EmployeesClient', client: EmployeesClient },
{ name: 'EngineeringChangesClient', client: EngineeringChangesClient },
{ name: 'ExportCreditLettersClient', client: ExportCreditLettersClient },
{ name: 'ExportCreditsClient', client: ExportCreditsClient },
{ name: 'ExportMovementSlipsClient', client: ExportMovementSlipsClient },
{ name: 'GLAccountsClient', client: GLAccountsClient },
{ name: 'ItemsClient', client: ItemsClient },
{ name: 'OpportunitiesClient', client: OpportunitiesClient },
{ name: 'ProjectsClient', client: ProjectsClient },
{ name: 'PurchaseInvoicesClient', client: PurchaseInvoicesClient },
{ name: 'PurchaseOrdersClient', client: PurchaseOrdersClient },
{ name: 'SalesInvoicesClient', client: SalesInvoicesClient },
{ name: 'SalesOrdersClient', client: SalesOrdersClient },
{ name: 'SpecialCodesClient', client: SpecialCodesClient },
{ name: 'UnitSetsClient', client: UnitSetsClient },
{ name: 'WorkstationStandardCostsClient', client: WorkstationStandardCostsClient },
];
clients.forEach(({ name, client }) => {
if (typeof client === 'function') {
console.log(`β
${name}: OK`);
} else {
console.log(`β ${name}: FAILED - not a constructor`);
}
});
// Test LogoApiClient integration
console.log('\nπ Testing LogoApiClient integration:');
try {
const config = {
baseURL: 'http://localhost:32001/api/v1',
apiKey: 'test-key',
};
const logoClient = new LogoApiClient(config);
console.log('β
LogoApiClient instantiated successfully');
// Test that all entity clients are available
const availableClients = logoClient.getAvailableClients();
console.log(`β
Available clients (${availableClients.length}):`, availableClients.join(', '));
// Test individual client access
const entityTests = [
{ name: 'additionalTaxes', client: logoClient.additionalTaxes },
{ name: 'arpGroupAssignments', client: logoClient.arpGroupAssignments },
{ name: 'arpMLDescriptions', client: logoClient.arpMLDescriptions },
{ name: 'arps', client: logoClient.arps },
{ name: 'arpShipmentLocations', client: logoClient.arpShipmentLocations },
{ name: 'arpSlips', client: logoClient.arpSlips },
{ name: 'authorizationCodes', client: logoClient.authorizationCodes },
{ name: 'bankAccounts', client: logoClient.bankAccounts },
{ name: 'bankCredits', client: logoClient.bankCredits },
{ name: 'bankMLDescriptions', client: logoClient.bankMLDescriptions },
{ name: 'bankSlips', client: logoClient.bankSlips },
{ name: 'bomStandardCosts', client: logoClient.bomStandardCosts },
{ name: 'boms', client: logoClient.boms },
{ name: 'banks', client: logoClient.banks },
{ name: 'capi', client: logoClient.capi },
{ name: 'characteristics', client: logoClient.characteristics },
{ name: 'characteristicSets', client: logoClient.characteristicSets },
{ name: 'chequeAndPnoteRolls', client: logoClient.chequeAndPnoteRolls },
{ name: 'chequeAndPnotes', client: logoClient.chequeAndPnotes },
{ name: 'cities', client: logoClient.cities },
{ name: 'collateralRolls', client: logoClient.collateralRolls },
{ name: 'contacts', client: logoClient.contacts },
{ name: 'costDistributionSlips', client: logoClient.costDistributionSlips },
{ name: 'countries', client: logoClient.countries },
{ name: 'customerMLDescriptions', client: logoClient.customerMLDescriptions },
{ name: 'customers', client: logoClient.customers },
{ name: 'customersOfSalesmen', client: logoClient.customersOfSalesmen },
{ name: 'customsOffices', client: logoClient.customsOffices },
{ name: 'dbinfo', client: logoClient.dbinfo },
{ name: 'definitions', client: logoClient.definitions },
{ name: 'deliveryCodes', client: logoClient.deliveryCodes },
{ name: 'demandPeggings', client: logoClient.demandPeggings },
{ name: 'demandSlips', client: logoClient.demandSlips },
{ name: 'distributionOrders', client: logoClient.distributionOrders },
{ name: 'distributionRoutes', client: logoClient.distributionRoutes },
{ name: 'distributionTemplates', client: logoClient.distributionTemplates },
{ name: 'districts', client: logoClient.districts },
{ name: 'employeeCosts', client: logoClient.employeeCosts },
{ name: 'employeeGroups', client: logoClient.employeeGroups },
{ name: 'employeeStandardCosts', client: logoClient.employeeStandardCosts },
{ name: 'employees', client: logoClient.employees },
{ name: 'engineeringChanges', client: logoClient.engineeringChanges },
{ name: 'exportCreditLetters', client: logoClient.exportCreditLetters },
{ name: 'exportCredits', client: logoClient.exportCredits },
{ name: 'exportMovementSlips', client: logoClient.exportMovementSlips },
{ name: 'GLAccounts', client: logoClient.GLAccounts },
{ name: 'items', client: logoClient.items },
{ name: 'opportunities', client: logoClient.opportunities },
{ name: 'projects', client: logoClient.projects },
{ name: 'purchaseInvoices', client: logoClient.purchaseInvoices },
{ name: 'purchaseOrders', client: logoClient.purchaseOrders },
{ name: 'salesInvoices', client: logoClient.salesInvoices },
{ name: 'salesOrders', client: logoClient.salesOrders },
{ name: 'specialCodes', client: logoClient.specialCodes },
{ name: 'unitSets', client: logoClient.unitSets },
{ name: 'workstationStandardCosts', client: logoClient.workstationStandardCosts },
];
console.log('\nπ― Testing entity client access:');
entityTests.forEach(({ name, client }) => {
if (name === 'dbinfo') {
// Special case for dbinfo client which is a utility client
if (client && typeof client.getDbInfo === 'function') {
console.log(`β
${name}: OK (has getDbInfo method)`);
} else {
console.log(`β ${name}: FAILED - missing or invalid`);
}
} else if (name === 'definitions') {
// Special case for definitions client which is a metadata client
if (client && typeof client.getEntityDefinition === 'function') {
console.log(`β
${name}: OK (has getEntityDefinition method)`);
} else {
console.log(`β ${name}: FAILED - missing or invalid`);
}
} else if (name === 'capi') {
// Special handling for CAPI client - it's a tracking client, not a CRUD client
if (
client &&
typeof client.trackFirms === 'function' &&
typeof client.getAllTrackingStatus === 'function'
) {
console.log(
`β
${name}: OK (tracking client with trackFirms and getAllTrackingStatus methods)`
);
} else {
console.log(`β ${name}: FAILED - missing tracking methods`);
}
} else if (client && typeof client.getAll === 'function') {
console.log(`β
${name}: OK (has getAll method)`);
} else {
console.log(`β ${name}: FAILED - missing or invalid`);
}
});
console.log('\nπ All tests completed successfully!');
console.log('\nπ Summary:');
console.log(`- Total entity clients: ${availableClients.length}`);
console.log('- All clients properly instantiated: β
');
console.log('- All clients accessible via LogoApiClient: β
');
console.log('- All clients have required methods: β
');
} catch (error) {
console.error('β Error during testing:', error.message);
process.exit(1);
}