forked from longtao.wu/droboticflow
77 lines
2.0 KiB
JavaScript
77 lines
2.0 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { buildSettingsUpdatePayload } from "../../src/lib/settings.js";
|
|
|
|
test("does not resend stored secrets when secret inputs are blank", () => {
|
|
const payload = buildSettingsUpdatePayload({
|
|
id: "settings-1",
|
|
k8s: {
|
|
enabled: true,
|
|
endpoint: "https://cluster.example.com",
|
|
namespace: "droboticflow",
|
|
kubeconfig: "",
|
|
hasKubeconfig: true,
|
|
kubeconfigPreview: "apiV****ig==",
|
|
},
|
|
worker: {
|
|
pollIntervalMs: 2000,
|
|
maxConcurrentRuns: 4,
|
|
},
|
|
ai: {
|
|
provider: "dashscope-openai-compatible",
|
|
baseURL: "https://coding.dashscope.aliyuncs.com/v1",
|
|
model: "glm-5",
|
|
apiKey: "",
|
|
hasAPIKey: true,
|
|
apiKeyPreview: "sk-t****1234",
|
|
},
|
|
defaults: {
|
|
cpuRequest: "500m",
|
|
cpuLimit: "1000m",
|
|
memoryRequest: "1Gi",
|
|
memoryLimit: "2Gi",
|
|
},
|
|
timezone: "Asia/Shanghai",
|
|
});
|
|
|
|
assert.equal("kubeconfig" in payload.k8s, false);
|
|
assert.equal("kubeconfigPreview" in payload.k8s, false);
|
|
assert.equal("apiKey" in payload.ai, false);
|
|
assert.equal("apiKeyPreview" in payload.ai, false);
|
|
});
|
|
|
|
test("sends new secrets when the user provides replacement values", () => {
|
|
const payload = buildSettingsUpdatePayload({
|
|
id: "settings-1",
|
|
k8s: {
|
|
enabled: true,
|
|
endpoint: "https://cluster.example.com",
|
|
namespace: "droboticflow",
|
|
kubeconfig: " apiVersion: v1\nkind: Config ",
|
|
hasKubeconfig: true,
|
|
},
|
|
worker: {
|
|
pollIntervalMs: 2000,
|
|
maxConcurrentRuns: 4,
|
|
},
|
|
ai: {
|
|
provider: "dashscope-openai-compatible",
|
|
baseURL: "https://coding.dashscope.aliyuncs.com/v1",
|
|
model: "glm-5",
|
|
apiKey: " new-key ",
|
|
hasAPIKey: true,
|
|
},
|
|
defaults: {
|
|
cpuRequest: "500m",
|
|
cpuLimit: "1000m",
|
|
memoryRequest: "1Gi",
|
|
memoryLimit: "2Gi",
|
|
},
|
|
timezone: "Asia/Shanghai",
|
|
});
|
|
|
|
assert.equal(payload.k8s.kubeconfig, "apiVersion: v1\nkind: Config");
|
|
assert.equal(payload.ai.apiKey, "new-key");
|
|
});
|