File size: 2,141 Bytes
f88cb09
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
const { analyzePrintReadyStatus } = require('../engine/decisionKernel');
const { planActions } = require('../engine/planner');

async function testDecisionKernel() {
    console.log("๐Ÿงช Testing Decision Kernel & Planner Integration...");

    const session = {
        draftAttributes: { width: 100, height: 100 },
        cart: [],
        currentProduct: 'flyer'
    };

    // Case 1: Low Resolution
    const lowResData = {
        intent: 'quote',
        mapped_params: { dpi: 72, width_mm: 100, height_mm: 100 },
        _debug: { source: "Vision" }
    };
    const res1 = planActions(lowResData, session);
    const kernel1 = res1.actions[0].payload.text.includes("ืื™ื›ื•ืช ื ืžื•ื›ื”");
    console.log(`Case 1 (Low Res Rejection): ${kernel1 ? 'โœ… PASSED' : 'โŒ FAILED'}`);

    // Case 2: Dimension Mismatch
    const mismatchData = {
        intent: 'quote',
        mapped_params: { dpi: 300, width_mm: 150, height_mm: 150 }, // 50% mismatch
        _debug: { source: "Vision" }
    };
    const res2 = planActions(mismatchData, session);
    const kernel2 = res2.actions[0].payload.text.includes("ืื™ ื”ืชืืžื” ื‘ืžื™ื“ื•ืช");
    console.log(`Case 2 (Dimension Mismatch Rejection): ${kernel2 ? 'โœ… PASSED' : 'โŒ FAILED'}`);

    // Case 3: Ready for Print
    const validData = {
        intent: 'quote',
        mapped_params: { dpi: 300, width_mm: 102, height_mm: 98 }, // ~2% mismatch, should pass
        _debug: { source: "Vision" }
    };
    const res3 = planActions(validData, session);
    // Success if it DOES NOT contain a rejection message
    const rejectionKeywords = ["ืื™ื›ื•ืช ื ืžื•ื›ื”", "ืื™ ื”ืชืืžื”", "ืžืฉื”ื• ืœื ืœื’ืžืจื™ ืชืงื™ืŸ"];
    const kernel3 = !rejectionKeywords.some(k => res3.actions[0].payload && res3.actions[0].payload.text && res3.actions[0].payload.text.includes(k));
    console.log(`Case 3 (Ready for Print): ${kernel3 ? 'โœ… PASSED' : 'โŒ FAILED'}`);

    if (kernel1 && kernel2 && kernel3) {
        console.log("\nโœจ ALL KERNEL TESTS PASSED!");
    } else {
        console.error("\nโŒ TESTS FAILED!");
        process.exit(1);
    }
}

testDecisionKernel();