test: speed up line and tlon seam tests

This commit is contained in:
Peter Steinberger
2026-04-07 14:37:53 +01:00
parent c385a2d45e
commit 7316a95327
3 changed files with 6 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { createRuntimeEnv } from "../../../test/helpers/plugins/runtime-env.js";
import type { OpenClawConfig, PluginRuntime, ResolvedLineAccount } from "../api.js";
import { linePlugin } from "./channel.js";
import { lineGatewayAdapter } from "./gateway.js";
import { setLineRuntime } from "./runtime.js";
const DEFAULT_ACCOUNT_ID = "default";
@@ -53,13 +53,13 @@ function resolveAccount(
}
async function runLogoutScenario(params: { cfg: OpenClawConfig; accountId: string }): Promise<{
result: Awaited<ReturnType<NonNullable<NonNullable<typeof linePlugin.gateway>["logoutAccount"]>>>;
result: Awaited<ReturnType<NonNullable<typeof lineGatewayAdapter.logoutAccount>>>;
mocks: LineRuntimeMocks;
}> {
const { runtime, mocks } = createRuntime();
setLineRuntime(runtime);
const account = resolveAccount(mocks.resolveLineAccount, params.cfg, params.accountId);
const result = await linePlugin.gateway!.logoutAccount!({
const result = await lineGatewayAdapter.logoutAccount!({
accountId: params.accountId,
cfg: params.cfg,
account,

View File

@@ -1,9 +1,9 @@
import { describe, expect, it } from "vitest";
import type { ChannelAccountSnapshot } from "../api.js";
import { linePlugin } from "./channel.js";
import { lineStatusAdapter } from "./status.js";
function collectIssues(accounts: ChannelAccountSnapshot[]) {
const collect = linePlugin.status?.collectStatusIssues;
const collect = lineStatusAdapter.collectStatusIssues;
if (!collect) {
throw new Error("LINE plugin status collector is unavailable");
}

View File

@@ -1,4 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { urbitFetch } from "./fetch.js";
import { UrbitSSEClient } from "./sse-client.js";
// Mock urbitFetch to avoid real network calls
@@ -24,7 +25,6 @@ describe("UrbitSSEClient", () => {
describe("subscribe", () => {
it("sends subscriptions added after connect", async () => {
const { urbitFetch } = await import("./fetch.js");
const mockUrbitFetch = vi.mocked(urbitFetch);
mockUrbitFetch.mockResolvedValue({
response: { ok: true, status: 200 } as unknown as Response,
@@ -57,7 +57,6 @@ describe("UrbitSSEClient", () => {
});
it("queues subscriptions before connect", async () => {
const { urbitFetch } = await import("./fetch.js");
const mockUrbitFetch = vi.mocked(urbitFetch);
const client = new UrbitSSEClient("https://example.com", "urbauth-~zod=123");
@@ -121,7 +120,6 @@ describe("UrbitSSEClient", () => {
});
it("resets reconnect attempts on successful connect", async () => {
const { urbitFetch } = await import("./fetch.js");
const mockUrbitFetch = vi.mocked(urbitFetch);
// Mock a response that returns a readable stream