From 37c90d53e03f8db922f7cb6e6f47caa899f3b75f Mon Sep 17 00:00:00 2001
From: Joseph Garrone <joseph.garrone.gj@gmail.com>
Date: Sun, 26 May 2024 12:42:13 +0200
Subject: [PATCH] Fix tests

---
 .../setupSampleReactProject.spec.ts.disabled  | 111 ------------------
 test/bin/setupSampleReactProject.ts           |  21 ----
 2 files changed, 132 deletions(-)
 delete mode 100644 test/bin/setupSampleReactProject.spec.ts.disabled
 delete mode 100644 test/bin/setupSampleReactProject.ts

diff --git a/test/bin/setupSampleReactProject.spec.ts.disabled b/test/bin/setupSampleReactProject.spec.ts.disabled
deleted file mode 100644
index 98b6966f..00000000
--- a/test/bin/setupSampleReactProject.spec.ts.disabled
+++ /dev/null
@@ -1,111 +0,0 @@
-import * as fs from "fs";
-import { getProjectRoot } from "keycloakify/bin/tools/getProjectRoot.js";
-import { join as pathJoin } from "path";
-import { downloadAndUnzip } from "keycloakify/bin/tools/downloadAndUnzip";
-import { main as initializeEmailTheme } from "keycloakify/bin/initialize-email-theme";
-import { it, describe, afterAll, beforeAll, beforeEach, vi } from "vitest";
-import { downloadBuiltinKeycloakTheme } from "keycloakify/bin/download-builtin-keycloak-theme";
-import { readBuildOptions } from "keycloakify/bin/keycloakify/BuildOptions";
-
-export const sampleReactProjectDirPath = pathJoin(getProjectRoot(), "sample_react_project");
-
-async function setupSampleReactProject(destDir: string) {
-    await downloadAndUnzip({
-        "url": "https://github.com/keycloakify/keycloakify/releases/download/v0.0.1/sample_build_dir_and_package_json.zip",
-        "destDirPath": destDir,
-        "doUseCache": false
-    });
-}
-let parsedPackageJson: Record<string, unknown> = {};
-vi.mock("keycloakify/bin/keycloakify/parsed-package-json", async () => ({
-    ...((await vi.importActual("keycloakify/bin/keycloakify/parsed-package-json")) as Record<string, unknown>),
-    getParsedPackageJson: () => parsedPackageJson
-}));
-
-vi.mock("keycloakify/bin/promptKeycloakVersion", async () => ({
-    ...((await vi.importActual("keycloakify/bin/promptKeycloakVersion")) as Record<string, unknown>),
-    promptKeycloakVersion: () => ({ "keycloakVersion": "11.0.3" })
-}));
-
-const nativeCwd = process.cwd;
-
-describe("Sample Project", () => {
-    beforeAll(() => {
-        // Monkey patching the cwd to the app location for the duration of this test
-        process.cwd = () => sampleReactProjectDirPath;
-    });
-    afterAll(() => {
-        fs.rmSync(sampleReactProjectDirPath, { "recursive": true });
-        process.cwd = nativeCwd;
-    });
-    beforeEach(() => {
-        if (fs.existsSync(sampleReactProjectDirPath)) {
-            fs.rmSync(sampleReactProjectDirPath, { "recursive": true });
-        }
-
-        fs.mkdirSync(pathJoin(sampleReactProjectDirPath, "src", "keycloak-theme"), { "recursive": true });
-        fs.mkdirSync(pathJoin(sampleReactProjectDirPath, "src", "login"), { "recursive": true });
-    });
-    it(
-        "Sets up the project without error",
-        async () => {
-            await setupSampleReactProject(sampleReactProjectDirPath);
-            await initializeEmailTheme();
-
-            const reactAppRootDirPath = process.cwd();
-
-            const destDirPath = pathJoin(
-                readBuildOptions({
-                    "processArgv": ["--silent"],
-                    reactAppRootDirPath
-                }).keycloakifyBuildDirPath,
-                "src",
-                "main",
-                "resources",
-                "theme"
-            );
-            await downloadBuiltinKeycloakTheme({
-                destDirPath,
-                "keycloakVersion": "11.0.3",
-                "buildOptions": {
-                    "cacheDirPath": pathJoin(reactAppRootDirPath, "node_modules", ".cache", "keycloakify")
-                }
-            });
-        },
-        { timeout: 90000 }
-    );
-    it(
-        "Sets up the project with a custom input and output directory without error",
-        async () => {
-            parsedPackageJson = {
-                "keycloakify": {
-                    "reactAppBuildDirPath": "./custom_input/build",
-                    "keycloakBuildDir": "./custom_output"
-                }
-            };
-            await setupSampleReactProject(pathJoin(sampleReactProjectDirPath, "custom_input"));
-            await initializeEmailTheme();
-
-            const reactAppRootDirPath = process.cwd();
-
-            const destDirPath = pathJoin(
-                readBuildOptions({
-                    "processArgv": ["--silent"],
-                    reactAppRootDirPath
-                }).keycloakifyBuildDirPath,
-                "src",
-                "main",
-                "resources",
-                "theme"
-            );
-            await downloadBuiltinKeycloakTheme({
-                destDirPath,
-                "keycloakVersion": "11.0.3",
-                buildOptions: {
-                    "cacheDirPath": pathJoin(reactAppRootDirPath, "node_modules", ".cache", "keycloakify")
-                }
-            });
-        },
-        { timeout: 90000 }
-    );
-});
diff --git a/test/bin/setupSampleReactProject.ts b/test/bin/setupSampleReactProject.ts
deleted file mode 100644
index 370174de..00000000
--- a/test/bin/setupSampleReactProject.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { downloadAndUnzip } from "keycloakify/bin/shared/downloadAndUnzip";
-import { join as pathJoin } from "path";
-import { getThisCodebaseRootDirPath } from "keycloakify/bin/tools/getThisCodebaseRootDirPath";
-
-export async function setupSampleReactProject(destDirPath: string) {
-    const thisCodebaseRootDirPath = getThisCodebaseRootDirPath();
-
-    await downloadAndUnzip({
-        url: "https://github.com/keycloakify/keycloakify/releases/download/v0.0.1/sample_build_dir_and_package_json.zip",
-        destDirPath: destDirPath,
-        buildOptions: {
-            cacheDirPath: pathJoin(
-                thisCodebaseRootDirPath,
-                "node_modules",
-                ".cache",
-                "keycloakify"
-            ),
-            npmWorkspaceRootDirPath: thisCodebaseRootDirPath
-        }
-    });
-}