mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-20 21:23:23 +00:00
test: speed up line and tlon seam tests
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user