Merge pull request #1010 from bbassie/feature/plugin-browser

Plugin management through web interface
This commit is contained in:
Bastiaan authored and GitHub committed 2026-10-27 21:32:51 +00:00
1 parent e36a76acc5
commit ffe82f81d8
48 files changed
+4275 -536

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
import assert from "node:assert/strict";
import { setTimeout as sleep } from "node:timers/promises";
import { poll } from "../../packages/web_ui/src/util/poll.ts";
describe("web_ui/util/poll", function() {
describe("poll()", function() {
it("should keep every result of a task slower than the interval", async function() {
let running = 0;
let maxRunning = 0;
const applied = [];
let count = 0;
const stop = poll(async () => {
count += 1;
const run = count;
running += 1;
maxRunning = Math.max(maxRunning, running);
await sleep(20);
running -= 1;
applied.push(run);
}, 1);
await sleep(150);
stop();
await sleep(40);
assert.equal(maxRunning, 1);
assert.ok(applied.length >= 3, `only ${applied.length} runs finished`);
assert.deepEqual(applied, applied.slice().sort((a, b) => a - b));
assert.equal(applied.length, count);
});
it("should not run again once stopped", async function() {
let count = 0;
const stop = poll(async () => { count += 1; }, 1);
stop();
await sleep(20);
assert.equal(count, 1);
});
it("should not run again when stopped while a run is in progress", async function() {
let count = 0;
const stop = poll(async () => { count += 1; await sleep(10); }, 1);
await sleep(2);
stop();
await sleep(30);
assert.equal(count, 1);
});
});
});