Docs/Skills and code/tests/

tests/channel-evidence.test.js

Code56 lines3.5 KBtests/

import test from "node:test";
import assert from "node:assert/strict";
import { buildQualificationInput, normalizeQualification, buildSharedChannelEvidence } from "../src/analysis/channel-evidence.js";

const now = new Date("2026-10-12T00:00:00.000Z");

test("qualification input is bounded, deterministic, and fingerprints changed evidence", () => {
  const channel = { channel_url: "https://youtube.com/@systems", name: "Systems", description: "Technology education", keywords: ["systems design"], subscriber_count: 100, video_count: 50,
    videos: Array.from({ length: 40 }, (_, i) => ({ video_id: `v${i}`, title: `Title ${i}`, view_count: i * 100, published_at_normalized: `2026-01-${String(i % 28 + 1).padStart(2, "0")}`, published_at_precision: "exact_day" })) };
  const first = buildQualificationInput(channel);
  const second = buildQualificationInput({ ...channel, videos: [...channel.videos].reverse() });
  assert.equal(first.inputHash, second.inputHash);
  assert.ok(first.packet.representative_videos.length <= 14);
  const changed = buildQualificationInput({ ...channel, description: "Different channel description" });
  assert.notEqual(first.inputHash, changed.inputHash);
});

test("qualification fingerprint is stable when equal-date/equal-view source rows arrive in a different order", () => {
  const channel = {
    channel_url: "https://youtube.com/@ties", name: "Tie Test", description: "Technology education",
    keywords: ["systems design"],
    videos: Array.from({ length: 24 }, (_, i) => ({
      video_id: `tie-${i}`,
      title: `Project episode ${String(i).padStart(2, "0")}`,
      view_count: i < 12 ? 5000 : 1000,
      published_at_normalized: i < 12 ? "2026-01-01" : "2026-02-01",
      published_at_precision: "exact_day"
    }))
  };
  const first = buildQualificationInput(channel);
  const second = buildQualificationInput({ ...channel, videos: [...channel.videos].reverse() });
  assert.equal(first.inputHash, second.inputHash);
  assert.deepEqual(first.packet.representative_videos, second.packet.representative_videos);
});

test("low-confidence core/adjacent labels remain qualification-pending", () => {
  const core = normalizeQualification({ classification: "core", confidence: 0.4, source: "llm" }, { source: "llm" });
  const adjacent = normalizeQualification({ classification: "adjacent", confidence: 0.9, source: "llm" }, { source: "llm" });
  const unknown = normalizeQualification({ classification: "unknown", confidence: 0.99, source: "llm" }, { source: "llm" });
  assert.equal(core.eligibility, "qualification_pending");
  assert.equal(adjacent.eligibility, "eligible_adjacent");
  assert.equal(unknown.eligibility, "qualification_pending");
});

test("month-precision publication dates do not enter age-adjusted static performance", () => {
  const channel = { channel_url: "u", name: "Systems", joined_date: "2020-01-01", ecosystem_classification: "core",
    qualification_assessment: { classification: "core", confidence: 0.9, topic_tags: ["systems design"], source: "llm" },
    videos: [
      { video_id: "exact", title: "Exact", view_count: 5000, published_at_normalized: "2025-01-01", published_at_precision: "exact_day" },
      { video_id: "month", title: "Month", view_count: 5000, published_at_normalized: "2025-01-01", published_at_precision: "estimated_month" }
    ] };
  const features = buildSharedChannelEvidence(channel, now);
  assert.equal(features.videos.find(v => v.video_id === "exact").age_days != null, true);
  assert.equal(features.videos.find(v => v.video_id === "month").age_days, null);
});

Shown as it is in the repository at build time (2026-11-03); the home directory appears as <home>. If this page and the file differ, the file is right. Back to the catalogue.