Z User
phase7: MCP stdio smoke test (handshake + tools/list + get_roots 6:74) — 4/4 tests PASS
54a6341 Download tests/plugin.test.mjs from bravesigma/quran-md-plugin: direct link, hf CLI and curl.
- Browser
- Download file 2.16 kB
-
https://huggingface.co/datasets/bravesigma/quran-md-plugin/resolve/main/tests/plugin.test.mjs
- Command line
-
hf download hf://datasets/bravesigma/quran-md-plugin/tests/plugin.test.mjs
-
curl -L -o plugin.test.mjs https://huggingface.co/datasets/bravesigma/quran-md-plugin/resolve/main/tests/plugin.test.mjs
2.16 kB
| /** | |
| * Phase 7 tests for quran-md plugin v0.2.0 (node:test, no extra deps). | |
| * Uses QURAN_MD_LOCAL_DIR pointing at a local data repo checkout. | |
| */ | |
| import test from "node:test"; | |
| import assert from "node:assert/strict"; | |
| import * as fs from "node:fs"; | |
| import * as path from "node:path"; | |
| import { spawnSync } from "node:child_process"; | |
| const DATA_DIR = process.env.QURAN_MD_LOCAL_DIR || path.resolve("../hf-quran-md-data"); | |
| const PLUGIN_ROOT = path.resolve(import.meta.dirname, ".."); | |
| function runCli(args, env = {}) { | |
| const dist = path.join(PLUGIN_ROOT, "dist", "index.js"); | |
| if (!fs.existsSync(dist)) { | |
| return { status: 2, stdout: "", stderr: "dist/index.js missing — run `npm run build`" }; | |
| } | |
| return spawnSync(process.execPath, [dist, ...args], { | |
| encoding: "utf-8", | |
| env: { ...process.env, QURAN_MD_LOCAL_DIR: DATA_DIR, ...env }, | |
| timeout: 30000, | |
| }); | |
| } | |
| test("CLI verse fetch wraps provenance block", () => { | |
| const r = runCli(["6:74"]); | |
| assert.equal(r.status, 0, r.stderr); | |
| const data = JSON.parse(r.stdout); | |
| assert.equal(data.verse_key, "6:74"); | |
| assert.ok(data._provenance, "provenance block present"); | |
| assert.ok(data._provenance.grounding_rule.includes("verbatim"), "grounding rule stated"); | |
| }); | |
| test("CLI sources tool prints license manifest with per-source states", () => { | |
| const r = runCli(["sources"]); | |
| assert.equal(r.status, 0, r.stderr); | |
| const data = JSON.parse(r.stdout); | |
| assert.ok(data.sources.length >= 20); | |
| const almizan = data.sources.find((s) => s.id === "tafsir_al_mizan"); | |
| assert.equal(almizan.state, "exclude_until_resolved"); | |
| const almizanEn = data.sources.find((s) => s.id === "tafsir_al_mizan_translation_en"); | |
| assert.equal(almizanEn.state, "exclude_entirely"); | |
| }); | |
| test("compare_traditions includes positions, data_flags and consensus_level", () => { | |
| const r = runCli(["6:74"]); | |
| assert.equal(r.status, 0, r.stderr); | |
| const data = JSON.parse(r.stdout); | |
| assert.ok(Array.isArray(data.positions)); | |
| const sunniPos = data.positions.find((p) => p.tradition === "sunni"); | |
| assert.equal(sunniPos.verification, "verified"); | |
| assert.ok(sunniPos.consensus_level); | |
| }); | |