This commit is contained in:
2026-07-06 00:01:34 +07:00
parent 2729408ef3
commit e7470e955e
108 changed files with 4131 additions and 529 deletions

View File

@@ -38,14 +38,14 @@ async function setupTestContext(nodeData) {
};
}
function makeRequest(provider) {
function makeRequest(provider, name = "Test Connection") {
return new Request("https://9router.local/api/providers", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
provider,
apiKey: "test-key",
name: "Test Connection",
name,
defaultModel: "test-model",
}),
});
@@ -145,26 +145,25 @@ describe("compatible provider connections API", () => {
});
});
it("returns 400 for a duplicate connection on the same compatible node", async () => {
it("allows multiple connections on the same compatible node", async () => {
const ctx = await setupTestContext({
id: "openai-compatible-duplicate-test",
id: "openai-compatible-multiple-test",
type: "openai-compatible",
name: "Duplicate Guard Node",
prefix: "dup",
name: "Multiple Connections Node",
prefix: "mul",
apiType: "chat",
baseUrl: "https://duplicate-guard.test/v1",
baseUrl: "https://multiple-connections.test/v1",
});
cleanup = ctx.cleanup;
const firstResponse = await ctx.POST(makeRequest(ctx.node.id));
const secondResponse = await ctx.POST(makeRequest(ctx.node.id));
const secondBody = await secondResponse.json();
const firstResponse = await ctx.POST(makeRequest(ctx.node.id, "Key A"));
const secondResponse = await ctx.POST(makeRequest(ctx.node.id, "Key B"));
const storedConnections = await ctx.getProviderConnections({ provider: ctx.node.id });
expect(firstResponse.status).toBe(201);
expect(secondResponse.status).toBe(400);
expect(secondBody.error).toContain("Only one connection is allowed");
expect(storedConnections).toHaveLength(1);
expect(secondResponse.status).toBe(201);
expect(storedConnections).toHaveLength(2);
expectCompatibleConnection(storedConnections[0], ctx.node, { apiType: "chat" });
expectCompatibleConnection(storedConnections[1], ctx.node, { apiType: "chat" });
});
});