[codex] refresh plugin regression fixtures · openclaw/openclaw@bfd540b
JayZeeDesign
·
2026-05-11
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { afterEach, describe, expect, it } from "vitest"; |
2 | 2 | import { type WebSocket, WebSocketServer } from "ws"; |
3 | 3 | import { rawDataToString } from "../infra/ws.js"; |
| 4 | +import "../test-support/browser-security.mock.js"; |
4 | 5 | import { |
5 | 6 | type AriaSnapshotNode, |
6 | 7 | captureScreenshot, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { describe, expect, it, vi } from "vitest"; |
2 | 2 | import type { BrowserRouteContext, ProfileContext } from "../server-context.js"; |
| 3 | +import "../../test-support/browser-security.mock.js"; |
3 | 4 | import { |
4 | 5 | readBody, |
5 | 6 | resolveSafeRouteTabUrl, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { afterEach, describe, expect, it, vi } from "vitest"; |
2 | 2 | import "../../../test-support.js"; |
3 | 3 | import "../server-context.chrome-test-harness.js"; |
| 4 | +import "../../test-support/browser-security.mock.js"; |
4 | 5 | import * as chromeModule from "../chrome.js"; |
5 | 6 | import { createBrowserRouteContext } from "../server-context.js"; |
6 | 7 | import { makeBrowserServerState } from "../server-context.test-harness.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { afterEach, describe, expect, it, vi } from "vitest"; |
2 | 2 | import { withBrowserFetchPreconnect } from "../../test-fetch.js"; |
| 3 | +import "../test-support/browser-security.mock.js"; |
3 | 4 | |
4 | 5 | vi.hoisted(() => { |
5 | 6 | vi.resetModules(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 2 | import { getFreePort } from "./test-port.js"; |
3 | 3 | import { getBrowserTestFetch } from "./test-support/fetch.js"; |
| 4 | +import "../test-support/browser-security.mock.js"; |
4 | 5 | |
5 | 6 | let testPort = 0; |
6 | 7 | let prevGatewayPort: string | undefined; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { vi } from "vitest"; |
2 | 2 | |
| 3 | +const lookupFn = vi.hoisted(() => async (_hostname: string, options?: { all?: boolean }) => { |
| 4 | +const result = { address: "93.184.216.34", family: 4 }; |
| 5 | +return options?.all === true ? [result] : result; |
| 6 | +}); |
| 7 | + |
| 8 | +vi.mock("../infra/net/ssrf.js", async () => { |
| 9 | +const actual = |
| 10 | +await vi.importActual<typeof import("../infra/net/ssrf.js")>("../infra/net/ssrf.js"); |
| 11 | +return { |
| 12 | + ...actual, |
| 13 | +resolvePinnedHostnameWithPolicy: (hostname: string, params: object = {}) => |
| 14 | +actual.resolvePinnedHostnameWithPolicy(hostname, { ...params, lookupFn: lookupFn as never }), |
| 15 | +}; |
| 16 | +}); |
| 17 | + |
3 | 18 | vi.mock("../sdk-security-runtime.js", async () => { |
4 | 19 | const actual = await vi.importActual<typeof import("../sdk-security-runtime.js")>( |
5 | 20 | "../sdk-security-runtime.js", |
6 | 21 | ); |
7 | | -const lookupFn = async (_hostname: string, options?: { all?: boolean }) => { |
8 | | -const result = { address: "93.184.216.34", family: 4 }; |
9 | | -return options?.all === true ? [result] : result; |
10 | | -}; |
11 | 22 | return { |
12 | 23 | ...actual, |
13 | 24 | resolvePinnedHostnameWithPolicy: (hostname: string, params: object = {}) => |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1728,16 +1728,15 @@ describe("processDiscordMessage draft streaming", () => {
|
1728 | 1728 | mode: "progress", |
1729 | 1729 | progress: { |
1730 | 1730 | label: "Clawing...", |
1731 | | -maxLines: 3, |
| 1731 | +maxLines: 4, |
1732 | 1732 | }, |
1733 | 1733 | }, |
1734 | 1734 | }, |
1735 | 1735 | }); |
1736 | 1736 | |
1737 | 1737 | await runProcessDiscordMessage(ctx); |
1738 | 1738 | |
1739 | | -expect(draftStream.update).toHaveBeenNthCalledWith(1, "Clawing...\n🧩 First\n🧩 Second"); |
1740 | | -expect(draftStream.update).toHaveBeenNthCalledWith(2, "🧩 First\n🧩 Second\n🧩 Third"); |
| 1739 | +expect(draftStream.update).toHaveBeenCalledWith("Clawing...\n🧩 First\n🧩 Second\n🧩 Third"); |
1741 | 1740 | }); |
1742 | 1741 | |
1743 | 1742 | it("skips empty apply_patch starts and renders the patch summary", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -import { describe, expect, it, vi } from "vitest"; |
| 1 | +import { mockPinnedHostnameResolution } from "openclaw/plugin-sdk/test-env"; |
| 2 | +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 3 | import { |
3 | 4 | elevenLabsMediaUnderstandingProvider, |
4 | 5 | transcribeElevenLabsAudio, |
5 | 6 | } from "./media-understanding-provider.js"; |
6 | 7 | |
7 | 8 | describe("elevenLabsMediaUnderstandingProvider", () => { |
| 9 | +let ssrfMock: { mockRestore: () => void } | undefined; |
| 10 | + |
| 11 | +beforeEach(() => { |
| 12 | +ssrfMock = mockPinnedHostnameResolution(); |
| 13 | +}); |
| 14 | + |
| 15 | +afterEach(() => { |
| 16 | +ssrfMock?.mockRestore(); |
| 17 | +ssrfMock = undefined; |
| 18 | +}); |
| 19 | + |
8 | 20 | it("has expected provider metadata", () => { |
9 | 21 | expect(elevenLabsMediaUnderstandingProvider.id).toBe("elevenlabs"); |
10 | 22 | expect(elevenLabsMediaUnderstandingProvider.capabilities).toEqual(["audio"]); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import * as providerAuthRuntime from "openclaw/plugin-sdk/provider-auth-runtime"; |
2 | 2 | import * as providerHttp from "openclaw/plugin-sdk/provider-http"; |
3 | | -import { afterEach, describe, expect, it, vi } from "vitest"; |
| 3 | +import { mockPinnedHostnameResolution } from "openclaw/plugin-sdk/test-env"; |
| 4 | +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
4 | 5 | import { buildGoogleImageGenerationProvider } from "./image-generation-provider.js"; |
5 | 6 | import { __testing as geminiWebSearchTesting } from "./src/gemini-web-search-provider.js"; |
6 | 7 | |
| 8 | +let ssrfMock: { mockRestore: () => void } | undefined; |
| 9 | + |
7 | 10 | function mockGoogleApiKeyAuth() { |
8 | 11 | vi.spyOn(providerAuthRuntime, "resolveApiKeyForProvider").mockResolvedValue({ |
9 | 12 | apiKey: "google-test-key", |
@@ -75,7 +78,13 @@ function postJsonRequestOptions(spy: unknown): {
|
75 | 78 | } |
76 | 79 | |
77 | 80 | describe("Google image-generation provider", () => { |
| 81 | +beforeEach(() => { |
| 82 | +ssrfMock = mockPinnedHostnameResolution(); |
| 83 | +}); |
| 84 | + |
78 | 85 | afterEach(() => { |
| 86 | +ssrfMock?.mockRestore(); |
| 87 | +ssrfMock = undefined; |
79 | 88 | vi.restoreAllMocks(); |
80 | 89 | vi.unstubAllGlobals(); |
81 | 90 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { writeFile } from "node:fs/promises"; |
2 | 2 | import path from "node:path"; |
3 | | -import { afterAll, afterEach, describe, expect, it, vi } from "vitest"; |
| 3 | +import { mockPinnedHostnameResolution } from "openclaw/plugin-sdk/test-env"; |
| 4 | +import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
4 | 5 | |
5 | 6 | const { createGoogleGenAIMock, downloadMock, generateVideosMock, getVideosOperationMock } = |
6 | 7 | vi.hoisted(() => { |
@@ -54,8 +55,16 @@ function firstGoogleClientHttpOptions(): Record<string, unknown> {
|
54 | 55 | return recordField(firstObjectArg(createGoogleGenAIMock).httpOptions, "httpOptions"); |
55 | 56 | } |
56 | 57 | |
| 58 | +let ssrfMock: { mockRestore: () => void } | undefined; |
| 59 | + |
57 | 60 | describe("google video generation provider", () => { |
| 61 | +beforeEach(() => { |
| 62 | +ssrfMock = mockPinnedHostnameResolution(); |
| 63 | +}); |
| 64 | + |
58 | 65 | afterEach(() => { |
| 66 | +ssrfMock?.mockRestore(); |
| 67 | +ssrfMock = undefined; |
59 | 68 | vi.restoreAllMocks(); |
60 | 69 | vi.unstubAllGlobals(); |
61 | 70 | downloadMock.mockReset(); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。