mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-26 01:41:04 +08:00
Comments, doc comments, UI labels, log and error messages, LLM prompt strings, markdown docs, test data and assertions. Identifiers, enum keys, routes, placeholders and code structure are unchanged. Notes: - docs/漏洞流量证据.md renamed to docs/vulnerability-traffic-evidence.md - tests that exercised CJK specific handling (GBK zip names, Chinese full text search) now use ASCII equivalents; go build passes and the test suite matches the pre translation baseline (remaining failures need a PostgreSQL DSN and fail identically on the original) - frontend mention syntax now uses English kinds (finding, asset, ...) matching the backend, chat mentions tests pass
32 lines
1.7 KiB
JavaScript
32 lines
1.7 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { activeMention, mentionSearch, mentionToken, selectedMentions } from "./chat-mentions.ts";
|
|
|
|
test("mention trigger supports kind aliases and cursor placement without hijacking email", () => {
|
|
assert.equal(activeMention("user@example.com", 16), null);
|
|
assert.equal(activeMention("done @[finding#1 X]", 19), null);
|
|
assert.deepEqual(activeMention("look @finding more words", 13), { start: 5, end: 13, query: "finding" });
|
|
assert.equal(activeMention("@ip\nnext line", 14), null);
|
|
});
|
|
|
|
test("categories, kind aliases, IP and keyword search", () => {
|
|
assert.equal(mentionSearch("").categories.length, 9);
|
|
assert.equal(mentionSearch("f").categories[0].kind, "finding");
|
|
assert.equal(mentionSearch("finding").kind, "finding");
|
|
assert.equal(mentionSearch("finding SQL injection").query, "SQL injection");
|
|
assert.equal(mentionSearch("ip 192.0.2.1").kind, "ip");
|
|
assert.equal(mentionSearch("endpoint GET /api").query, "GET /api");
|
|
assert.equal(mentionSearch("acme.com").kind, "");
|
|
});
|
|
|
|
test("tokens roundtrip labels and removing one reference preserves its neighbors", () => {
|
|
const first = mentionToken({ kind: "finding", id: 12, label: "Title [1]\nDescription" });
|
|
const second = mentionToken({ kind: "ip", id: 13, label: "192.0.2.1" });
|
|
const value = `analyze ${first} and ${second}`;
|
|
const selected = selectedMentions(value);
|
|
assert.equal(selected.length, 2);
|
|
assert.equal(selected[0].label, "finding #12 · Title (1) Description");
|
|
const next = value.slice(0, selected[0].start) + value.slice(selected[0].start + selected[0].token.length);
|
|
assert.equal(selectedMentions(next)[0].token, second);
|
|
});
|