slicejs-web-framework 2.0.0 → 2.0.3
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/Slice/Slice.js +1 -2
- package/api/index.js +124 -101
- package/package.json +1 -1
- package/src/Components/AppComponents/HomePage/HomePage.js +195 -195
- package/src/Components/components.js +27 -27
- package/src/sliceConfig.json +5 -6
- package/src/testing.js +888 -0
package/src/testing.js
ADDED
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🧪 Sistema de Testing para Slice.js
|
|
3
|
+
*
|
|
4
|
+
* Este archivo contiene métodos para testear la implementación del RouteRenderer
|
|
5
|
+
* y verificar que el sistema de gestión de componentes funciona correctamente.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Rutas reales de la aplicación para testing
|
|
9
|
+
const REAL_ROUTES = [
|
|
10
|
+
'/',
|
|
11
|
+
'/Playground',
|
|
12
|
+
'/Documentation',
|
|
13
|
+
'/Documentation/Slice',
|
|
14
|
+
'/Documentation/Commands',
|
|
15
|
+
'/Documentation/SliceConfig',
|
|
16
|
+
'/Documentation/Visual',
|
|
17
|
+
'/Documentation/Service',
|
|
18
|
+
'/Documentation/Structural',
|
|
19
|
+
'/Documentation/Themes',
|
|
20
|
+
'/Documentation/Routing',
|
|
21
|
+
'/Documentation/Installation',
|
|
22
|
+
'/Documentation/The-build-method',
|
|
23
|
+
'/Documentation/Components/Visual',
|
|
24
|
+
'/Documentation/Components/Visual/Card',
|
|
25
|
+
'/Documentation/Components/Visual/Button',
|
|
26
|
+
'/Documentation/Components/Visual/Switch',
|
|
27
|
+
'/Documentation/Components/Visual/Checkbox',
|
|
28
|
+
'/Documentation/Components/Visual/Input',
|
|
29
|
+
'/About',
|
|
30
|
+
'/404'
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
// Función para ejecutar tests desde la consola del navegador
|
|
34
|
+
window.testSliceImplementation = async function() {
|
|
35
|
+
console.log('🚀 Iniciando tests de Slice.js...\n');
|
|
36
|
+
|
|
37
|
+
if (!window.slice || !window.slice.router) {
|
|
38
|
+
console.error('❌ Slice.js no está inicializado. Asegúrate de que la aplicación esté cargada.');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const renderer = window.slice.router.routeRenderer;
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
// Ejecutar todos los tests
|
|
46
|
+
const results = await renderer.runAllTests();
|
|
47
|
+
|
|
48
|
+
// Ejecutar test de rendimiento con rutas reales
|
|
49
|
+
console.log('\n' + '='.repeat(50));
|
|
50
|
+
const performanceResults = await renderer.testPerformanceWithRealRoutes();
|
|
51
|
+
|
|
52
|
+
// Mostrar estadísticas finales
|
|
53
|
+
console.log('\n' + '='.repeat(50));
|
|
54
|
+
console.log('📈 ESTADÍSTICAS FINALES:');
|
|
55
|
+
const finalStats = renderer.getStats();
|
|
56
|
+
console.log(` Total componentes activos: ${finalStats.controllerStats.totalActiveComponents}`);
|
|
57
|
+
console.log(` Componentes huérfanos: ${finalStats.controllerStats.orphanedComponents}`);
|
|
58
|
+
console.log(` Componentes en pool: ${finalStats.totalPooledComponents}`);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
testResults: results,
|
|
62
|
+
performanceResults,
|
|
63
|
+
finalStats
|
|
64
|
+
};
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error('❌ Error durante los tests:', error);
|
|
67
|
+
return { error: error.message };
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Función para monitorear componentes en tiempo real
|
|
72
|
+
window.monitorComponents = function() {
|
|
73
|
+
if (!window.slice) {
|
|
74
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const renderer = window.slice.router.routeRenderer;
|
|
79
|
+
const stats = renderer.getStats();
|
|
80
|
+
|
|
81
|
+
console.log('📊 MONITOREO DE COMPONENTES:');
|
|
82
|
+
console.log(` Total activos: ${stats.controllerStats.totalActiveComponents}`);
|
|
83
|
+
console.log(` Huérfanos: ${stats.controllerStats.orphanedComponents}`);
|
|
84
|
+
console.log(` En pool: ${stats.totalPooledComponents}`);
|
|
85
|
+
|
|
86
|
+
if (stats.controllerStats.orphanedComponents > 0) {
|
|
87
|
+
console.log(' 🧹 Componentes huérfanos encontrados:');
|
|
88
|
+
stats.controllerStats.orphanedComponentIds.forEach(id => {
|
|
89
|
+
console.log(` - ${id}`);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
console.log('\n 📋 Por tipo:');
|
|
94
|
+
Object.entries(stats.controllerStats.activeComponentsByType).forEach(([type, counts]) => {
|
|
95
|
+
console.log(` ${type}: ${counts.total} (${counts.connected} conectados, ${counts.orphaned} huérfanos)`);
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Función para limpiar componentes huérfanos manualmente
|
|
100
|
+
window.cleanupOrphanedComponents = function() {
|
|
101
|
+
if (!window.slice) {
|
|
102
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const renderer = window.slice.router.routeRenderer;
|
|
107
|
+
const cleanedCount = renderer.cleanupOrphanedComponents();
|
|
108
|
+
|
|
109
|
+
console.log(`🧹 Limpiados ${cleanedCount} componentes huérfanos.`);
|
|
110
|
+
return cleanedCount;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// Función para simular navegación y testear reutilización con rutas reales
|
|
114
|
+
window.testNavigation = async function() {
|
|
115
|
+
if (!window.slice) {
|
|
116
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
console.log('🧭 Test de navegación con rutas reales...');
|
|
121
|
+
|
|
122
|
+
const initialCount = window.slice.controller.activeComponents.size;
|
|
123
|
+
console.log(` Componentes iniciales: ${initialCount}`);
|
|
124
|
+
|
|
125
|
+
// Simular navegaciones con rutas reales
|
|
126
|
+
const testRoutes = ['/', '/Playground', '/Documentation', '/About', '/', '/Documentation/Slice'];
|
|
127
|
+
|
|
128
|
+
for (let i = 0; i < testRoutes.length; i++) {
|
|
129
|
+
const route = testRoutes[i];
|
|
130
|
+
console.log(` Navegando a: ${route}`);
|
|
131
|
+
|
|
132
|
+
const beforeCount = window.slice.controller.activeComponents.size;
|
|
133
|
+
window.slice.router.navigate(route);
|
|
134
|
+
|
|
135
|
+
// Esperar un poco para que se complete la navegación
|
|
136
|
+
await new Promise(resolve => setTimeout(resolve, 150));
|
|
137
|
+
|
|
138
|
+
const afterCount = window.slice.controller.activeComponents.size;
|
|
139
|
+
const created = afterCount - beforeCount;
|
|
140
|
+
|
|
141
|
+
if (created > 0) {
|
|
142
|
+
console.log(` ➕ Creados: ${created} componentes`);
|
|
143
|
+
} else {
|
|
144
|
+
console.log(` 🔄 Reutilizados componentes existentes`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const finalCount = window.slice.controller.activeComponents.size;
|
|
149
|
+
const totalCreated = finalCount - initialCount;
|
|
150
|
+
|
|
151
|
+
console.log(`\n📊 Resultado:`);
|
|
152
|
+
console.log(` Componentes iniciales: ${initialCount}`);
|
|
153
|
+
console.log(` Componentes finales: ${finalCount}`);
|
|
154
|
+
console.log(` Total creados: ${totalCreated}`);
|
|
155
|
+
console.log(` Eficiencia: ${(((testRoutes.length - totalCreated) / testRoutes.length) * 100).toFixed(1)}%`);
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
initialCount,
|
|
159
|
+
finalCount,
|
|
160
|
+
totalCreated,
|
|
161
|
+
efficiency: ((testRoutes.length - totalCreated) / testRoutes.length) * 100
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Función para testear navegación en rutas anidadas
|
|
166
|
+
window.testNestedRoutes = async function() {
|
|
167
|
+
if (!window.slice) {
|
|
168
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
console.log('🌳 Test de rutas anidadas...');
|
|
173
|
+
|
|
174
|
+
const initialCount = window.slice.controller.activeComponents.size;
|
|
175
|
+
console.log(` Componentes iniciales: ${initialCount}`);
|
|
176
|
+
|
|
177
|
+
// Test de navegación en rutas anidadas
|
|
178
|
+
const nestedRoutes = [
|
|
179
|
+
'/Documentation',
|
|
180
|
+
'/Documentation/Slice',
|
|
181
|
+
'/Documentation/Commands',
|
|
182
|
+
'/Documentation/Components/Visual',
|
|
183
|
+
'/Documentation/Components/Visual/Card',
|
|
184
|
+
'/Documentation/Components/Visual/Button',
|
|
185
|
+
'/Documentation/Components/Visual/Switch',
|
|
186
|
+
'/Documentation/Components/Visual/Checkbox',
|
|
187
|
+
'/Documentation/Components/Visual/Input'
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
let totalCreated = 0;
|
|
191
|
+
|
|
192
|
+
for (let i = 0; i < nestedRoutes.length; i++) {
|
|
193
|
+
const route = nestedRoutes[i];
|
|
194
|
+
console.log(` Navegando a: ${route}`);
|
|
195
|
+
|
|
196
|
+
const beforeCount = window.slice.controller.activeComponents.size;
|
|
197
|
+
window.slice.router.navigate(route);
|
|
198
|
+
|
|
199
|
+
// Esperar un poco más para rutas complejas
|
|
200
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
|
201
|
+
|
|
202
|
+
const afterCount = window.slice.controller.activeComponents.size;
|
|
203
|
+
const created = afterCount - beforeCount;
|
|
204
|
+
totalCreated += created;
|
|
205
|
+
|
|
206
|
+
if (created > 0) {
|
|
207
|
+
console.log(` ➕ Creados: ${created} componentes`);
|
|
208
|
+
} else {
|
|
209
|
+
console.log(` 🔄 Reutilizados componentes existentes`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const finalCount = window.slice.controller.activeComponents.size;
|
|
214
|
+
const actualCreated = finalCount - initialCount;
|
|
215
|
+
|
|
216
|
+
console.log(`\n📊 Resultado de rutas anidadas:`);
|
|
217
|
+
console.log(` Componentes iniciales: ${initialCount}`);
|
|
218
|
+
console.log(` Componentes finales: ${finalCount}`);
|
|
219
|
+
console.log(` Total creados: ${actualCreated}`);
|
|
220
|
+
console.log(` Eficiencia: ${(((nestedRoutes.length - actualCreated) / nestedRoutes.length) * 100).toFixed(1)}%`);
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
initialCount,
|
|
224
|
+
finalCount,
|
|
225
|
+
totalCreated: actualCreated,
|
|
226
|
+
efficiency: ((nestedRoutes.length - actualCreated) / nestedRoutes.length) * 100
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// Función para testear stress con rutas reales
|
|
231
|
+
window.stressTest = async function(iterations = 10) {
|
|
232
|
+
if (!window.slice) {
|
|
233
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
console.log(`💪 Test de stress con rutas reales (${iterations} iteraciones)...`);
|
|
238
|
+
|
|
239
|
+
const startTime = performance.now();
|
|
240
|
+
const initialCount = window.slice.controller.activeComponents.size;
|
|
241
|
+
|
|
242
|
+
// Usar rutas reales para el stress test
|
|
243
|
+
const routes = ['/', '/Playground', '/Documentation', '/About'];
|
|
244
|
+
|
|
245
|
+
for (let i = 0; i < iterations; i++) {
|
|
246
|
+
const route = routes[i % routes.length];
|
|
247
|
+
window.slice.router.navigate(route);
|
|
248
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const endTime = performance.now();
|
|
252
|
+
const finalCount = window.slice.controller.activeComponents.size;
|
|
253
|
+
const timeElapsed = endTime - startTime;
|
|
254
|
+
const componentsCreated = finalCount - initialCount;
|
|
255
|
+
|
|
256
|
+
console.log(`\n📊 Resultados del stress test:`);
|
|
257
|
+
console.log(` ⏱️ Tiempo total: ${timeElapsed.toFixed(2)}ms`);
|
|
258
|
+
console.log(` 📦 Componentes creados: ${componentsCreated}`);
|
|
259
|
+
console.log(` 🔄 Componentes reutilizados: ${iterations - componentsCreated}`);
|
|
260
|
+
console.log(` 📈 Eficiencia: ${(((iterations - componentsCreated) / iterations) * 100).toFixed(1)}%`);
|
|
261
|
+
console.log(` ⚡ Velocidad: ${(iterations / (timeElapsed / 1000)).toFixed(1)} navegaciones/segundo`);
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
timeElapsed,
|
|
265
|
+
componentsCreated,
|
|
266
|
+
componentsReused: iterations - componentsCreated,
|
|
267
|
+
efficiency: ((iterations - componentsCreated) / iterations) * 100,
|
|
268
|
+
speed: iterations / (timeElapsed / 1000)
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// Función para testear rutas específicas
|
|
273
|
+
window.testSpecificRoutes = async function(routes = null) {
|
|
274
|
+
if (!window.slice) {
|
|
275
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const routesToTest = routes || [
|
|
280
|
+
'/Documentation/Slice',
|
|
281
|
+
'/Documentation/Commands',
|
|
282
|
+
'/Documentation/Components/Visual/Card',
|
|
283
|
+
'/Documentation/Components/Visual/Button'
|
|
284
|
+
];
|
|
285
|
+
|
|
286
|
+
console.log(`🎯 Test de rutas específicas: ${routesToTest.join(', ')}`);
|
|
287
|
+
|
|
288
|
+
const initialCount = window.slice.controller.activeComponents.size;
|
|
289
|
+
const results = [];
|
|
290
|
+
|
|
291
|
+
for (let i = 0; i < routesToTest.length; i++) {
|
|
292
|
+
const route = routesToTest[i];
|
|
293
|
+
console.log(` Navegando a: ${route}`);
|
|
294
|
+
|
|
295
|
+
const beforeCount = window.slice.controller.activeComponents.size;
|
|
296
|
+
const startTime = performance.now();
|
|
297
|
+
|
|
298
|
+
window.slice.router.navigate(route);
|
|
299
|
+
await new Promise(resolve => setTimeout(resolve, 150));
|
|
300
|
+
|
|
301
|
+
const endTime = performance.now();
|
|
302
|
+
const afterCount = window.slice.controller.activeComponents.size;
|
|
303
|
+
const created = afterCount - beforeCount;
|
|
304
|
+
const timeElapsed = endTime - startTime;
|
|
305
|
+
|
|
306
|
+
results.push({
|
|
307
|
+
route,
|
|
308
|
+
created,
|
|
309
|
+
timeElapsed,
|
|
310
|
+
success: created >= 0 // Al menos no debería crear componentes negativos
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
if (created > 0) {
|
|
314
|
+
console.log(` ➕ Creados: ${created} componentes (${timeElapsed.toFixed(2)}ms)`);
|
|
315
|
+
} else {
|
|
316
|
+
console.log(` 🔄 Reutilizados (${timeElapsed.toFixed(2)}ms)`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const finalCount = window.slice.controller.activeComponents.size;
|
|
321
|
+
const totalCreated = finalCount - initialCount;
|
|
322
|
+
const successfulRoutes = results.filter(r => r.success).length;
|
|
323
|
+
|
|
324
|
+
console.log(`\n📊 Resultado de rutas específicas:`);
|
|
325
|
+
console.log(` Rutas exitosas: ${successfulRoutes}/${routesToTest.length}`);
|
|
326
|
+
console.log(` Componentes creados: ${totalCreated}`);
|
|
327
|
+
console.log(` Tiempo promedio: ${(results.reduce((sum, r) => sum + r.timeElapsed, 0) / results.length).toFixed(2)}ms`);
|
|
328
|
+
|
|
329
|
+
return {
|
|
330
|
+
results,
|
|
331
|
+
totalCreated,
|
|
332
|
+
successfulRoutes,
|
|
333
|
+
averageTime: results.reduce((sum, r) => sum + r.timeElapsed, 0) / results.length
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
// Función para testear todas las rutas disponibles
|
|
338
|
+
window.testAllRoutes = async function() {
|
|
339
|
+
if (!window.slice) {
|
|
340
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
console.log(`🌐 Test de todas las rutas disponibles (${REAL_ROUTES.length} rutas)...`);
|
|
345
|
+
|
|
346
|
+
const initialCount = window.slice.controller.activeComponents.size;
|
|
347
|
+
const results = [];
|
|
348
|
+
let successfulRoutes = 0;
|
|
349
|
+
let totalCreated = 0;
|
|
350
|
+
|
|
351
|
+
for (let i = 0; i < REAL_ROUTES.length; i++) {
|
|
352
|
+
const route = REAL_ROUTES[i];
|
|
353
|
+
console.log(` [${i + 1}/${REAL_ROUTES.length}] Navegando a: ${route}`);
|
|
354
|
+
|
|
355
|
+
const beforeCount = window.slice.controller.activeComponents.size;
|
|
356
|
+
const startTime = performance.now();
|
|
357
|
+
|
|
358
|
+
try {
|
|
359
|
+
window.slice.router.navigate(route);
|
|
360
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
361
|
+
|
|
362
|
+
const endTime = performance.now();
|
|
363
|
+
const afterCount = window.slice.controller.activeComponents.size;
|
|
364
|
+
const created = afterCount - beforeCount;
|
|
365
|
+
const timeElapsed = endTime - startTime;
|
|
366
|
+
|
|
367
|
+
totalCreated += created;
|
|
368
|
+
successfulRoutes++;
|
|
369
|
+
|
|
370
|
+
results.push({
|
|
371
|
+
route,
|
|
372
|
+
created,
|
|
373
|
+
timeElapsed,
|
|
374
|
+
success: true
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
if (created > 0) {
|
|
378
|
+
console.log(` ➕ Creados: ${created} componentes (${timeElapsed.toFixed(2)}ms)`);
|
|
379
|
+
} else {
|
|
380
|
+
console.log(` 🔄 Reutilizados (${timeElapsed.toFixed(2)}ms)`);
|
|
381
|
+
}
|
|
382
|
+
} catch (error) {
|
|
383
|
+
console.log(` ❌ Error: ${error.message}`);
|
|
384
|
+
results.push({
|
|
385
|
+
route,
|
|
386
|
+
created: 0,
|
|
387
|
+
timeElapsed: 0,
|
|
388
|
+
success: false,
|
|
389
|
+
error: error.message
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const finalCount = window.slice.controller.activeComponents.size;
|
|
395
|
+
const actualCreated = finalCount - initialCount;
|
|
396
|
+
|
|
397
|
+
console.log(`\n📊 Resultado de todas las rutas:`);
|
|
398
|
+
console.log(` Rutas exitosas: ${successfulRoutes}/${REAL_ROUTES.length}`);
|
|
399
|
+
console.log(` Componentes creados: ${actualCreated}`);
|
|
400
|
+
console.log(` Tiempo promedio: ${(results.filter(r => r.success).reduce((sum, r) => sum + r.timeElapsed, 0) / successfulRoutes).toFixed(2)}ms`);
|
|
401
|
+
console.log(` Eficiencia: ${(((REAL_ROUTES.length - actualCreated) / REAL_ROUTES.length) * 100).toFixed(1)}%`);
|
|
402
|
+
|
|
403
|
+
return {
|
|
404
|
+
results,
|
|
405
|
+
successfulRoutes,
|
|
406
|
+
totalCreated: actualCreated,
|
|
407
|
+
efficiency: ((REAL_ROUTES.length - actualCreated) / REAL_ROUTES.length) * 100
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// Función para mostrar ayuda
|
|
412
|
+
window.showTestingHelp = function() {
|
|
413
|
+
console.log(`
|
|
414
|
+
🧪 SISTEMA DE TESTING DE SLICE.JS
|
|
415
|
+
|
|
416
|
+
Comandos disponibles:
|
|
417
|
+
|
|
418
|
+
📋 testSliceImplementation()
|
|
419
|
+
Ejecuta todos los tests automáticamente
|
|
420
|
+
|
|
421
|
+
🧪 testSimple()
|
|
422
|
+
Test simple de funcionalidad básica
|
|
423
|
+
|
|
424
|
+
🔍 debugReuse()
|
|
425
|
+
Debug específico de reutilización de componentes
|
|
426
|
+
|
|
427
|
+
📊 monitorComponents()
|
|
428
|
+
Muestra estadísticas actuales de componentes
|
|
429
|
+
|
|
430
|
+
🧹 cleanupOrphanedComponents()
|
|
431
|
+
Limpia componentes huérfanos manualmente
|
|
432
|
+
|
|
433
|
+
🧭 testNavigation()
|
|
434
|
+
Test de navegación con rutas reales básicas
|
|
435
|
+
|
|
436
|
+
🌳 testNestedRoutes()
|
|
437
|
+
Test de rutas anidadas (Documentation/Components/...)
|
|
438
|
+
|
|
439
|
+
🎯 testSpecificRoutes([routes])
|
|
440
|
+
Test de rutas específicas personalizadas
|
|
441
|
+
|
|
442
|
+
🌐 testAllRoutes()
|
|
443
|
+
Test de todas las rutas disponibles
|
|
444
|
+
|
|
445
|
+
💪 stressTest(iterations)
|
|
446
|
+
Test de stress con múltiples navegaciones
|
|
447
|
+
|
|
448
|
+
🔍 checkAvailableComponents()
|
|
449
|
+
Verifica qué componentes están disponibles
|
|
450
|
+
|
|
451
|
+
🏊 debugComponentPool()
|
|
452
|
+
Debug del pool de componentes
|
|
453
|
+
|
|
454
|
+
🧪 testComponentPoolManually()
|
|
455
|
+
Test manual del pool de componentes
|
|
456
|
+
|
|
457
|
+
🧪 testWithAvailableComponents()
|
|
458
|
+
Test con componentes disponibles
|
|
459
|
+
|
|
460
|
+
📊 testWithStateTracking()
|
|
461
|
+
Test con seguimiento de estado antes/después
|
|
462
|
+
|
|
463
|
+
❓ showTestingHelp()
|
|
464
|
+
Muestra esta ayuda
|
|
465
|
+
|
|
466
|
+
Ejemplo de uso:
|
|
467
|
+
testSimple() // Test simple y rápido
|
|
468
|
+
debugReuse() // Debug específico de reutilización
|
|
469
|
+
testSliceImplementation() // Ejecutar todos los tests
|
|
470
|
+
testWithStateTracking() // Test con seguimiento de estado
|
|
471
|
+
debugComponentPool() // Debug del pool
|
|
472
|
+
testComponentPoolManually() // Test manual del pool
|
|
473
|
+
testNestedRoutes() // Test rutas anidadas
|
|
474
|
+
testSpecificRoutes(['/Documentation/Slice']) // Test ruta específica
|
|
475
|
+
testAllRoutes() // Test todas las rutas
|
|
476
|
+
stressTest(20) // Test de stress con 20 iteraciones
|
|
477
|
+
`);
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
// Función para verificar componentes disponibles
|
|
481
|
+
window.checkAvailableComponents = function() {
|
|
482
|
+
if (!window.slice) {
|
|
483
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
const availableComponents = Array.from(window.slice.controller.componentCategories.keys());
|
|
488
|
+
|
|
489
|
+
console.log('🔍 COMPONENTES DISPONIBLES:');
|
|
490
|
+
console.log(` Total: ${availableComponents.length} componentes`);
|
|
491
|
+
console.log('\n 📋 Lista completa:');
|
|
492
|
+
availableComponents.forEach((component, index) => {
|
|
493
|
+
console.log(` ${index + 1}. ${component}`);
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
// Verificar componentes críticos para los tests
|
|
497
|
+
const criticalComponents = ['Playground', 'Button', 'Input', 'Card'];
|
|
498
|
+
console.log('\n ✅ Componentes críticos para tests:');
|
|
499
|
+
criticalComponents.forEach(component => {
|
|
500
|
+
if (availableComponents.includes(component)) {
|
|
501
|
+
console.log(` ✅ ${component} - Disponible`);
|
|
502
|
+
} else {
|
|
503
|
+
console.log(` ❌ ${component} - No disponible`);
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
return availableComponents;
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// Función para testear con componentes disponibles
|
|
511
|
+
window.testWithAvailableComponents = async function() {
|
|
512
|
+
if (!window.slice) {
|
|
513
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const availableComponents = Array.from(window.slice.controller.componentCategories.keys());
|
|
518
|
+
|
|
519
|
+
if (availableComponents.length === 0) {
|
|
520
|
+
console.error('❌ No hay componentes disponibles para testing.');
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
console.log('🧪 Test con componentes disponibles...');
|
|
525
|
+
console.log(` Componentes disponibles: ${availableComponents.join(', ')}`);
|
|
526
|
+
|
|
527
|
+
// Usar el primer componente disponible para testing
|
|
528
|
+
const testComponent = availableComponents[0];
|
|
529
|
+
console.log(` Usando componente: ${testComponent}`);
|
|
530
|
+
|
|
531
|
+
const initialCount = window.slice.controller.activeComponents.size;
|
|
532
|
+
console.log(` Componentes iniciales: ${initialCount}`);
|
|
533
|
+
|
|
534
|
+
// Test de creación y reutilización
|
|
535
|
+
const testRoutes = [
|
|
536
|
+
{ path: '/test1', component: testComponent },
|
|
537
|
+
{ path: '/test2', component: testComponent },
|
|
538
|
+
{ path: '/test1', component: testComponent } // Debería reutilizar
|
|
539
|
+
];
|
|
540
|
+
|
|
541
|
+
for (let i = 0; i < testRoutes.length; i++) {
|
|
542
|
+
const route = testRoutes[i];
|
|
543
|
+
console.log(` Navegando a: ${route.path} (${route.component})`);
|
|
544
|
+
|
|
545
|
+
const beforeCount = window.slice.controller.activeComponents.size;
|
|
546
|
+
window.slice.router.routeRenderer.handleRoute(route, {});
|
|
547
|
+
|
|
548
|
+
// Esperar un poco para que se complete
|
|
549
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
550
|
+
|
|
551
|
+
const afterCount = window.slice.controller.activeComponents.size;
|
|
552
|
+
const created = afterCount - beforeCount;
|
|
553
|
+
|
|
554
|
+
if (created > 0) {
|
|
555
|
+
console.log(` ➕ Creados: ${created} componentes`);
|
|
556
|
+
} else {
|
|
557
|
+
console.log(` 🔄 Reutilizados componentes existentes`);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const finalCount = window.slice.controller.activeComponents.size;
|
|
562
|
+
const totalCreated = finalCount - initialCount;
|
|
563
|
+
|
|
564
|
+
console.log(`\n📊 Resultado:`);
|
|
565
|
+
console.log(` Componentes iniciales: ${initialCount}`);
|
|
566
|
+
console.log(` Componentes finales: ${finalCount}`);
|
|
567
|
+
console.log(` Total creados: ${totalCreated}`);
|
|
568
|
+
console.log(` Eficiencia: ${(((testRoutes.length - totalCreated) / testRoutes.length) * 100).toFixed(1)}%`);
|
|
569
|
+
|
|
570
|
+
return {
|
|
571
|
+
testComponent,
|
|
572
|
+
initialCount,
|
|
573
|
+
finalCount,
|
|
574
|
+
totalCreated,
|
|
575
|
+
efficiency: ((testRoutes.length - totalCreated) / testRoutes.length) * 100
|
|
576
|
+
};
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
// Función para debuggear el pool de componentes
|
|
580
|
+
window.debugComponentPool = function() {
|
|
581
|
+
if (!window.slice) {
|
|
582
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const renderer = window.slice.router.routeRenderer;
|
|
587
|
+
|
|
588
|
+
console.log('🔍 DEBUG DEL POOL DE COMPONENTES:');
|
|
589
|
+
console.log(` Tamaño máximo del pool: ${renderer.maxPoolSize}`);
|
|
590
|
+
console.log(` Pool actual:`);
|
|
591
|
+
|
|
592
|
+
if (renderer.componentPool.size === 0) {
|
|
593
|
+
console.log(' (vacío)');
|
|
594
|
+
} else {
|
|
595
|
+
for (const [componentName, pool] of renderer.componentPool.entries()) {
|
|
596
|
+
console.log(` ${componentName}: ${pool.length} componentes`);
|
|
597
|
+
pool.forEach((component, index) => {
|
|
598
|
+
console.log(` ${index + 1}. sliceId: ${component.sliceId || 'sin sliceId'}, connected: ${component.isConnected}`);
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
console.log(`\n Componentes activos en controller: ${window.slice.controller.activeComponents.size}`);
|
|
604
|
+
console.log(` Componentes activos en renderer: ${renderer.activeComponents.size}`);
|
|
605
|
+
|
|
606
|
+
return {
|
|
607
|
+
poolSize: renderer.componentPool.size,
|
|
608
|
+
totalPooledComponents: Array.from(renderer.componentPool.values()).reduce((total, pool) => total + pool.length, 0),
|
|
609
|
+
controllerActiveComponents: window.slice.controller.activeComponents.size,
|
|
610
|
+
rendererActiveComponents: renderer.activeComponents.size
|
|
611
|
+
};
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
// Función para testear el pool manualmente
|
|
615
|
+
window.testComponentPoolManually = async function() {
|
|
616
|
+
if (!window.slice) {
|
|
617
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const renderer = window.slice.router.routeRenderer;
|
|
622
|
+
|
|
623
|
+
console.log('🧪 Test manual del pool de componentes...');
|
|
624
|
+
|
|
625
|
+
// 1. Crear un componente
|
|
626
|
+
const component = await window.slice.build('Button', {
|
|
627
|
+
value: 'Pool Test',
|
|
628
|
+
sliceId: 'manual-pool-test'
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
console.log(` 1. Componente creado: ${component ? '✅' : '❌'}`);
|
|
632
|
+
console.log(` sliceId: ${component?.sliceId}`);
|
|
633
|
+
console.log(` tagName: ${component?.tagName}`);
|
|
634
|
+
console.log(` constructor: ${component?.constructor?.name}`);
|
|
635
|
+
|
|
636
|
+
// 2. Añadir al pool
|
|
637
|
+
const beforePoolSize = renderer.componentPool.size;
|
|
638
|
+
renderer.addToPool(component);
|
|
639
|
+
const afterPoolSize = renderer.componentPool.size;
|
|
640
|
+
|
|
641
|
+
console.log(` 2. Añadido al pool: ${afterPoolSize > beforePoolSize ? '✅' : '❌'}`);
|
|
642
|
+
console.log(` Pool size: ${beforePoolSize} -> ${afterPoolSize}`);
|
|
643
|
+
|
|
644
|
+
// 3. Verificar contenido del pool
|
|
645
|
+
debugComponentPool();
|
|
646
|
+
|
|
647
|
+
// 4. Obtener del pool
|
|
648
|
+
const retrievedComponent = renderer.getFromPool('button');
|
|
649
|
+
console.log(` 3. Obtenido del pool: ${retrievedComponent ? '✅' : '❌'}`);
|
|
650
|
+
console.log(` Componente recuperado: ${retrievedComponent === component ? '✅ mismo' : '❌ diferente'}`);
|
|
651
|
+
|
|
652
|
+
return {
|
|
653
|
+
created: !!component,
|
|
654
|
+
addedToPool: afterPoolSize > beforePoolSize,
|
|
655
|
+
retrieved: !!retrievedComponent,
|
|
656
|
+
isSameComponent: retrievedComponent === component
|
|
657
|
+
};
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
// Función para ver estado antes y después de tests
|
|
661
|
+
window.testWithStateTracking = async function() {
|
|
662
|
+
if (!window.slice) {
|
|
663
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
console.log('📊 Test con seguimiento de estado...');
|
|
668
|
+
|
|
669
|
+
// Estado inicial
|
|
670
|
+
const initialState = {
|
|
671
|
+
controllerComponents: window.slice.controller.activeComponents.size,
|
|
672
|
+
rendererComponents: window.slice.router.routeRenderer.activeComponents.size,
|
|
673
|
+
poolSize: window.slice.router.routeRenderer.componentPool.size,
|
|
674
|
+
orphanedComponents: 0
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
// Contar componentes huérfanos
|
|
678
|
+
for (const [sliceId, component] of window.slice.controller.activeComponents.entries()) {
|
|
679
|
+
if (!component.isConnected && component !== window.slice.loading) {
|
|
680
|
+
initialState.orphanedComponents++;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
console.log('📈 Estado inicial:');
|
|
685
|
+
console.log(` Controller: ${initialState.controllerComponents} componentes`);
|
|
686
|
+
console.log(` Renderer: ${initialState.rendererComponents} componentes`);
|
|
687
|
+
console.log(` Pool: ${initialState.poolSize} tipos`);
|
|
688
|
+
console.log(` Huérfanos: ${initialState.orphanedComponents} componentes`);
|
|
689
|
+
|
|
690
|
+
// Ejecutar tests
|
|
691
|
+
console.log('\n🧪 Ejecutando tests...');
|
|
692
|
+
const results = await window.testSliceImplementation();
|
|
693
|
+
|
|
694
|
+
// Estado final
|
|
695
|
+
const finalState = {
|
|
696
|
+
controllerComponents: window.slice.controller.activeComponents.size,
|
|
697
|
+
rendererComponents: window.slice.router.routeRenderer.activeComponents.size,
|
|
698
|
+
poolSize: window.slice.router.routeRenderer.componentPool.size,
|
|
699
|
+
orphanedComponents: 0
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
// Contar componentes huérfanos finales
|
|
703
|
+
for (const [sliceId, component] of window.slice.controller.activeComponents.entries()) {
|
|
704
|
+
if (!component.isConnected && component !== window.slice.loading) {
|
|
705
|
+
finalState.orphanedComponents++;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
console.log('\n📉 Estado final:');
|
|
710
|
+
console.log(` Controller: ${finalState.controllerComponents} componentes (${finalState.controllerComponents - initialState.controllerComponents > 0 ? '+' : ''}${finalState.controllerComponents - initialState.controllerComponents})`);
|
|
711
|
+
console.log(` Renderer: ${finalState.rendererComponents} componentes (${finalState.rendererComponents - initialState.rendererComponents > 0 ? '+' : ''}${finalState.rendererComponents - initialState.rendererComponents})`);
|
|
712
|
+
console.log(` Pool: ${finalState.poolSize} tipos (${finalState.poolSize - initialState.poolSize > 0 ? '+' : ''}${finalState.poolSize - initialState.poolSize})`);
|
|
713
|
+
console.log(` Huérfanos: ${finalState.orphanedComponents} componentes (${finalState.orphanedComponents - initialState.orphanedComponents > 0 ? '+' : ''}${finalState.orphanedComponents - initialState.orphanedComponents})`);
|
|
714
|
+
|
|
715
|
+
// Análisis
|
|
716
|
+
console.log('\n🔍 Análisis:');
|
|
717
|
+
const controllerDiff = finalState.controllerComponents - initialState.controllerComponents;
|
|
718
|
+
const rendererDiff = finalState.rendererComponents - initialState.rendererComponents;
|
|
719
|
+
const orphanedDiff = finalState.orphanedComponents - initialState.orphanedComponents;
|
|
720
|
+
|
|
721
|
+
if (controllerDiff === 0 && rendererDiff === 0) {
|
|
722
|
+
console.log(' ✅ No se crearon componentes adicionales');
|
|
723
|
+
} else {
|
|
724
|
+
console.log(` ⚠️ Se crearon ${controllerDiff} componentes en controller, ${rendererDiff} en renderer`);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
if (orphanedDiff <= 0) {
|
|
728
|
+
console.log(' ✅ No hay componentes huérfanos adicionales');
|
|
729
|
+
} else {
|
|
730
|
+
console.log(` ❌ Se crearon ${orphanedDiff} componentes huérfanos adicionales`);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
return {
|
|
734
|
+
initialState,
|
|
735
|
+
finalState,
|
|
736
|
+
differences: {
|
|
737
|
+
controller: controllerDiff,
|
|
738
|
+
renderer: rendererDiff,
|
|
739
|
+
orphaned: orphanedDiff
|
|
740
|
+
},
|
|
741
|
+
testResults: results
|
|
742
|
+
};
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
// Función para test simple sin problemas complejos
|
|
746
|
+
window.testSimple = async function() {
|
|
747
|
+
if (!window.slice) {
|
|
748
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
console.log('🧪 Test simple de funcionalidad básica...');
|
|
753
|
+
|
|
754
|
+
const results = {
|
|
755
|
+
passed: 0,
|
|
756
|
+
failed: 0,
|
|
757
|
+
tests: []
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
// Test 1: Crear un componente simple
|
|
761
|
+
const sliceId = `simple-test-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
762
|
+
const component = await window.slice.build('Button', {
|
|
763
|
+
value: 'Simple Test',
|
|
764
|
+
sliceId: sliceId
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
if (component && component instanceof Node) {
|
|
768
|
+
results.passed++;
|
|
769
|
+
results.tests.push('✅ Componente se crea correctamente');
|
|
770
|
+
} else {
|
|
771
|
+
results.failed++;
|
|
772
|
+
results.tests.push('❌ Componente no se crea correctamente');
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// Test 2: Verificar que está en el controller
|
|
776
|
+
const controllerComponent = window.slice.controller.getComponent(sliceId);
|
|
777
|
+
if (controllerComponent === component) {
|
|
778
|
+
results.passed++;
|
|
779
|
+
results.tests.push('✅ Componente está en el controller');
|
|
780
|
+
} else {
|
|
781
|
+
results.failed++;
|
|
782
|
+
results.tests.push('❌ Componente no está en el controller');
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// Test 3: Verificar que se puede obtener
|
|
786
|
+
const retrievedComponent = window.slice.controller.getComponent(sliceId);
|
|
787
|
+
if (retrievedComponent) {
|
|
788
|
+
results.passed++;
|
|
789
|
+
results.tests.push('✅ Componente se puede obtener');
|
|
790
|
+
} else {
|
|
791
|
+
results.failed++;
|
|
792
|
+
results.tests.push('❌ Componente no se puede obtener');
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// Test 4: Verificar que se puede destruir
|
|
796
|
+
const beforeCount = window.slice.controller.activeComponents.size;
|
|
797
|
+
window.slice.router.routeRenderer.destroyComponent(component);
|
|
798
|
+
const afterCount = window.slice.controller.activeComponents.size;
|
|
799
|
+
|
|
800
|
+
if (afterCount < beforeCount) {
|
|
801
|
+
results.passed++;
|
|
802
|
+
results.tests.push('✅ Componente se destruye correctamente');
|
|
803
|
+
} else {
|
|
804
|
+
results.failed++;
|
|
805
|
+
results.tests.push('❌ Componente no se destruye correctamente');
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// Mostrar resultados
|
|
809
|
+
console.log('\n📊 Resultados del test simple:');
|
|
810
|
+
console.log(` ✅ Pasados: ${results.passed}`);
|
|
811
|
+
console.log(` ❌ Fallidos: ${results.failed}`);
|
|
812
|
+
results.tests.forEach(test => console.log(` ${test}`));
|
|
813
|
+
|
|
814
|
+
return results;
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
// Función para debug específico de reutilización
|
|
818
|
+
window.debugReuse = async function() {
|
|
819
|
+
if (!window.slice) {
|
|
820
|
+
console.error('❌ Slice.js no está inicializado.');
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
console.log('🔍 Debug específico de reutilización...');
|
|
825
|
+
|
|
826
|
+
const sliceId = `debug-reuse-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
827
|
+
|
|
828
|
+
// Paso 1: Crear componente
|
|
829
|
+
console.log(`Paso 1: Creando componente con sliceId: ${sliceId}`);
|
|
830
|
+
const component1 = await window.slice.router.routeRenderer.getOrCreateComponent('Button', sliceId, {
|
|
831
|
+
value: 'Debug Test'
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
if (!component1) {
|
|
835
|
+
console.error('❌ No se pudo crear el componente');
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
console.log(` Componente creado: ${component1.constructor.name}`);
|
|
840
|
+
console.log(` sliceId: ${component1.sliceId}`);
|
|
841
|
+
console.log(` Está en controller: ${window.slice.controller.getComponent(sliceId) ? 'Sí' : 'No'}`);
|
|
842
|
+
|
|
843
|
+
// Paso 2: Verificar en controller
|
|
844
|
+
const controllerComponent = window.slice.controller.getComponent(sliceId);
|
|
845
|
+
console.log(`Paso 2: Verificando controller`);
|
|
846
|
+
console.log(` Componente en controller: ${controllerComponent ? controllerComponent.constructor.name : 'null'}`);
|
|
847
|
+
console.log(` Son iguales: ${component1 === controllerComponent}`);
|
|
848
|
+
|
|
849
|
+
// Paso 3: Intentar reutilizar
|
|
850
|
+
console.log(`Paso 3: Intentando reutilizar`);
|
|
851
|
+
const beforeCount = window.slice.controller.activeComponents.size;
|
|
852
|
+
const component2 = await window.slice.router.routeRenderer.getOrCreateComponent('Button', sliceId, {
|
|
853
|
+
value: 'Debug Test Updated'
|
|
854
|
+
});
|
|
855
|
+
const afterCount = window.slice.controller.activeComponents.size;
|
|
856
|
+
|
|
857
|
+
console.log(` Contador: ${beforeCount} -> ${afterCount}`);
|
|
858
|
+
console.log(` Componente 2: ${component2 ? component2.constructor.name : 'null'}`);
|
|
859
|
+
console.log(` Son iguales: ${component1 === component2}`);
|
|
860
|
+
|
|
861
|
+
// Análisis
|
|
862
|
+
console.log(`\n📊 Análisis:`);
|
|
863
|
+
if (component1 === component2) {
|
|
864
|
+
console.log(` ✅ Reutilización funciona`);
|
|
865
|
+
} else {
|
|
866
|
+
console.log(` ❌ Reutilización falla`);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
if (beforeCount === afterCount) {
|
|
870
|
+
console.log(` ✅ No se crearon componentes adicionales`);
|
|
871
|
+
} else {
|
|
872
|
+
console.log(` ❌ Se crearon ${afterCount - beforeCount} componentes adicionales`);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// Limpiar
|
|
876
|
+
window.slice.router.routeRenderer.destroyComponent(component1);
|
|
877
|
+
|
|
878
|
+
return {
|
|
879
|
+
component1,
|
|
880
|
+
component2,
|
|
881
|
+
areEqual: component1 === component2,
|
|
882
|
+
countDiff: afterCount - beforeCount
|
|
883
|
+
};
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
// Auto-ejecutar ayuda cuando se carga el archivo
|
|
887
|
+
console.log('🧪 Sistema de testing de Slice.js cargado.');
|
|
888
|
+
console.log('💡 Usa showTestingHelp() para ver los comandos disponibles.');
|