Files
EnragedAntelopeandClaude Opus 4.8 77f268c4ec Initial commit: LoRA Slider node for ComfyUI (integrates with Lora Manager)
Self-contained ComfyUI custom node that adds per-LoRA bipolar strength
sliders with editable min/max, semantic end-labels, per-slider / bulk /
each-run randomization (locks respected), batch-add via a path-aware picker,
a paste/type text field, and Lora Pool folder import. Best-effort min/max
auto-fill parsed from Lora Manager's stored CivitAI descriptions. Outputs
LORA_STACK (+ trigger_words). Integrates with Lora Manager purely via its
public HTTP routes and shared ComfyUI types -- no LM modules imported.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 15:23:21 -04:00

57 lines
1.9 KiB
JavaScript

// Run with: node --test tests/strength_parser.test.mjs
// Verifies the JS parser mirror matches the Python parser behavior.
import { test } from "node:test";
import assert from "node:assert/strict";
import { parseStrengthHints } from "../web/strength_parser.js";
test("sample Slender Slider description", () => {
const r = parseStrengthHints(
"Strength: Safe zone (-3 - +2.5), it can be pushed beyond that for extreme " +
"ends of the weight spectrum. Higher is thinner."
);
assert.equal(r.min, -3);
assert.equal(r.max, 2.5);
assert.equal((r.highLabel || "").toLowerCase(), "thinner");
});
test("'to' separator", () => {
const r = parseStrengthHints("Recommended strength 0.5 to 1.2 for best results.");
assert.equal(r.min, 0.5);
assert.equal(r.max, 1.2);
});
test("tilde separator", () => {
const r = parseStrengthHints("weight ~ use -2~2");
assert.equal(r.min, -2);
assert.equal(r.max, 2);
});
test("html stripped", () => {
const r = parseStrengthHints("<p>Strength range: <b>-1.5</b> to <b>1.5</b></p>");
assert.equal(r.min, -1.5);
assert.equal(r.max, 1.5);
});
test("high/low labels", () => {
const r = parseStrengthHints("Strength 0 to 2. Higher is muscular and lower is skinny.");
assert.equal((r.highLabel || "").toLowerCase(), "muscular");
assert.equal((r.lowLabel || "").toLowerCase(), "skinny");
});
test("prefers range near keyword", () => {
const r = parseStrengthHints("Trained at 512-768 resolution. Strength: use -3 to 3.");
assert.equal(r.min, -3);
assert.equal(r.max, 3);
});
test("absurd range rejected", () => {
const r = parseStrengthHints("Trained on 1000-2000 images.");
assert.equal(r.min, undefined);
});
test("no match returns empty", () => {
assert.deepEqual(parseStrengthHints("A lovely style lora."), {});
assert.deepEqual(parseStrengthHints(""), {});
assert.deepEqual(parseStrengthHints(null), {});
});