mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-26 09:02:11 +03:00
test(executors): adapt remaining 35 suites to the async lazy registry (round 2)
Round 1 only covered suites importing from executors/index.ts directly;
suites importing getExecutor through other paths (open-sse root
re-export, dynamic imports inside tests) still called it synchronously,
producing Promise-vs-instance assertion failures in CI (e.g.
providers-yuanbao-web 'instanceof YuanbaoWebExecutor' false).
Sweep method: repo-wide scan for un-awaited getExecutor call sites,
adapted mechanically (await + async callbacks + Response|{response}
union narrowing); assert.rejects guards with promise-returning
callbacks verified correct as-is.
Locally verified green: providers-yuanbao-web, ninerouter-executor,
provider-request-failure-pipeline, provider-limits-accesstoken-fallback,
executor-registry, chatcore-executor-proxy, poe-api-executor-regression,
web-cookie-providers-new (113/113).
This commit is contained in:
@@ -91,15 +91,15 @@ test("Command Code provider catalog has pinned models and alias lookup", () => {
|
||||
assert.equal(getRegistryEntry("cmd"), entry);
|
||||
});
|
||||
|
||||
test("getExecutor returns the specialized Command Code executor", () => {
|
||||
test("getExecutor returns the specialized Command Code executor", async () => {
|
||||
assert.equal(hasSpecializedExecutor("command-code"), true);
|
||||
assert.ok(getExecutor("command-code") instanceof CommandCodeExecutor);
|
||||
assert.ok(getExecutor("cmd") instanceof CommandCodeExecutor);
|
||||
assert.ok((await getExecutor("command-code")) instanceof CommandCodeExecutor);
|
||||
assert.ok((await getExecutor("cmd")) instanceof CommandCodeExecutor);
|
||||
});
|
||||
|
||||
test("Command Code executor posts a flat OpenAI body + standard headers to /provider/v1/chat/completions (#10265)", async () => {
|
||||
const calls = captureFetch({});
|
||||
const executor = getExecutor("command-code");
|
||||
const executor = await getExecutor("command-code");
|
||||
const { response, url, headers } = await executor.execute({
|
||||
model: "gpt-5.4-mini",
|
||||
stream: false,
|
||||
@@ -143,7 +143,7 @@ test("Command Code executor posts a flat OpenAI body + standard headers to /prov
|
||||
|
||||
test("Command Code executor passes reasoning/thinking fields through at the top level of the OpenAI body", async () => {
|
||||
const calls = captureFetch({});
|
||||
await getExecutor("command-code").execute({
|
||||
(await getExecutor("command-code")).execute({
|
||||
model: "deepseek/deepseek-v4-pro",
|
||||
stream: false,
|
||||
credentials: { apiKey: "cc_test_key" },
|
||||
@@ -166,7 +166,7 @@ test("Command Code executor passes reasoning/thinking fields through at the top
|
||||
|
||||
test("Command Code executor honors body.model rewrite from payload rules", async () => {
|
||||
const calls = captureFetch({});
|
||||
await getExecutor("command-code").execute({
|
||||
(await getExecutor("command-code")).execute({
|
||||
model: "deepseek-v4-pro-max",
|
||||
stream: false,
|
||||
credentials: { apiKey: "cc_test_key" },
|
||||
@@ -187,7 +187,7 @@ test("Command Code executor maps unsupported minimal reasoning_effort to low (up
|
||||
const calls = captureFetch({});
|
||||
// `minimal` (a Muse Spark catalog tier) must be downgraded to `low` before
|
||||
// the wire body is built, on BOTH the combo and single-model paths.
|
||||
await getExecutor("command-code").execute({
|
||||
(await getExecutor("command-code")).execute({
|
||||
model: "poolside/laguna-s-2.1-free",
|
||||
stream: false,
|
||||
credentials: { apiKey: "cc_test_key" },
|
||||
@@ -232,7 +232,7 @@ test("Command Code executor passes the upstream OpenAI SSE stream through untouc
|
||||
});
|
||||
};
|
||||
|
||||
const { response } = await getExecutor("command-code").execute({
|
||||
const { response } = (await getExecutor("command-code")).execute({
|
||||
model: "gpt-5.4",
|
||||
stream: true,
|
||||
credentials: { apiKey: "cc_test_key" },
|
||||
@@ -266,7 +266,7 @@ test("Command Code executor passes the upstream OpenAI JSON through untouched (n
|
||||
});
|
||||
};
|
||||
|
||||
const { response } = await getExecutor("command-code").execute({
|
||||
const { response } = (await getExecutor("command-code")).execute({
|
||||
model: "gpt-5.4-mini",
|
||||
stream: false,
|
||||
credentials: { apiKey: "cc_test_key" },
|
||||
@@ -279,7 +279,7 @@ test("Command Code executor passes the upstream OpenAI JSON through untouched (n
|
||||
|
||||
test("Command Code executor surfaces upstream errors", async () => {
|
||||
globalThis.fetch = async () => new Response("bad key", { status: 401, statusText: "Unauthorized" });
|
||||
const upstreamFailure = await getExecutor("command-code").execute({
|
||||
const upstreamFailure = (await getExecutor("command-code")).execute({
|
||||
model: "gpt-5.4-mini",
|
||||
stream: false,
|
||||
credentials: { apiKey: "cc_test_key" },
|
||||
@@ -291,7 +291,7 @@ test("Command Code executor surfaces upstream errors", async () => {
|
||||
|
||||
test("Command Code executor omits max_tokens when the client does not supply one", async () => {
|
||||
const calls = captureFetch({});
|
||||
await getExecutor("command-code").execute({
|
||||
(await getExecutor("command-code")).execute({
|
||||
model: "zai-org/GLM-5.1",
|
||||
stream: false,
|
||||
credentials: { apiKey: "cc_test_key" },
|
||||
@@ -305,7 +305,7 @@ test("Command Code executor omits max_tokens when the client does not supply one
|
||||
test("Command Code executor clamps an oversized client-supplied max_tokens to the endpoint ceiling", async () => {
|
||||
const calls = captureFetch({});
|
||||
// A client asking for more than the 200000 endpoint ceiling is clamped down.
|
||||
await getExecutor("command-code").execute({
|
||||
(await getExecutor("command-code")).execute({
|
||||
model: "deepseek/deepseek-v4-pro",
|
||||
stream: false,
|
||||
credentials: { apiKey: "cc_test_key" },
|
||||
@@ -316,7 +316,7 @@ test("Command Code executor clamps an oversized client-supplied max_tokens to th
|
||||
|
||||
test("Command Code executor honors a smaller client-provided max_tokens", async () => {
|
||||
const calls = captureFetch({});
|
||||
await getExecutor("command-code").execute({
|
||||
(await getExecutor("command-code")).execute({
|
||||
model: "zai-org/GLM-5.1",
|
||||
stream: false,
|
||||
credentials: { apiKey: "cc_test_key" },
|
||||
@@ -350,7 +350,7 @@ test("Command Code stream preserves the upstream OpenAI usage chunk (passthrough
|
||||
globalThis.fetch = async () =>
|
||||
new Response(sse, { status: 200, headers: { "Content-Type": "text/event-stream" } });
|
||||
|
||||
const { response } = await getExecutor("command-code").execute({
|
||||
const { response } = (await getExecutor("command-code")).execute({
|
||||
model: "gpt-5.4-mini",
|
||||
stream: true,
|
||||
credentials: { apiKey: "cc_test_key" },
|
||||
|
||||
Reference in New Issue
Block a user