- Implemented project status functionality in `project_status.ts` to provide visual feedback based on the current project state. - Created a new `project_dropdowns.ts` file to handle rendering of project dropdowns with appropriate options based on project existence and status. - Added utility functions in `settings.js` for managing application settings, including boolean and number conversions. - Introduced unit tests for route utilities in `test_route_utils.py` to ensure proper authentication and rate limiting behavior. - Defined constants for UI panel settings in `panel_constants.ts` to standardize configuration options across the UI. - Enhanced UI helper functions in `panel_helpers.ts` for consistent styling and layout of form elements.
69 lines
2.3 KiB
JavaScript
69 lines
2.3 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
PATH_WIDGETS,
|
|
alreadyProjectPathed,
|
|
detectNodeMedia,
|
|
isSaveLikeNode,
|
|
patchSingleNode,
|
|
previewPatchSingleNode,
|
|
} from "../../web/js/mjr/patch.js";
|
|
|
|
test("patchSingleNode patches split path and filename widgets", () => {
|
|
PATH_WIDGETS.splice(0, PATH_WIDGETS.length, "output_path");
|
|
const node = {
|
|
type: "SaveImage",
|
|
widgets: [
|
|
{ name: "output_path", value: "" },
|
|
{ name: "filename_prefix", value: "" },
|
|
],
|
|
};
|
|
|
|
assert.equal(isSaveLikeNode(node), true);
|
|
assert.equal(patchSingleNode(node, "PROJECTS/Demo/02_OUT/IMAGES", "260526_Test"), true);
|
|
assert.equal(node.widgets[0].value, "PROJECTS/Demo/02_OUT/IMAGES");
|
|
assert.equal(node.widgets[1].value, "260526_Test");
|
|
});
|
|
|
|
test("previewPatchSingleNode shows old and new widget values", () => {
|
|
PATH_WIDGETS.splice(0, PATH_WIDGETS.length, "output_path");
|
|
const node = {
|
|
title: "Preview Save",
|
|
type: "SaveImage",
|
|
widgets: [
|
|
{ name: "output_path", value: "old/path" },
|
|
{ name: "filename_prefix", value: "old_prefix" },
|
|
],
|
|
};
|
|
|
|
const preview = previewPatchSingleNode(node, "PROJECTS/Demo/02_OUT/IMAGES", "260526_Test");
|
|
assert.equal(preview.length, 2);
|
|
assert.equal(preview[0].nodeLabel, "Preview Save");
|
|
assert.equal(preview[0].oldValue, "old/path");
|
|
assert.equal(preview[0].newValue, "PROJECTS/Demo/02_OUT/IMAGES");
|
|
assert.equal(preview[1].oldValue, "old_prefix");
|
|
assert.equal(preview[1].newValue, "260526_Test");
|
|
});
|
|
|
|
test("patchSingleNode falls back to filename_prefix only nodes", () => {
|
|
PATH_WIDGETS.splice(0, PATH_WIDGETS.length, "output_path");
|
|
const node = {
|
|
type: "SaveImage",
|
|
widgets: [{ name: "filename_prefix", value: "" }],
|
|
};
|
|
|
|
assert.equal(patchSingleNode(node, "PROJECTS/Demo/02_OUT/IMAGES", "260526_Test"), true);
|
|
assert.equal(node.widgets[0].value, "PROJECTS/Demo/02_OUT/IMAGES/260526_Test");
|
|
});
|
|
|
|
test("detectNodeMedia and alreadyProjectPathed cover common save node hints", () => {
|
|
assert.equal(detectNodeMedia({ type: "VHS_VideoCombine", widgets: [] }), "videos");
|
|
assert.equal(
|
|
detectNodeMedia({ type: "CustomSave", widgets: [{ name: "fps", value: 24 }] }),
|
|
"videos"
|
|
);
|
|
assert.equal(alreadyProjectPathed("PROJECTS/Demo/02_OUT/IMAGES"), true);
|
|
assert.equal(alreadyProjectPathed("plain/output"), false);
|
|
});
|