An outpaint whose new area still shows the plain fill color used to come back as a finished-looking picture with bars. Stitch Inpaint now measures how much of the new area is still flat at the fill color, beyond what the source picture itself has, and when a quarter of it (or half of any checked frame) is left, says so in the console and in a toast. The check lives in its own helper, works for images and video and for any fill color, and stays quiet on dark scenes that are painted.
54 lines
2.2 KiB
JavaScript
54 lines
2.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { noticesFromExecuted, queueRemaining, shouldChime } from "../js/shared/notify.mjs";
|
|
|
|
test("queue remaining reads both status event shapes", () => {
|
|
assert.equal(queueRemaining({ exec_info: { queue_remaining: 3 } }), 3);
|
|
assert.equal(queueRemaining({ status: { exec_info: { queue_remaining: 0 } } }), 0);
|
|
});
|
|
|
|
test("unknown shapes resolve to null, never to an empty queue", () => {
|
|
assert.equal(queueRemaining(null), null);
|
|
assert.equal(queueRemaining(undefined), null);
|
|
assert.equal(queueRemaining({}), null);
|
|
assert.equal(queueRemaining({ exec_info: {} }), null);
|
|
assert.equal(queueRemaining({ exec_info: { queue_remaining: "soon" } }), null);
|
|
});
|
|
|
|
test("the chime marks the busy-to-idle transition only", () => {
|
|
assert.equal(shouldChime(true, 1, 0), true);
|
|
assert.equal(shouldChime(true, 5, 0), true);
|
|
// Page opened onto an idle queue: no transition, no chime.
|
|
assert.equal(shouldChime(true, 0, 0), false);
|
|
// Mid-run ticks stay silent.
|
|
assert.equal(shouldChime(true, 3, 2), false);
|
|
// Queue refilling is not completion.
|
|
assert.equal(shouldChime(true, 0, 2), false);
|
|
});
|
|
|
|
test("the setting gates the chime entirely", () => {
|
|
assert.equal(shouldChime(false, 1, 0), false);
|
|
assert.equal(shouldChime(undefined, 1, 0), false);
|
|
});
|
|
|
|
test("notices sent with a node's result are read from the executed event", () => {
|
|
const detail = {
|
|
node: "28:21",
|
|
output: { ausboss_notice: [{ source: "Stitch Inpaint", text: "The model left 100% of the new area unpainted." }] },
|
|
};
|
|
assert.deepEqual(noticesFromExecuted(detail), [
|
|
{ source: "Stitch Inpaint", text: "The model left 100% of the new area unpainted." },
|
|
]);
|
|
assert.deepEqual(noticesFromExecuted({ output: { ausboss_notice: [" plain text "] } }), [
|
|
{ source: "", text: "plain text" },
|
|
]);
|
|
});
|
|
|
|
test("results without notices, and malformed ones, show nothing", () => {
|
|
assert.deepEqual(noticesFromExecuted(null), []);
|
|
assert.deepEqual(noticesFromExecuted({ output: { images: [] } }), []);
|
|
assert.deepEqual(noticesFromExecuted({ output: { ausboss_notice: "not a list" } }), []);
|
|
assert.deepEqual(noticesFromExecuted({ output: { ausboss_notice: [null, 3, { text: "" }, { source: "x" }] } }), []);
|
|
});
|