116 lines
3.5 KiB
JavaScript
116 lines
3.5 KiB
JavaScript
const assert = require('assert')
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
const repoRoot = path.resolve(__dirname, '..')
|
|
const skillRoot = path.join(
|
|
repoRoot,
|
|
'examples',
|
|
'monitoring_action_detect_preview_anchor_2026-04-21',
|
|
'skills',
|
|
'command-center-fee-control-monitor'
|
|
)
|
|
const scriptPath = path.join(skillRoot, 'scripts', 'detect_preview.js')
|
|
const fixturesPath = path.join(
|
|
repoRoot,
|
|
'tests',
|
|
'fixtures',
|
|
'generated_scene',
|
|
'monitoring_action_mock_validation_fixtures_2026-04-22.json'
|
|
)
|
|
const resultsPath = path.join(
|
|
repoRoot,
|
|
'tests',
|
|
'fixtures',
|
|
'generated_scene',
|
|
'monitoring_action_mock_validation_results_2026-04-22.json'
|
|
)
|
|
|
|
const {
|
|
buildBrowserEntrypointResult,
|
|
assertPreviewOnly
|
|
} = require(scriptPath)
|
|
|
|
async function main() {
|
|
const fixtures = JSON.parse(fs.readFileSync(fixturesPath, 'utf8'))
|
|
const sideEffectCounters = {
|
|
repetCtrlSend: 0,
|
|
sendMessages: 0,
|
|
callOutLogin: 0,
|
|
audioPlay: 0,
|
|
exeTQueue: 0,
|
|
productionLogWrite: 0
|
|
}
|
|
|
|
const artifact = await buildBrowserEntrypointResult({
|
|
mode: 'detect_preview',
|
|
expected_domain: '',
|
|
operator: 'mock-operator'
|
|
}, {
|
|
localStorage: {
|
|
getItem(key) {
|
|
return `mock-${key}`
|
|
}
|
|
},
|
|
previewData: fixtures,
|
|
sideEffects: {
|
|
repetCtrlSend() { sideEffectCounters.repetCtrlSend += 1 },
|
|
sendMessages() { sideEffectCounters.sendMessages += 1 },
|
|
callOutLogin() { sideEffectCounters.callOutLogin += 1 },
|
|
audioPlay() { sideEffectCounters.audioPlay += 1 },
|
|
exeTQueue() { sideEffectCounters.exeTQueue += 1 },
|
|
productionLogWrite() { sideEffectCounters.productionLogWrite += 1 }
|
|
}
|
|
})
|
|
|
|
assert.equal(artifact.type, 'monitoring-preview-artifact')
|
|
assert.equal(artifact.status, 'preview-ok')
|
|
assert.equal(artifact.mode, 'detect_preview')
|
|
assert.ok(Array.isArray(artifact.pendingList))
|
|
assert.ok(Array.isArray(artifact.notifyCandidates))
|
|
assert.ok(Array.isArray(artifact.actionPlan))
|
|
assert.ok(artifact.actionPlan.length >= 1)
|
|
assert.ok(artifact.blockedSideEffects.blockedCallSignatures.includes('repetCtrlSend'))
|
|
assert.ok(artifact.blockedSideEffects.blockedCallSignatures.includes('mac.sendMessages'))
|
|
assert.equal(artifact.summary.pending_count, 1)
|
|
assert.equal(artifact.summary.notify_count, 1)
|
|
|
|
for (const [name, count] of Object.entries(sideEffectCounters)) {
|
|
assert.equal(count, 0, `side effect ${name} should not execute`)
|
|
}
|
|
|
|
let blockedMode = false
|
|
try {
|
|
assertPreviewOnly('execute_dispatch_confirmed')
|
|
} catch (error) {
|
|
blockedMode = /blocked/.test(String(error.message))
|
|
}
|
|
assert.equal(blockedMode, true)
|
|
|
|
const result = {
|
|
status: 'mock-validation-pass',
|
|
family: 'monitoring_action_workflow',
|
|
mode: 'detect_preview',
|
|
artifactStatus: artifact.status,
|
|
pendingCount: artifact.pendingList.length,
|
|
notifyCount: artifact.notifyCandidates.length,
|
|
actionPlanCount: artifact.actionPlan.length,
|
|
blockedCallSignatures: artifact.blockedSideEffects.blockedCallSignatures,
|
|
sideEffectCounters,
|
|
nonPreviewModeBlocked: blockedMode,
|
|
fixtures: path.relative(repoRoot, fixturesPath).replace(/\\/g, '/'),
|
|
skillRoot: path.relative(repoRoot, skillRoot).replace(/\\/g, '/')
|
|
}
|
|
fs.writeFileSync(resultsPath, JSON.stringify(result, null, 2) + '\n', 'utf8')
|
|
}
|
|
|
|
main().catch((error) => {
|
|
const result = {
|
|
status: 'mock-validation-fail',
|
|
error: String(error && error.stack ? error.stack : error)
|
|
}
|
|
fs.writeFileSync(resultsPath, JSON.stringify(result, null, 2) + '\n', 'utf8')
|
|
console.error(error)
|
|
process.exit(1)
|
|
})
|