test: consolidate plugin provider suites

This commit is contained in:
Peter Steinberger
2026-03-25 00:41:15 +00:00
parent 3a1b517581
commit 83591fabfb
16 changed files with 651 additions and 718 deletions

View File

@@ -1,4 +1,4 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import type { FeishuConfig, ResolvedFeishuAccount } from "./types.js";
type CreateFeishuClient = typeof import("./client.js").createFeishuClient;
@@ -61,7 +61,7 @@ function firstWsClientOptions(): { agent?: unknown } {
return calls[0]?.[0] ?? {};
}
beforeEach(async () => {
beforeAll(async () => {
vi.resetModules();
vi.doMock("@larksuiteoapi/node-sdk", () => ({
AppType: { SelfBuild: "self" },
@@ -85,7 +85,9 @@ beforeEach(async () => {
FEISHU_HTTP_TIMEOUT_MAX_MS,
FEISHU_HTTP_TIMEOUT_ENV_VAR,
} = await import("./client.js"));
});
beforeEach(() => {
priorProxyEnv = {};
priorFeishuTimeoutEnv = process.env[FEISHU_HTTP_TIMEOUT_ENV_VAR];
delete process.env[FEISHU_HTTP_TIMEOUT_ENV_VAR];
@@ -94,6 +96,7 @@ beforeEach(async () => {
delete process.env[key];
}
vi.clearAllMocks();
clearClientCache();
setFeishuClientRuntimeForTest({
sdk: {
AppType: { SelfBuild: "self" } as never,
@@ -129,10 +132,6 @@ afterEach(() => {
});
describe("createFeishuClient HTTP timeout", () => {
beforeEach(() => {
clearClientCache();
});
const getLastClientHttpInstance = () => {
const calls = clientCtorMock.mock.calls as unknown as Array<[options: unknown]>;
const lastCall = calls[calls.length - 1]?.[0] as