-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-integration.mjs
More file actions
119 lines (103 loc) · 3.88 KB
/
test-integration.mjs
File metadata and controls
119 lines (103 loc) · 3.88 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
// SPDX-License-Identifier: PMPL-1.0-or-later
// Integration test for ReScript modules
import { make as makeMapper, captureExperience, loadAll, getExperienceCount,
findInterdisciplinary, groupByLocation, generateReport } from './src-rescript/Mapper.res.js';
async function runIntegrationTest() {
console.log('🧪 UbiCity Integration Test\n');
try {
// 1. Create mapper
console.log('1. Creating mapper...');
const mapper = await makeMapper('./ubicity-data-test');
console.log(' ✓ Mapper created');
// 2. Create a test experience
console.log('\n2. Creating test experience...');
const testExperience = {
id: 'test-001',
timestamp: new Date().toISOString(),
version: '1.0',
learner: {
id: 'learner-test',
name: 'Test Learner',
interests: ['testing', 'programming'],
},
context: {
location: {
name: 'Test Lab',
coordinates: { latitude: 45.5, longitude: -73.6 },
type: 'makerspace',
address: '123 Test St',
},
situation: 'Integration testing',
connections: ['mapper', 'storage'],
timeOfDay: 'afternoon',
},
experience: {
type: 'workshop',
description: 'Testing the ReScript integration',
domains: ['software', 'testing'],
outcome: {
success: true,
connections_made: ['mapper', 'decoder'],
next_questions: ['Does it all work together?'],
artifacts: ['test-integration.mjs'],
},
duration: 30,
intensity: 'medium',
},
privacy: {
level: 'public',
shareableWith: null,
},
tags: ['test', 'integration'],
};
// 3. Capture experience
console.log(' Creating experience...');
const result = await captureExperience(mapper, testExperience);
if (result.TAG === 'Ok') {
console.log(` ✓ Experience captured: ${result._0}`);
} else {
throw new Error(`Failed to capture: ${result._0}`);
}
// 4. Check count
console.log('\n3. Checking experience count...');
const count = getExperienceCount(mapper);
console.log(` ✓ Total experiences: ${count}`);
// 5. Load all experiences
console.log('\n4. Loading all experiences...');
const loadResult = await loadAll(mapper);
if (loadResult.TAG === 'Ok') {
console.log(` ✓ Loaded ${loadResult._0} experiences`);
} else {
throw new Error(`Failed to load: ${loadResult._0}`);
}
// 6. Run analysis
console.log('\n5. Running analysis...');
const interdisciplinary = findInterdisciplinary(mapper);
console.log(` ✓ Interdisciplinary experiences: ${interdisciplinary.length}`);
const byLocation = groupByLocation(mapper);
const locationCount = Object.keys(byLocation).length;
console.log(` ✓ Unique locations: ${locationCount}`);
// 7. Generate report
console.log('\n6. Generating report...');
const reportResult = await generateReport(mapper);
if (reportResult.TAG === 'Ok') {
const report = reportResult._0;
console.log(` ✓ Report generated:`);
console.log(` - Total: ${report.summary.totalExperiences}`);
console.log(` - Locations: ${report.summary.uniqueLocations}`);
console.log(` - Domains: ${report.summary.uniqueDomains}`);
console.log(` - Learners: ${report.summary.uniqueLearners}`);
console.log(` - Interdisciplinary: ${report.summary.interdisciplinaryExperiences}`);
console.log(` - Hotspots: ${report.learningHotspots.length}`);
} else {
throw new Error(`Failed to generate report: ${reportResult._0}`);
}
console.log('\n✅ All integration tests passed!');
return 0;
} catch (error) {
console.error('\n❌ Integration test failed:');
console.error(error);
return 1;
}
}
runIntegrationTest().then(code => process.exit(code));