mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-27 10:05:32 +02:00
shouldDeploy passed undefined/null entries from commit.modified straight into micromatch, which throws "Expected input to be a string" and fails every webhook deployment when watch paths are configured. Filter out non-string values before matching.
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import { shouldDeploy } from "@dokploy/server";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
describe("shouldDeploy", () => {
|
|
it("should deploy when no watch paths are configured", () => {
|
|
expect(shouldDeploy(null, ["src/index.ts"])).toBe(true);
|
|
expect(shouldDeploy([], ["src/index.ts"])).toBe(true);
|
|
});
|
|
|
|
it("should deploy when watch paths match modified files", () => {
|
|
expect(shouldDeploy(["src/**"], ["src/index.ts"])).toBe(true);
|
|
expect(shouldDeploy(["apps/web/**"], ["apps/web/page.tsx"])).toBe(true);
|
|
});
|
|
|
|
it("should not deploy when watch paths do not match", () => {
|
|
expect(shouldDeploy(["src/**"], ["docs/readme.md"])).toBe(false);
|
|
});
|
|
|
|
it("should not throw when modified files contain non-string values", () => {
|
|
expect(() =>
|
|
shouldDeploy(["src/**"], ["src/index.ts", undefined, null] as any),
|
|
).not.toThrow();
|
|
expect(
|
|
shouldDeploy(["src/**"], ["src/index.ts", undefined, null] as any),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("should not throw when modified files are undefined or null", () => {
|
|
expect(() => shouldDeploy(["src/**"], undefined)).not.toThrow();
|
|
expect(() => shouldDeploy(["src/**"], null)).not.toThrow();
|
|
expect(shouldDeploy(["src/**"], undefined)).toBe(false);
|
|
expect(shouldDeploy(["src/**"], null)).toBe(false);
|
|
});
|
|
|
|
it("should not throw when every modified file is non-string", () => {
|
|
expect(() =>
|
|
shouldDeploy(["src/**"], [undefined, undefined] as any),
|
|
).not.toThrow();
|
|
expect(shouldDeploy(["src/**"], [undefined, undefined] as any)).toBe(false);
|
|
});
|
|
});
|