feat: integrate Vitest for testing and update workflows

- Added Vitest as a testing framework in package.json and configured test scripts.
- Created new test files for CLI and client functionalities, ensuring comprehensive coverage.
- Updated GitHub Actions workflows to include testing steps and streamlined release process.
- Removed the deprecated onRelease workflow to consolidate CI/CD processes.
This commit is contained in:
Mauricio Siu
2026-04-15 21:00:48 -06:00
parent 0869e2d69a
commit c073a037b1
8 changed files with 978 additions and 45 deletions

86
tests/cli.test.ts Normal file
View File

@@ -0,0 +1,86 @@
import { execFileSync } from "node:child_process";
import * as path from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.resolve(__dirname, "..");
const CLI = path.join(ROOT, "dist", "index.js");
function run(...args: string[]): string {
return execFileSync("node", [CLI, ...args], {
encoding: "utf8",
env: { ...process.env, NO_COLOR: "1" },
});
}
describe("CLI", () => {
it("should show help with --help", () => {
const output = run("--help");
expect(output).toContain("Dokploy CLI");
expect(output).toContain("auth");
expect(output).toContain("application");
expect(output).toContain("project");
});
it("should show version with --version", () => {
const output = run("--version");
expect(output.trim()).toMatch(/^\d+\.\d+\.\d+$/);
});
it("should show subcommands for application", () => {
const output = run("application", "--help");
expect(output).toContain("create");
expect(output).toContain("deploy");
expect(output).toContain("delete");
expect(output).toContain("stop");
});
it("should show subcommands for postgres", () => {
const output = run("postgres", "--help");
expect(output).toContain("create");
expect(output).toContain("deploy");
expect(output).toContain("remove");
});
it("should show options for a specific command", () => {
const output = run("application", "create", "--help");
expect(output).toContain("--name");
expect(output).toContain("--environmentId");
});
it("should show auth command options", () => {
const output = run("auth", "--help");
expect(output).toContain("--url");
expect(output).toContain("--token");
});
it("should show all expected command groups", () => {
const output = run("--help");
const expectedGroups = [
"application",
"postgres",
"mysql",
"redis",
"mongo",
"mariadb",
"compose",
"docker",
"project",
"server",
"domain",
"backup",
"settings",
"user",
"environment",
];
for (const group of expectedGroups) {
expect(output).toContain(group);
}
});
it("should exit with 0 when no args provided", () => {
const output = run();
expect(output).toContain("Usage:");
});
});