fix: address CodeRabbit review — typed mocks, robust benchmark script
- Replace `as any` casts in integration-test-connection.spec.ts with Pick<Integration, "testConnectionAsync"> + mockResolvedValue - build-compare.sh: split local declarations (SC2318), clean .next between builds with --force, add EXIT trap for safe stash/cleanup
This commit is contained in:
2 files changed
+33
-34
No files matched your search
@@ -1,10 +1,15 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
|
||||
import * as homarrDefinitions from "@homarr/definitions";
|
||||
import type { Integration } from "@homarr/integrations";
|
||||
import * as homarrIntegrations from "@homarr/integrations";
|
||||
|
||||
import { testConnectionAsync } from "../../integration/integration-test-connection";
|
||||
|
||||
const mockIntegration = (): Pick<Integration, "testConnectionAsync"> => ({
|
||||
testConnectionAsync: async () => ({ success: true }),
|
||||
});
|
||||
|
||||
vi.mock("@homarr/common/server", async (importActual) => {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||
const actual = await importActual<typeof import("@homarr/common/server")>();
|
||||
@@ -20,12 +25,7 @@ describe("testConnectionAsync should run test connection of integration", () =>
|
||||
// Arrange
|
||||
const factorySpy = vi.spyOn(homarrIntegrations, "createIntegrationAsync");
|
||||
const optionsSpy = vi.spyOn(homarrDefinitions, "getAllSecretKindOptions");
|
||||
factorySpy.mockReturnValue(
|
||||
Promise.resolve({
|
||||
testConnectionAsync: async () => await Promise.resolve({ success: true }),
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any),
|
||||
);
|
||||
factorySpy.mockResolvedValue(mockIntegration() as Awaited<ReturnType<typeof homarrIntegrations.createIntegrationAsync>>);
|
||||
optionsSpy.mockReturnValue([["apiKey"]]);
|
||||
|
||||
const integration = {
|
||||
@@ -64,12 +64,7 @@ describe("testConnectionAsync should run test connection of integration", () =>
|
||||
// Arrange
|
||||
const factorySpy = vi.spyOn(homarrIntegrations, "createIntegrationAsync");
|
||||
const optionsSpy = vi.spyOn(homarrDefinitions, "getAllSecretKindOptions");
|
||||
factorySpy.mockReturnValue(
|
||||
Promise.resolve({
|
||||
testConnectionAsync: async () => await Promise.resolve({ success: true }),
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any),
|
||||
);
|
||||
factorySpy.mockResolvedValue(mockIntegration() as Awaited<ReturnType<typeof homarrIntegrations.createIntegrationAsync>>);
|
||||
optionsSpy.mockReturnValue([["apiKey"]]);
|
||||
|
||||
const integration = {
|
||||
@@ -115,12 +110,7 @@ describe("testConnectionAsync should run test connection of integration", () =>
|
||||
// Arrange
|
||||
const factorySpy = vi.spyOn(homarrIntegrations, "createIntegrationAsync");
|
||||
const optionsSpy = vi.spyOn(homarrDefinitions, "getAllSecretKindOptions");
|
||||
factorySpy.mockReturnValue(
|
||||
Promise.resolve({
|
||||
testConnectionAsync: async () => await Promise.resolve({ success: true }),
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any),
|
||||
);
|
||||
factorySpy.mockResolvedValue(mockIntegration() as Awaited<ReturnType<typeof homarrIntegrations.createIntegrationAsync>>);
|
||||
optionsSpy.mockReturnValue([["apiKey"]]);
|
||||
|
||||
const integration = {
|
||||
@@ -166,12 +156,7 @@ describe("testConnectionAsync should run test connection of integration", () =>
|
||||
// Arrange
|
||||
const factorySpy = vi.spyOn(homarrIntegrations, "createIntegrationAsync");
|
||||
const optionsSpy = vi.spyOn(homarrDefinitions, "getAllSecretKindOptions");
|
||||
factorySpy.mockReturnValue(
|
||||
Promise.resolve({
|
||||
testConnectionAsync: async () => await Promise.resolve({ success: true }),
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any),
|
||||
);
|
||||
factorySpy.mockResolvedValue(mockIntegration() as Awaited<ReturnType<typeof homarrIntegrations.createIntegrationAsync>>);
|
||||
optionsSpy.mockReturnValue([["username", "password"], ["apiKey"]]);
|
||||
|
||||
const integration = {
|
||||
@@ -221,12 +206,7 @@ describe("testConnectionAsync should run test connection of integration", () =>
|
||||
// Arrange
|
||||
const factorySpy = vi.spyOn(homarrIntegrations, "createIntegrationAsync");
|
||||
const optionsSpy = vi.spyOn(homarrDefinitions, "getAllSecretKindOptions");
|
||||
factorySpy.mockReturnValue(
|
||||
Promise.resolve({
|
||||
testConnectionAsync: async () => await Promise.resolve({ success: true }),
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any),
|
||||
);
|
||||
factorySpy.mockResolvedValue(mockIntegration() as Awaited<ReturnType<typeof homarrIntegrations.createIntegrationAsync>>);
|
||||
optionsSpy.mockReturnValue([["username", "password"], ["apiKey"]]);
|
||||
|
||||
const integration = {
|
||||
|
||||
Reference in new issue
Block a user