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:
oyi77
2026-08-25 03:32:57 +07:00
committed by Markus Hartung
parent 77ea656b12
commit 158fb1a806
30 changed files with 124 additions and 120 deletions

View File

@@ -41,7 +41,7 @@ after(() => {
test("no config (disabled by default) returns the provider's own executor", async () => {
clearUpstreamProxyConfigCache("openai");
const exec = await resolveExecutorWithProxy("openai");
assert.equal(exec, getExecutor("openai"));
assert.equal(exec, await getExecutor("openai"));
});
test("mode 'native' returns the provider's own executor", async () => {
@@ -52,7 +52,7 @@ test("mode 'native' returns the provider's own executor", async () => {
});
clearUpstreamProxyConfigCache("openai");
const exec = await resolveExecutorWithProxy("openai");
assert.equal(exec, getExecutor("openai"));
assert.equal(exec, await getExecutor("openai"));
});
test("mode 'cliproxyapi' returns the CLIProxyAPI passthrough executor", async () => {
@@ -63,7 +63,7 @@ test("mode 'cliproxyapi' returns the CLIProxyAPI passthrough executor", async ()
});
clearUpstreamProxyConfigCache("anthropic");
const exec = await resolveExecutorWithProxy("anthropic");
assert.equal(exec, getExecutor("cliproxyapi"));
assert.equal(exec, await getExecutor("cliproxyapi"));
});
test("mode 'fallback' returns a distinct wrapper owning its own execute()", async () => {
@@ -74,8 +74,8 @@ test("mode 'fallback' returns a distinct wrapper owning its own execute()", asyn
});
clearUpstreamProxyConfigCache("openai");
const exec = await resolveExecutorWithProxy("openai");
assert.notEqual(exec, getExecutor("openai"));
assert.notEqual(exec, getExecutor("cliproxyapi"));
assert.notEqual(exec, await getExecutor("openai"));
assert.notEqual(exec, await getExecutor("cliproxyapi"));
assert.equal(typeof exec.execute, "function");
});
@@ -94,7 +94,7 @@ test("connection override 'claude-native' selects CLIProxyAPI even when provider
const exec = await resolveExecutorWithProxy("openai", undefined, {
cliproxyapiMode: "claude-native",
});
assert.equal(exec, getExecutor("cliproxyapi"));
assert.equal(exec, await getExecutor("cliproxyapi"));
});
test("connection override 'claude-native' selects CLIProxyAPI even with no provider config (default)", async () => {
@@ -102,7 +102,7 @@ test("connection override 'claude-native' selects CLIProxyAPI even with no provi
const exec = await resolveExecutorWithProxy("anthropic", undefined, {
cliproxyapiMode: "claude-native",
});
assert.equal(exec, getExecutor("cliproxyapi"));
assert.equal(exec, await getExecutor("cliproxyapi"));
});
test("no connection override + provider mode native → native executor (unchanged)", async () => {
@@ -115,13 +115,13 @@ test("no connection override + provider mode native → native executor (unchang
const exec = await resolveExecutorWithProxy("openai", undefined, {
someOtherField: "x",
});
assert.equal(exec, getExecutor("openai"));
assert.equal(exec, await getExecutor("openai"));
});
test("connection override absent (undefined providerSpecificData) preserves default behaviour", async () => {
clearUpstreamProxyConfigCache("openai");
const exec = await resolveExecutorWithProxy("openai");
assert.equal(exec, getExecutor("openai"));
assert.equal(exec, await getExecutor("openai"));
});
test("connection override wins over provider mode 'fallback'", async () => {
@@ -135,5 +135,5 @@ test("connection override wins over provider mode 'fallback'", async () => {
cliproxyapiMode: "claude-native",
});
// Connection override short-circuits to the passthrough executor, not the fallback wrapper.
assert.equal(exec, getExecutor("cliproxyapi"));
assert.equal(exec, await getExecutor("cliproxyapi"));
});