test: speed up setup and core extension tests

This commit is contained in:
Peter Steinberger
2026-04-07 16:13:46 +01:00
parent 9975e3172d
commit a96790fde7
3 changed files with 62 additions and 19 deletions

View File

@@ -2,7 +2,7 @@ import fs from "node:fs";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
import { describe, expect, it } from "vitest";
import { validateJsonSchemaValue } from "../../../src/plugins/schema-validator.js";
import { qqbotPlugin } from "./channel.js";
import { qqbotSetupAdapterShared } from "./channel-config-shared.js";
import { qqbotSetupPlugin } from "./channel.setup.js";
import { QQBotConfigSchema } from "./config-schema.js";
import { DEFAULT_ACCOUNT_ID, resolveDefaultQQBotAccountId, resolveQQBotAccount } from "./config.js";
@@ -264,7 +264,7 @@ describe("qqbot config", () => {
});
it("rejects malformed --token consistently across setup paths", () => {
const runtimeSetup = qqbotPlugin.setup;
const runtimeSetup = qqbotSetupAdapterShared;
const lightweightSetup = qqbotSetupPlugin.setup;
expect(runtimeSetup).toBeDefined();
expect(lightweightSetup).toBeDefined();
@@ -272,7 +272,7 @@ describe("qqbot config", () => {
const input = { token: "broken", name: "Bad" };
expect(
runtimeSetup!.validateInput?.({
runtimeSetup.validateInput?.({
cfg: {} as OpenClawConfig,
accountId: DEFAULT_ACCOUNT_ID,
input,
@@ -286,7 +286,7 @@ describe("qqbot config", () => {
}),
).toBe("QQBot --token must be in appId:clientSecret format");
expect(
runtimeSetup!.applyAccountConfig?.({
runtimeSetup.applyAccountConfig?.({
cfg: {} as OpenClawConfig,
accountId: DEFAULT_ACCOUNT_ID,
input,
@@ -302,7 +302,7 @@ describe("qqbot config", () => {
});
it("preserves the --use-env add flow across setup paths", () => {
const runtimeSetup = qqbotPlugin.setup;
const runtimeSetup = qqbotSetupAdapterShared;
const lightweightSetup = qqbotSetupPlugin.setup;
expect(runtimeSetup).toBeDefined();
expect(lightweightSetup).toBeDefined();
@@ -310,7 +310,7 @@ describe("qqbot config", () => {
const input = { useEnv: true, name: "Env Bot" };
expect(
runtimeSetup!.applyAccountConfig?.({
runtimeSetup.applyAccountConfig?.({
cfg: {} as OpenClawConfig,
accountId: DEFAULT_ACCOUNT_ID,
input,
@@ -342,11 +342,11 @@ describe("qqbot config", () => {
});
it("uses configured defaultAccount when runtime setup accountId is omitted", () => {
const runtimeSetup = qqbotPlugin.setup;
const runtimeSetup = qqbotSetupAdapterShared;
expect(runtimeSetup).toBeDefined();
expect(
runtimeSetup!.resolveAccountId?.({
runtimeSetup.resolveAccountId?.({
cfg: {
channels: {
qqbot: {
@@ -363,7 +363,7 @@ describe("qqbot config", () => {
});
it("rejects --use-env for named accounts across setup paths", () => {
const runtimeSetup = qqbotPlugin.setup;
const runtimeSetup = qqbotSetupAdapterShared;
const lightweightSetup = qqbotSetupPlugin.setup;
expect(runtimeSetup).toBeDefined();
expect(lightweightSetup).toBeDefined();
@@ -371,7 +371,7 @@ describe("qqbot config", () => {
const input = { useEnv: true, name: "Env Bot" };
expect(
runtimeSetup!.validateInput?.({
runtimeSetup.validateInput?.({
cfg: {} as OpenClawConfig,
accountId: "bot2",
input,
@@ -385,7 +385,7 @@ describe("qqbot config", () => {
}),
).toBe("QQBot --use-env only supports the default account");
expect(
runtimeSetup!.applyAccountConfig?.({
runtimeSetup.applyAccountConfig?.({
cfg: {} as OpenClawConfig,
accountId: "bot2",
input,