From af3b1a27f4e8d558088c57ded6c4b2be3eba107f Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 24 Oct 2024 23:57:40 -0600 Subject: [PATCH] refactor: update tests --- apps/dokploy/__test__/drop/drop.test.test.ts | 21 ++++++++++---------- apps/dokploy/__test__/vitest.config.ts | 15 ++++++++------ packages/server/package.json | 4 ++++ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/apps/dokploy/__test__/drop/drop.test.test.ts b/apps/dokploy/__test__/drop/drop.test.test.ts index 5df29b55..c906c144 100644 --- a/apps/dokploy/__test__/drop/drop.test.test.ts +++ b/apps/dokploy/__test__/drop/drop.test.test.ts @@ -7,6 +7,17 @@ import { unzipDrop } from "@dokploy/server"; import AdmZip from "adm-zip"; import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; +vi.mock("@dokploy/server/constants", async (importOriginal) => { + const actual = await importOriginal(); + return { + // @ts-ignore + ...actual, + paths: () => ({ + APPLICATIONS_PATH: "./__test__/drop/zips/output", + }), + }; +}); + if (typeof window === "undefined") { const undici = require("undici"); globalThis.File = undici.File as any; @@ -82,16 +93,6 @@ const baseApp: ApplicationNested = { dockerContextPath: null, }; -vi.mock("@dokploy/server/dist/constants", async (importOriginal) => { - const actual = await importOriginal(); - return { - // @ts-ignore - ...actual, - paths: () => ({ - APPLICATIONS_PATH: "./__test__/drop/zips/output", - }), - }; -}); describe("unzipDrop using real zip files", () => { // const { APPLICATIONS_PATH } = paths(); beforeAll(async () => { diff --git a/apps/dokploy/__test__/vitest.config.ts b/apps/dokploy/__test__/vitest.config.ts index c11f6cef..14eabf69 100644 --- a/apps/dokploy/__test__/vitest.config.ts +++ b/apps/dokploy/__test__/vitest.config.ts @@ -1,13 +1,8 @@ +import path from "node:path"; import tsconfigPaths from "vite-tsconfig-paths"; import { defineConfig } from "vitest/config"; export default defineConfig({ - plugins: [ - tsconfigPaths({ - root: "./", - projects: ["tsconfig.json"], - }), - ], test: { include: ["__test__/**/*.test.ts"], // Incluir solo los archivos de test en el directorio __test__ exclude: ["**/node_modules/**", "**/dist/**", "**/.docker/**"], @@ -18,4 +13,12 @@ export default defineConfig({ NODE: "test", }, }, + resolve: { + alias: { + "@dokploy/server": path.resolve( + __dirname, + "../../../packages/server/src", + ), + }, + }, }); diff --git a/packages/server/package.json b/packages/server/package.json index d198fd9e..75532859 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -13,6 +13,10 @@ "import": "./src/setup/*.ts", "require": "./dist/setup/index.cjs.js" }, + "./constants": { + "import": "./src/constants/index.ts", + "require": "./dist/constants.cjs.js" + }, "./dist": { "import": "./dist/index.js", "require": "./dist/index.cjs.js"