test(extensions): cast fetch mocks to satisfy tsgo

This commit is contained in:
Sebastian
2026-02-16 21:25:25 -05:00
parent f7e75d2c5c
commit 4aed4eedb7
2 changed files with 9 additions and 9 deletions

View File

@@ -16,7 +16,7 @@ function createCfg(): OpenClawConfig {
describe("mattermost reactions", () => {
it("adds reactions by calling /users/me then POST /reactions", async () => {
const fetchImpl = vi.fn(async (url: any, init?: any) => {
const fetchMock = vi.fn(async (url: any, init?: any) => {
if (String(url).endsWith("/api/v4/users/me")) {
return new Response(JSON.stringify({ id: "BOT123" }), {
status: 200,
@@ -42,15 +42,15 @@ describe("mattermost reactions", () => {
cfg: createCfg(),
postId: "POST1",
emojiName: "thumbsup",
fetchImpl,
fetchImpl: fetchMock as unknown as typeof fetch,
});
expect(result).toEqual({ ok: true });
expect(fetchImpl).toHaveBeenCalled();
expect(fetchMock).toHaveBeenCalled();
});
it("returns a Result error when add reaction API call fails", async () => {
const fetchImpl = vi.fn(async (url: any) => {
const fetchMock = vi.fn(async (url: any) => {
if (String(url).endsWith("/api/v4/users/me")) {
return new Response(JSON.stringify({ id: "BOT123" }), {
status: 200,
@@ -70,7 +70,7 @@ describe("mattermost reactions", () => {
cfg: createCfg(),
postId: "POST1",
emojiName: "thumbsup",
fetchImpl,
fetchImpl: fetchMock as unknown as typeof fetch,
});
expect(result.ok).toBe(false);
@@ -80,7 +80,7 @@ describe("mattermost reactions", () => {
});
it("removes reactions by calling /users/me then DELETE /users/:id/posts/:postId/reactions/:emoji", async () => {
const fetchImpl = vi.fn(async (url: any, init?: any) => {
const fetchMock = vi.fn(async (url: any, init?: any) => {
if (String(url).endsWith("/api/v4/users/me")) {
return new Response(JSON.stringify({ id: "BOT123" }), {
status: 200,
@@ -101,10 +101,10 @@ describe("mattermost reactions", () => {
cfg: createCfg(),
postId: "POST1",
emojiName: "thumbsup",
fetchImpl,
fetchImpl: fetchMock as unknown as typeof fetch,
});
expect(result).toEqual({ ok: true });
expect(fetchImpl).toHaveBeenCalled();
expect(fetchMock).toHaveBeenCalled();
});
});

View File

@@ -28,7 +28,7 @@ describe("thread-ownership plugin", () => {
process.env.SLACK_BOT_USER_ID = "U999";
originalFetch = globalThis.fetch;
globalThis.fetch = vi.fn();
globalThis.fetch = vi.fn() as unknown as typeof globalThis.fetch;
});
afterEach(() => {