Builds PaperTrail from the base skeleton into a full evidence-verification platform for the "Built with Claude: Life Sciences" hackathon (Builder Track). New named-user features (Build Beyond the Bench): - Lab Notebook Companion — rough bench notes -> structured, searchable, grounded experiment records (lib/labNotebook, /console/lab-notebook, migration 0059) - Clinical Trial Matcher — de-identified patient notes -> ranked eligible ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning (lib/trialMatcher, /console/trial-matcher, migrations 0060) Platform: - Deterministic verification moat (biostats recompute, exact-span grounding) - 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar, PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier) - Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise governance (RBAC, /api/v1 gateway, metering, audit chain, retention) - 17 OSS projects assimilated into native TypeScript on our stack (backend/engines retained + credited in NOTICE) - Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site - Next.js 16 upgrade, benchmark harness (honest smoke-test caveat) Licensing: Apache-2.0 (LICENSE + NOTICE).
49 lines
1.9 KiB
TypeScript
49 lines
1.9 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
||
import { sanitizeClaimText } from "@/lib/api/claimInput";
|
||
|
||
const NUL = String.fromCharCode(0x00);
|
||
const BELL = String.fromCharCode(0x07);
|
||
const ESC = String.fromCharCode(0x1b);
|
||
const ZERO_WIDTH_SPACE = "";
|
||
const RLO = ""; // right-to-left override (bidi smuggling)
|
||
|
||
describe("sanitizeClaimText", () => {
|
||
it("accepts a normal claim and trims surrounding whitespace", () => {
|
||
const r = sanitizeClaimText(" Drug X reduced events by 30%. ");
|
||
expect(r).toEqual({ ok: true, value: "Drug X reduced events by 30%." });
|
||
});
|
||
|
||
it("preserves internal whitespace (tabs/newlines are legitimate)", () => {
|
||
const r = sanitizeClaimText("line one\n\tline two");
|
||
expect(r.ok && r.value).toBe("line one\n\tline two");
|
||
});
|
||
|
||
it("rejects non-string input", () => {
|
||
expect(sanitizeClaimText(undefined).ok).toBe(false);
|
||
expect(sanitizeClaimText(42 as unknown).ok).toBe(false);
|
||
});
|
||
|
||
it("rejects control characters (NUL / bell / escape)", () => {
|
||
expect(sanitizeClaimText(`hello${NUL}world`).ok).toBe(false);
|
||
expect(sanitizeClaimText(`hello${BELL}world`).ok).toBe(false);
|
||
expect(sanitizeClaimText(`hello${ESC}world`).ok).toBe(false);
|
||
});
|
||
|
||
it("strips invisible/bidi characters rather than rejecting the whole claim", () => {
|
||
const r = sanitizeClaimText(`Drug${ZERO_WIDTH_SPACE}X reduced${RLO} events`);
|
||
expect(r.ok).toBe(true);
|
||
expect(r.ok && r.value).toBe("DrugX reduced events");
|
||
});
|
||
|
||
it("rejects input that is empty once cleaned", () => {
|
||
expect(sanitizeClaimText(" ").ok).toBe(false);
|
||
expect(sanitizeClaimText(`${ZERO_WIDTH_SPACE}${ZERO_WIDTH_SPACE}`).ok).toBe(false);
|
||
});
|
||
|
||
it("rejects degenerate single-character repetition", () => {
|
||
expect(sanitizeClaimText("aaaaaaaaaaaaaaaa").ok).toBe(false);
|
||
// Short repeats are allowed (min/max length is the caller's job).
|
||
expect(sanitizeClaimText("aaaa").ok).toBe(true);
|
||
});
|
||
});
|