#!/usr/bin/env node /* * Built-in plugin smoke validation script * Usage: * node test-scripts/plugins-smoke.js */ if (process.env.SKIP_SMOKE_TESTS === '1') { console.log('plugin smoke checks skipped (SKIP_SMOKE_TESTS=1)'); process.exit(0); } const targets = { peerDirectory: process.env.PEER_DIRECTORY_URL || 'https://peer.directory', globalProfile: process.env.GLOBAL_PROFILE_URL || 'https://global.profile', fileDrop: process.env.FILE_DROP_URL || 'https://file.drop' }; async function checkPeerDirectory() { const response = await fetch(`${targets.peerDirectory}/domains?page=1&limit=25&sort=type`); const json = await response.json(); if (!response.ok) throw new Error(`peer.directory domains failed: ${response.status}`); if (!Array.isArray(json.domains)) throw new Error('peer.directory domains payload missing domains[]'); } async function checkGlobalProfile() { const response = await fetch(`${targets.globalProfile}/api/profiles?page=1&limit=10`); const json = await response.json(); if (!response.ok) throw new Error(`global.profile profiles failed: ${response.status}`); if (!Array.isArray(json.profiles)) throw new Error('global.profile payload missing profiles[]'); } async function checkFileDrop() { const response = await fetch(`${targets.fileDrop}/api/files`); const json = await response.json(); if (!response.ok) throw new Error(`file.drop files failed: ${response.status}`); if (!Array.isArray(json.files)) throw new Error('file.drop payload missing files[]'); } async function run() { await checkPeerDirectory(); await checkGlobalProfile(); await checkFileDrop(); console.log('plugin smoke checks passed'); } run().catch((err) => { console.error(`plugin smoke checks failed: ${err.message}`); process.exit(1); });