Initial Commit
This commit is contained in:
74
packages/foundation/flow/workflow/tests/dep-graph.test.ts
Normal file
74
packages/foundation/flow/workflow/tests/dep-graph.test.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
interface PkgJson {
|
||||
dependencies?: Record<string, string>;
|
||||
peerDependencies?: Record<string, string>;
|
||||
exports?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
const pkg = JSON.parse(
|
||||
readFileSync(join(__dirname, "..", "package.json"), "utf8")
|
||||
) as PkgJson;
|
||||
|
||||
describe("dep-graph", () => {
|
||||
it("runtime @suaveplan deps are exactly error + events + types", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const runtimeScoped = Object.keys(pkg.dependencies ?? {})
|
||||
.filter((name) => name.startsWith("@suaveplan/"))
|
||||
.sort();
|
||||
expect(runtimeScoped).toEqual([
|
||||
"@suaveplan/error",
|
||||
"@suaveplan/events",
|
||||
"@suaveplan/types",
|
||||
]);
|
||||
});
|
||||
|
||||
it("no peer @suaveplan deps", { timeout: 5000 }, () => {
|
||||
const peers = Object.keys(pkg.peerDependencies ?? {}).filter((n) =>
|
||||
n.startsWith("@suaveplan/")
|
||||
);
|
||||
expect(peers).toEqual([]);
|
||||
});
|
||||
|
||||
it("runtime deps are exactly the expected set (sorted)", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const runtime = Object.keys(pkg.dependencies ?? {}).sort();
|
||||
expect(runtime).toEqual([
|
||||
"@opentelemetry/api",
|
||||
"@suaveplan/error",
|
||||
"@suaveplan/events",
|
||||
"@suaveplan/types",
|
||||
"tslib",
|
||||
"zod",
|
||||
]);
|
||||
});
|
||||
|
||||
it("package exports map covers every feature module", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const sub = Object.keys(pkg.exports ?? {}).filter(
|
||||
(k) => k !== "./package.json"
|
||||
);
|
||||
const required = [
|
||||
".",
|
||||
"./core/workflow-engine/workflow-engine",
|
||||
"./core/workflow-builder/workflow-builder",
|
||||
"./core/context/context",
|
||||
"./steps/step/step",
|
||||
"./steps/parallel-step/parallel-step",
|
||||
"./steps/conditional-step/conditional-step",
|
||||
"./compensation/saga/saga",
|
||||
"./compensation/compensator/compensator",
|
||||
"./middleware/hook/hook",
|
||||
"./middleware/retry/retry",
|
||||
"./errors",
|
||||
"./otel",
|
||||
];
|
||||
for (const r of required) expect(sub).toContain(r);
|
||||
expect(sub.length).toBeGreaterThanOrEqual(12);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import { webcrypto } from "node:crypto";
|
||||
|
||||
type WritableGlobal = { crypto?: Crypto };
|
||||
const g = globalThis as WritableGlobal;
|
||||
if (g.crypto === undefined) {
|
||||
g.crypto = webcrypto as unknown as Crypto;
|
||||
}
|
||||
Reference in New Issue
Block a user