@vint.tri/report_gen_mcp 1.2.2 → 1.3.1

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.
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { generateReport } from './dist/utils/reportGenerator.js';
4
+ import fs from 'fs-extra';
5
+ import path from 'path';
6
+ import { fileURLToPath } from 'url';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+
11
+ // Test case 1: Correct format (should work)
12
+ console.log("Test 1: Correct format (should work)");
13
+ try {
14
+ const document = "# Test Report\n\nThis is a test report with a chart.\n\n[[chart:testchart]]";
15
+ const elements = {
16
+ testchart: {
17
+ type: "bar",
18
+ config: {
19
+ labels: ["A", "B", "C"],
20
+ datasets: [{
21
+ label: "Data",
22
+ data: [1, 2, 3],
23
+ backgroundColor: ["red", "green", "blue"],
24
+ borderColor: ["red", "green", "blue"]
25
+ }]
26
+ }
27
+ }
28
+ };
29
+
30
+ const outputPath = path.join(__dirname, 'test_correct_format.html');
31
+ const result = await generateReport(document, elements, outputPath);
32
+ console.log("✅ Success:", result);
33
+
34
+ // Read and display the generated file
35
+ const content = await fs.readFile(outputPath, 'utf8');
36
+ console.log("Generated content preview:");
37
+ console.log(content.substring(0, 500) + "...");
38
+ } catch (error) {
39
+ console.log("❌ Error:", error.message);
40
+ }
41
+
42
+ console.log("\n" + "=".repeat(50) + "\n");
43
+
44
+ // Test case 2: Incorrect format - elements as string (should fail)
45
+ console.log("Test 2: Incorrect format - elements as string (should fail)");
46
+ try {
47
+ const document = "# Test Report\n\nThis is a test report with a chart.\n\n[[chart:testchart]]";
48
+ // This is wrong - elements should be an object, not a string
49
+ const elements = JSON.stringify({
50
+ testchart: {
51
+ type: "bar",
52
+ config: {
53
+ labels: ["A", "B", "C"],
54
+ datasets: [{
55
+ label: "Data",
56
+ data: [1, 2, 3],
57
+ backgroundColor: ["red", "green", "blue"],
58
+ borderColor: ["red", "green", "blue"]
59
+ }]
60
+ }
61
+ }
62
+ });
63
+
64
+ const outputPath = path.join(__dirname, 'test_incorrect_format.html');
65
+ const result = await generateReport(document, elements, outputPath);
66
+ console.log("❌ Unexpected success:", result);
67
+ } catch (error) {
68
+ console.log("✅ Expected error:", error.message);
69
+ }
70
+
71
+ console.log("\n" + "=".repeat(50) + "\n");
72
+
73
+ // Test case 3: Incorrect format - colors as strings instead of arrays (should be fixed by normalization)
74
+ console.log("Test 3: Incorrect format - colors as strings instead of arrays (should be fixed by normalization)");
75
+ try {
76
+ const document = "# Test Report\n\nThis is a test report with a chart.\n\n[[chart:testchart]]";
77
+ const elements = {
78
+ testchart: {
79
+ type: "bar",
80
+ config: {
81
+ labels: ["A", "B", "C"],
82
+ datasets: [{
83
+ label: "Data",
84
+ data: [1, 2, 3],
85
+ // These are wrong - should be arrays, but normalization should fix them
86
+ backgroundColor: "red",
87
+ borderColor: "blue"
88
+ }]
89
+ }
90
+ }
91
+ };
92
+
93
+ const outputPath = path.join(__dirname, 'test_color_normalization.html');
94
+ const result = await generateReport(document, elements, outputPath);
95
+ console.log("✅ Success with normalization:", result);
96
+
97
+ // Read and display the generated file
98
+ const content = await fs.readFile(outputPath, 'utf8');
99
+ console.log("Generated content preview:");
100
+ console.log(content.substring(0, 500) + "...");
101
+ } catch (error) {
102
+ console.log("❌ Error:", error.message);
103
+ }
104
+
105
+ console.log("\nTest completed!");