- Remove the separate Concurrent jobs field; rename Jobs per run to Images per run (1-16) with a tooltip explaining that Runpod's max workers decides how many GPUs run them. - Backend uses a fixed per-worker limit of 16 outstanding jobs, so all images of a run are submitted at once. Unresolved jobs still count against it. The limit is constant, so it never has to change while jobs are unresolved. - Legacy 'concurrency' in saved configs and older browser tabs is accepted and ignored/dropped; it no longer triggers the busy guard. - Revert the enable toggle and show the reason when the backend rejects it. - Trim a pasted api.runpod.ai/v2/<id> URL to the endpoint ID; plainer endpoint-ID error otherwise. - Confirm before a type change deletes a saved Runpod API key. - Update docs and tests.
55 lines
2.3 KiB
JavaScript
55 lines
2.3 KiB
JavaScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
vi.mock("../../scripts/app.js", () => ({ app: { registerExtension: vi.fn() } }), { virtual: true });
|
|
vi.mock("../../scripts/api.js", () => ({ api: { clientId: "test-client", queuePrompt: vi.fn() } }), { virtual: true });
|
|
|
|
import { DistributedExtension } from "../main.js";
|
|
|
|
function makeExtension(worker, updateWorker) {
|
|
return {
|
|
config: { workers: [worker] },
|
|
state: { updateWorker: vi.fn() },
|
|
api: { updateWorker },
|
|
app: { extensionManager: { toast: { add: vi.fn() } } },
|
|
ui: { updateStatusDot: vi.fn() },
|
|
log: vi.fn(),
|
|
_emitWorkersChanged: vi.fn(),
|
|
panelElement: null,
|
|
};
|
|
}
|
|
|
|
describe("worker enable toggle", () => {
|
|
let originalDocument;
|
|
beforeEach(() => {
|
|
originalDocument = globalThis.document;
|
|
globalThis.document = { getElementById: () => null };
|
|
});
|
|
afterEach(() => {
|
|
globalThis.document = originalDocument;
|
|
});
|
|
|
|
it("reverts the toggle and explains why when the backend rejects the change", async () => {
|
|
const worker = { id: "w1", type: "serverless", enabled: false };
|
|
const extension = makeExtension(worker, vi.fn().mockRejectedValue(new Error("Save an API key before enabling this worker")));
|
|
|
|
await DistributedExtension.prototype.updateWorkerEnabled.call(extension, "w1", true);
|
|
|
|
expect(worker.enabled).toBe(false);
|
|
expect(extension.state.updateWorker).toHaveBeenLastCalledWith("w1", { enabled: false });
|
|
expect(extension.app.extensionManager.toast.add).toHaveBeenCalledWith(expect.objectContaining({
|
|
severity: "error", summary: "Could not enable worker", detail: "Save an API key before enabling this worker",
|
|
}));
|
|
});
|
|
|
|
it("keeps the new state when the backend accepts it", async () => {
|
|
const worker = { id: "w2", type: "serverless", enabled: false };
|
|
const extension = makeExtension(worker, vi.fn().mockResolvedValue({ status: "success" }));
|
|
|
|
await DistributedExtension.prototype.updateWorkerEnabled.call(extension, "w2", true);
|
|
|
|
expect(worker.enabled).toBe(true);
|
|
expect(extension.state.updateWorker).toHaveBeenLastCalledWith("w2", { enabled: true });
|
|
expect(extension.app.extensionManager.toast.add).not.toHaveBeenCalled();
|
|
});
|
|
});
|