@powerhousedao/switchboard 6.2.3-dev.9 → 6.2.3-dev.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.tsbuild/test/ai-gateway.test.d.ts +2 -0
- package/.tsbuild/test/ai-gateway.test.d.ts.map +1 -0
- package/.tsbuild/test/attachments/byte-grants.test.d.ts +2 -0
- package/.tsbuild/test/attachments/byte-grants.test.d.ts.map +1 -0
- package/.tsbuild/test/attachments/byte-routes-read-gate.integration.test.d.ts +2 -0
- package/.tsbuild/test/attachments/byte-routes-read-gate.integration.test.d.ts.map +1 -0
- package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts +2 -0
- package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts.map +1 -0
- package/.tsbuild/test/attachments/url-signer.test.d.ts +2 -0
- package/.tsbuild/test/attachments/url-signer.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-auth-config.test.d.ts +2 -0
- package/.tsbuild/test/boot-auth-config.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-create-signature-policy.test.d.ts +2 -0
- package/.tsbuild/test/boot-create-signature-policy.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-desktop-auth.test.d.ts +2 -0
- package/.tsbuild/test/boot-desktop-auth.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-env-isolation.test.d.ts +2 -0
- package/.tsbuild/test/boot-env-isolation.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-helpers.d.ts +5 -0
- package/.tsbuild/test/boot-helpers.d.ts.map +1 -0
- package/.tsbuild/test/boot-inspection-enabled.test.d.ts +2 -0
- package/.tsbuild/test/boot-inspection-enabled.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-mcp-auth.test.d.ts +2 -0
- package/.tsbuild/test/boot-mcp-auth.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-mcp-enabled.test.d.ts +2 -0
- package/.tsbuild/test/boot-mcp-enabled.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-port-zero.test.d.ts +2 -0
- package/.tsbuild/test/boot-port-zero.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-preconditions.test.d.ts +2 -0
- package/.tsbuild/test/boot-preconditions.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-privacy.test.d.ts +2 -0
- package/.tsbuild/test/boot-privacy.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-ready-drives.test.d.ts +2 -0
- package/.tsbuild/test/boot-ready-drives.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-unsupported-stored-documents.test.d.ts +2 -0
- package/.tsbuild/test/boot-unsupported-stored-documents.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-without-renown.test.d.ts +2 -0
- package/.tsbuild/test/boot-without-renown.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-without-require-signatures.test.d.ts +2 -0
- package/.tsbuild/test/boot-without-require-signatures.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-worker-trust-policy.test.d.ts +2 -0
- package/.tsbuild/test/boot-worker-trust-policy.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts +2 -0
- package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts +2 -0
- package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts.map +1 -0
- package/.tsbuild/test/builder-defaults.test.d.ts +2 -0
- package/.tsbuild/test/builder-defaults.test.d.ts.map +1 -0
- package/.tsbuild/test/config-from-env.test.d.ts +2 -0
- package/.tsbuild/test/config-from-env.test.d.ts.map +1 -0
- package/.tsbuild/test/config-merge.test.d.ts +2 -0
- package/.tsbuild/test/config-merge.test.d.ts.map +1 -0
- package/.tsbuild/test/config-schema.test.d.ts +2 -0
- package/.tsbuild/test/config-schema.test.d.ts.map +1 -0
- package/.tsbuild/test/create-signature-policy.test.d.ts +2 -0
- package/.tsbuild/test/create-signature-policy.test.d.ts.map +1 -0
- package/.tsbuild/test/default-drive-protocol-versions.test.d.ts +2 -0
- package/.tsbuild/test/default-drive-protocol-versions.test.d.ts.map +1 -0
- package/.tsbuild/test/default-drive-slug.test.d.ts +2 -0
- package/.tsbuild/test/default-drive-slug.test.d.ts.map +1 -0
- package/.tsbuild/test/delegated-publish.test.d.ts +2 -0
- package/.tsbuild/test/delegated-publish.test.d.ts.map +1 -0
- package/.tsbuild/test/durable-node-fs-pg16.test.d.ts +2 -0
- package/.tsbuild/test/durable-node-fs-pg16.test.d.ts.map +1 -0
- package/.tsbuild/test/fatal-shutdown.test.d.ts +2 -0
- package/.tsbuild/test/fatal-shutdown.test.d.ts.map +1 -0
- package/.tsbuild/test/inspection-throttle.test.d.ts +2 -0
- package/.tsbuild/test/inspection-throttle.test.d.ts.map +1 -0
- package/.tsbuild/test/keyframe-reclaim-store.test.d.ts +2 -0
- package/.tsbuild/test/keyframe-reclaim-store.test.d.ts.map +1 -0
- package/.tsbuild/test/observability-signals.test.d.ts +2 -0
- package/.tsbuild/test/observability-signals.test.d.ts.map +1 -0
- package/.tsbuild/test/permissions-backfill.test.d.ts +2 -0
- package/.tsbuild/test/permissions-backfill.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-preflight.test.d.ts +2 -0
- package/.tsbuild/test/pglite-preflight.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-storage-dirs.test.d.ts +2 -0
- package/.tsbuild/test/pglite-storage-dirs.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-store.test.d.ts +2 -0
- package/.tsbuild/test/pglite-store.test.d.ts.map +1 -0
- package/.tsbuild/test/plugin-config-schemas.test.d.ts +2 -0
- package/.tsbuild/test/plugin-config-schemas.test.d.ts.map +1 -0
- package/.tsbuild/test/plugin-presence.test.d.ts +2 -0
- package/.tsbuild/test/plugin-presence.test.d.ts.map +1 -0
- package/.tsbuild/test/port-probe.test.d.ts +2 -0
- package/.tsbuild/test/port-probe.test.d.ts.map +1 -0
- package/.tsbuild/test/processor-timing-log.test.d.ts +2 -0
- package/.tsbuild/test/processor-timing-log.test.d.ts.map +1 -0
- package/.tsbuild/test/renown-storage-path.test.d.ts +2 -0
- package/.tsbuild/test/renown-storage-path.test.d.ts.map +1 -0
- package/.tsbuild/test/renown-trust-policy.test.d.ts +2 -0
- package/.tsbuild/test/renown-trust-policy.test.d.ts.map +1 -0
- package/.tsbuild/test/served-schemas.test.d.ts +2 -0
- package/.tsbuild/test/served-schemas.test.d.ts.map +1 -0
- package/.tsbuild/test/shutdown.test.d.ts +2 -0
- package/.tsbuild/test/shutdown.test.d.ts.map +1 -0
- package/.tsbuild/test/snapshot-writer.d.ts +18 -0
- package/.tsbuild/test/snapshot-writer.d.ts.map +1 -0
- package/.tsbuild/test/store-lock.test.d.ts +2 -0
- package/.tsbuild/test/store-lock.test.d.ts.map +1 -0
- package/.tsbuild/test/two-switchboards.test.d.ts +2 -0
- package/.tsbuild/test/two-switchboards.test.d.ts.map +1 -0
- package/.tsbuild/test/unsupported-stored-documents.test.d.ts +2 -0
- package/.tsbuild/test/unsupported-stored-documents.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/harness.d.ts +56 -0
- package/.tsbuild/test/workflow/harness.d.ts.map +1 -0
- package/.tsbuild/test/workflow/oauth-apps-config.test.d.ts +2 -0
- package/.tsbuild/test/workflow/oauth-apps-config.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/oauth.test.d.ts +2 -0
- package/.tsbuild/test/workflow/oauth.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/resolvers.test.d.ts +2 -0
- package/.tsbuild/test/workflow/resolvers.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/runtime-host.test.d.ts +2 -0
- package/.tsbuild/test/workflow/runtime-host.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts +2 -0
- package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts +2 -0
- package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/webhook-dedupe.test.d.ts +2 -0
- package/.tsbuild/test/workflow/webhook-dedupe.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/webhook-signed.test.d.ts +2 -0
- package/.tsbuild/test/workflow/webhook-signed.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/webhook-trigger-test.test.d.ts +2 -0
- package/.tsbuild/test/workflow/webhook-trigger-test.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/webhook-unsigned.test.d.ts +2 -0
- package/.tsbuild/test/workflow/webhook-unsigned.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow-reactor-access.test.d.ts +2 -0
- package/.tsbuild/test/workflow-reactor-access.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts +2 -0
- package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow-read-gate.test.d.ts +2 -0
- package/.tsbuild/test/workflow-read-gate.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow-runtime.test.d.ts +2 -0
- package/.tsbuild/test/workflow-runtime.test.d.ts.map +1 -0
- package/.tsbuild/test/workflows-plugin-config.test.d.ts +2 -0
- package/.tsbuild/test/workflows-plugin-config.test.d.ts.map +1 -0
- package/.tsbuild/tsconfig.tsbuildinfo +1 -1
- package/.tsbuild/tsdown.config.d.ts.map +1 -1
- package/.tsbuild/vitest.config.d.ts.map +1 -1
- package/Auth.md +144 -2
- package/CHANGELOG.md +1206 -0
- package/README.md +88 -14
- package/dist/boot.d.mts +46 -0
- package/dist/boot.d.mts.map +1 -0
- package/dist/boot.mjs +67 -0
- package/dist/boot.mjs.map +1 -0
- package/dist/config/from-env.d.mts +15 -0
- package/dist/config/from-env.d.mts.map +1 -0
- package/dist/config/from-env.mjs +4 -0
- package/dist/config/schema.d.mts +3 -0
- package/dist/config/schema.mjs +4 -0
- package/dist/from-env-DJ4iQ3QZ.mjs +473 -0
- package/dist/from-env-DJ4iQ3QZ.mjs.map +1 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +84 -84
- package/dist/index.mjs.map +1 -1
- package/dist/install-packages.d.mts +2 -1
- package/dist/install-packages.mjs +2 -2
- package/dist/install-packages.mjs.map +1 -1
- package/dist/mcp-SsBK14Jm.mjs +32 -0
- package/dist/mcp-SsBK14Jm.mjs.map +1 -0
- package/dist/migrate.d.mts +2 -1
- package/dist/migrate.mjs +7 -5
- package/dist/migrate.mjs.map +1 -1
- package/dist/plugin-host-BHEUSn9G.d.mts +46 -0
- package/dist/plugin-host-BHEUSn9G.d.mts.map +1 -0
- package/dist/plugins/ai.d.mts +37 -0
- package/dist/plugins/ai.d.mts.map +1 -0
- package/dist/plugins/ai.mjs +400 -0
- package/dist/plugins/ai.mjs.map +1 -0
- package/dist/plugins/attachments.d.mts +33 -0
- package/dist/plugins/attachments.d.mts.map +1 -0
- package/dist/plugins/attachments.mjs +4 -0
- package/dist/plugins/mcp.d.mts +31 -0
- package/dist/plugins/mcp.d.mts.map +1 -0
- package/dist/plugins/mcp.mjs +4 -0
- package/dist/plugins/privacy.d.mts +22 -0
- package/dist/plugins/privacy.d.mts.map +1 -0
- package/dist/plugins/privacy.mjs +4 -0
- package/dist/plugins/workflows.d.mts +79 -0
- package/dist/plugins/workflows.d.mts.map +1 -0
- package/dist/plugins/workflows.mjs +4 -0
- package/dist/postgres-url-DTDhBjXX.mjs +11 -0
- package/dist/postgres-url-DTDhBjXX.mjs.map +1 -0
- package/dist/privacy-BO8Q25xI.mjs +44 -0
- package/dist/privacy-BO8Q25xI.mjs.map +1 -0
- package/dist/privacy-DxIJGH4P.mjs +91 -0
- package/dist/privacy-DxIJGH4P.mjs.map +1 -0
- package/dist/renown-layers-COZsrGQT.mjs +40 -0
- package/dist/renown-layers-COZsrGQT.mjs.map +1 -0
- package/dist/schema-1yj85yQD.mjs +326 -0
- package/dist/schema-1yj85yQD.mjs.map +1 -0
- package/dist/schema-ugrJupVH.d.mts +246 -0
- package/dist/schema-ugrJupVH.d.mts.map +1 -0
- package/dist/server-CgDvrUqE.mjs +2729 -0
- package/dist/server-CgDvrUqE.mjs.map +1 -0
- package/dist/server.d.mts +129 -189
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +5 -5
- package/dist/types-DzO3_320.d.mts +308 -0
- package/dist/types-DzO3_320.d.mts.map +1 -0
- package/dist/utils-Cm0TE6dP.mjs +148 -0
- package/dist/utils-Cm0TE6dP.mjs.map +1 -0
- package/dist/utils.d.mts +30 -5
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +5 -4
- package/dist/worker-pool-gyxJnCxA.mjs +304 -0
- package/dist/worker-pool-gyxJnCxA.mjs.map +1 -0
- package/dist/workflow-runtime-CF5pc8mt.d.mts +33 -0
- package/dist/workflow-runtime-CF5pc8mt.d.mts.map +1 -0
- package/dist/workflows-C9BQlyT0.mjs +1943 -0
- package/dist/workflows-C9BQlyT0.mjs.map +1 -0
- package/package.json +85 -24
- package/scripts/install-packages.sh +0 -0
- package/test/ai-gateway.test.ts +612 -0
- package/test/attachment-reference-read-model.test.ts +28 -20
- package/test/attachments/auth.test.ts +85 -0
- package/test/attachments/byte-grants.test.ts +290 -0
- package/test/attachments/byte-routes-read-gate.integration.test.ts +314 -0
- package/test/attachments/download-target.test.ts +211 -32
- package/test/attachments/index.test.ts +47 -4
- package/test/attachments/reserve-metadata-parity.test.ts +96 -0
- package/test/attachments/routes-integration.test.ts +60 -4
- package/test/attachments/routes.test.ts +297 -35
- package/test/attachments/service-config.test.ts +41 -19
- package/test/attachments/url-signer.test.ts +105 -0
- package/test/boot-auth-config.test.ts +109 -0
- package/test/boot-create-signature-policy.test.ts +110 -0
- package/test/boot-desktop-auth.test.ts +278 -0
- package/test/boot-env-isolation.test.ts +26 -0
- package/test/boot-helpers.ts +19 -0
- package/test/boot-inspection-enabled.test.ts +140 -0
- package/test/boot-mcp-auth.test.ts +449 -0
- package/test/boot-mcp-enabled.test.ts +119 -0
- package/test/boot-port-zero.test.ts +101 -0
- package/test/boot-preconditions.test.ts +213 -0
- package/test/boot-privacy.test.ts +232 -0
- package/test/boot-ready-drives.test.ts +141 -0
- package/test/boot-unsupported-stored-documents.test.ts +214 -0
- package/test/boot-without-renown.test.ts +83 -0
- package/test/boot-without-require-signatures.test.ts +76 -0
- package/test/boot-worker-trust-policy.test.ts +91 -0
- package/test/boot-workflow-singleton-conflict.test.ts +109 -0
- package/test/boot-workflow-singleton-retry.test.ts +122 -0
- package/test/builder-defaults.test.ts +80 -0
- package/test/config-from-env.test.ts +942 -0
- package/test/config-merge.test.ts +226 -0
- package/test/config-schema.test.ts +156 -0
- package/test/create-signature-policy.test.ts +69 -0
- package/test/default-drive-protocol-versions.test.ts +79 -0
- package/test/default-drive-slug.test.ts +265 -0
- package/test/delegated-publish.test.ts +435 -0
- package/test/durable-node-fs-pg16.test.ts +80 -0
- package/test/fatal-shutdown.test.ts +205 -0
- package/test/goldens/packages.graphql +797 -0
- package/test/goldens/privacy.graphql +853 -0
- package/test/goldens/reactor-drive-nodes.graphql +827 -0
- package/test/goldens/resolvers.json +327 -0
- package/test/goldens/supergraph.graphql +5918 -0
- package/test/goldens/workflow-runtime.graphql +1548 -0
- package/test/inspection-throttle.test.ts +23 -0
- package/test/keyframe-reclaim-store.test.ts +156 -0
- package/test/observability-signals.test.ts +131 -0
- package/test/permissions-backfill.test.ts +486 -0
- package/test/pglite-dialect.test.ts +237 -2
- package/test/pglite-preflight.test.ts +313 -0
- package/test/pglite-storage-dirs.test.ts +113 -0
- package/test/pglite-store.test.ts +441 -0
- package/test/pglite-version.test.ts +9 -1
- package/test/plugin-config-schemas.test.ts +83 -0
- package/test/plugin-presence.test.ts +262 -0
- package/test/port-probe.test.ts +45 -0
- package/test/processor-timing-log.test.ts +109 -0
- package/test/redact-webhook-path.test.ts +9 -0
- package/test/renown-storage-path.test.ts +40 -0
- package/test/renown-trust-policy.test.ts +313 -0
- package/test/served-schemas.test.ts +134 -0
- package/test/shutdown.test.ts +278 -0
- package/test/snapshot-writer.ts +94 -0
- package/test/store-lock.test.ts +65 -0
- package/test/two-switchboards.test.ts +146 -0
- package/test/unsupported-stored-documents.test.ts +72 -0
- package/test/worker-pool.test.ts +27 -1
- package/test/workflow/harness.ts +289 -0
- package/test/workflow/oauth-apps-config.test.ts +66 -0
- package/test/workflow/oauth.test.ts +286 -0
- package/test/workflow/resolvers.test.ts +488 -0
- package/test/workflow/runtime-host.test.ts +19 -0
- package/test/workflow/waitpoint-routes.test.ts +306 -0
- package/test/workflow/waitpoint-runtime.test.ts +204 -0
- package/test/workflow/webhook-dedupe.test.ts +295 -0
- package/test/workflow/webhook-signed.test.ts +509 -0
- package/test/workflow/webhook-trigger-test.test.ts +82 -0
- package/test/workflow/webhook-unsigned.test.ts +345 -0
- package/test/workflow-reactor-access.test.ts +384 -0
- package/test/workflow-reactor-enforcement.test.ts +808 -0
- package/test/workflow-read-gate.test.ts +213 -0
- package/test/workflow-runtime.test.ts +1254 -0
- package/test/workflows-plugin-config.test.ts +77 -0
- package/tsconfig.json +11 -2
- package/tsdown.config.ts +13 -1
- package/vitest.config.ts +65 -0
- package/dist/server-CiKkVE6g.mjs +0 -1555
- package/dist/server-CiKkVE6g.mjs.map +0 -1
- package/dist/utils-Baw7rThP.mjs +0 -80
- package/dist/utils-Baw7rThP.mjs.map +0 -1
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
// The resume URL over a real socket: GET never resumes, the confirm page
|
|
2
|
+
// escapes what it shows, and POST hands the request to the runtime.
|
|
3
|
+
import {
|
|
4
|
+
createHttpAdapter,
|
|
5
|
+
HttpRouteService,
|
|
6
|
+
} from "@powerhousedao/reactor-api";
|
|
7
|
+
import {
|
|
8
|
+
afterAll,
|
|
9
|
+
beforeAll,
|
|
10
|
+
beforeEach,
|
|
11
|
+
describe,
|
|
12
|
+
expect,
|
|
13
|
+
it,
|
|
14
|
+
vi,
|
|
15
|
+
} from "vitest";
|
|
16
|
+
import {
|
|
17
|
+
MAX_REASON_LENGTH,
|
|
18
|
+
registerWaitpointRoutes,
|
|
19
|
+
waitpointBaseUrlOf,
|
|
20
|
+
type WaitpointRouteRuntime,
|
|
21
|
+
} from "../../src/workflow/waitpoint-routes.js";
|
|
22
|
+
|
|
23
|
+
const TOKEN = "tok_abc";
|
|
24
|
+
|
|
25
|
+
describe("the waitpoint resume routes", () => {
|
|
26
|
+
let base: string;
|
|
27
|
+
let close: () => Promise<void>;
|
|
28
|
+
const runtime = {
|
|
29
|
+
describeWaitpointByToken:
|
|
30
|
+
vi.fn<WaitpointRouteRuntime["describeWaitpointByToken"]>(),
|
|
31
|
+
resumeWaitpointByToken:
|
|
32
|
+
vi.fn<WaitpointRouteRuntime["resumeWaitpointByToken"]>(),
|
|
33
|
+
resumeWaitpointByTokenSync:
|
|
34
|
+
vi.fn<WaitpointRouteRuntime["resumeWaitpointByTokenSync"]>(),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
beforeAll(async () => {
|
|
38
|
+
const { adapter } = await createHttpAdapter("express");
|
|
39
|
+
adapter.setupMiddleware({});
|
|
40
|
+
const server = await adapter.listen(0, undefined, "127.0.0.1");
|
|
41
|
+
const { port } = server.address() as { port: number };
|
|
42
|
+
const url = `http://127.0.0.1:${port}`;
|
|
43
|
+
const routes = new HttpRouteService({
|
|
44
|
+
httpAdapter: adapter,
|
|
45
|
+
publicUrl: url,
|
|
46
|
+
});
|
|
47
|
+
const scope = routes.scopeFor("@powerhousedao/workflow");
|
|
48
|
+
registerWaitpointRoutes(scope, runtime);
|
|
49
|
+
base = `${waitpointBaseUrlOf(scope)!}/${TOKEN}`;
|
|
50
|
+
close = () => new Promise((done) => server.close(() => done()));
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
afterAll(() => close());
|
|
54
|
+
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
runtime.describeWaitpointByToken.mockReset().mockResolvedValue({
|
|
57
|
+
workflowName: "Invoice <b>approval</b>",
|
|
58
|
+
stepName: `Ask "finance"`,
|
|
59
|
+
status: "PENDING",
|
|
60
|
+
waitingSince: "2026-10-28T09:30:00.000Z",
|
|
61
|
+
});
|
|
62
|
+
runtime.resumeWaitpointByToken
|
|
63
|
+
.mockReset()
|
|
64
|
+
.mockResolvedValue({ status: "resumed" });
|
|
65
|
+
runtime.resumeWaitpointByTokenSync.mockReset().mockResolvedValue({
|
|
66
|
+
status: "resumed",
|
|
67
|
+
reply: {
|
|
68
|
+
status: 201,
|
|
69
|
+
contentType: "application/json",
|
|
70
|
+
body: '{"ok":true}',
|
|
71
|
+
headers: { "x-next": "later" },
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const form = (action: string, reason = "", accept = "text/html") =>
|
|
77
|
+
fetch(`${base}/confirm?action=${action}`, {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: {
|
|
80
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
81
|
+
accept,
|
|
82
|
+
},
|
|
83
|
+
body: new URLSearchParams({ reason }).toString(),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("lives under the workflow package's namespace", () => {
|
|
87
|
+
expect(base).toMatch(
|
|
88
|
+
/\/api\/@powerhousedao\/workflow\/waitpoints\/tok_abc$/,
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("serves no resume URL from a host with no public origin", async () => {
|
|
93
|
+
const { adapter } = await createHttpAdapter("express");
|
|
94
|
+
const routes = new HttpRouteService({ httpAdapter: adapter });
|
|
95
|
+
const scope = routes.scopeFor("@powerhousedao/workflow");
|
|
96
|
+
expect(scope.baseUrl).toMatch(/^\/api\//);
|
|
97
|
+
expect(waitpointBaseUrlOf(scope)).toBeUndefined();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// The bare URL's page posts to /confirm, relative to the token.
|
|
101
|
+
it.each([
|
|
102
|
+
[
|
|
103
|
+
"GET",
|
|
104
|
+
"?action=approve",
|
|
105
|
+
200,
|
|
106
|
+
'formaction="tok_abc/confirm?action=approve"',
|
|
107
|
+
],
|
|
108
|
+
["GET", "/sync", 405, undefined],
|
|
109
|
+
["GET", "/confirm", 200, "<form"],
|
|
110
|
+
["HEAD", "", 200, ""],
|
|
111
|
+
["HEAD", "/sync", 405, ""],
|
|
112
|
+
["HEAD", "/confirm", 200, ""],
|
|
113
|
+
] as const)(
|
|
114
|
+
"never resumes on %s %s, answering %i",
|
|
115
|
+
async (method, path, status, body) => {
|
|
116
|
+
const response = await fetch(`${base}${path}`, { method });
|
|
117
|
+
expect(response.status).toBe(status);
|
|
118
|
+
if (status === 405) expect(response.headers.get("allow")).toBe("POST");
|
|
119
|
+
const text = await response.text();
|
|
120
|
+
if (body === "") expect(text).toBe("");
|
|
121
|
+
else if (body) expect(text).toContain(body);
|
|
122
|
+
expect(runtime.resumeWaitpointByToken).not.toHaveBeenCalled();
|
|
123
|
+
expect(runtime.resumeWaitpointByTokenSync).not.toHaveBeenCalled();
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
it("serves an escaped confirm page under a strict CSP", async () => {
|
|
128
|
+
const response = await fetch(`${base}/confirm?x=1`);
|
|
129
|
+
expect(response.status).toBe(200);
|
|
130
|
+
expect(response.headers.get("content-type")).toContain("text/html");
|
|
131
|
+
const csp = response.headers.get("content-security-policy") ?? "";
|
|
132
|
+
expect(csp).toContain("default-src 'none'");
|
|
133
|
+
expect(csp).toContain("form-action 'self'");
|
|
134
|
+
expect(response.headers.get("referrer-policy")).toBe("no-referrer");
|
|
135
|
+
const body = await response.text();
|
|
136
|
+
expect(runtime.describeWaitpointByToken).toHaveBeenCalledWith(TOKEN);
|
|
137
|
+
expect(body).toContain("Invoice <b>approval</b>");
|
|
138
|
+
expect(body).toContain("Ask "finance"");
|
|
139
|
+
expect(body).not.toContain("<b>");
|
|
140
|
+
expect(body).not.toContain("<script");
|
|
141
|
+
expect(body).toContain('formaction="?x=1&action=approve"');
|
|
142
|
+
expect(body).toContain('formaction="?x=1&action=disapprove"');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("describes the workflow and the wait, times in UTC", async () => {
|
|
146
|
+
runtime.describeWaitpointByToken.mockResolvedValueOnce({
|
|
147
|
+
workflowName: "Vendor sign-off",
|
|
148
|
+
workflowDescription: "Ask <the vendor> to sign off\non the new terms.",
|
|
149
|
+
stepName: "Ask vendor",
|
|
150
|
+
actionName: "Create Approval Links",
|
|
151
|
+
status: "PENDING",
|
|
152
|
+
startedAt: "2026-10-28T09:29:00.000Z",
|
|
153
|
+
triggerName: "Manual Trigger",
|
|
154
|
+
waitingSince: "2026-10-28T09:30:00.000Z",
|
|
155
|
+
expiresAt: "2026-11-04T09:30:00.000Z",
|
|
156
|
+
});
|
|
157
|
+
const body = await (await fetch(`${base}/confirm`)).text();
|
|
158
|
+
expect(body).toContain(
|
|
159
|
+
"Ask <the vendor> to sign off\non the new terms.",
|
|
160
|
+
);
|
|
161
|
+
expect(body).toContain("<dd>Ask vendor · Create Approval Links</dd>");
|
|
162
|
+
expect(body).toContain(
|
|
163
|
+
"<dd>28 Oct 2026, 09:29 UTC, by Manual Trigger</dd>",
|
|
164
|
+
);
|
|
165
|
+
expect(body).toContain(
|
|
166
|
+
"<dt>Waiting since</dt><dd>28 Oct 2026, 09:30 UTC</dd>",
|
|
167
|
+
);
|
|
168
|
+
expect(body).toContain("<dt>Expires</dt><dd>4 Nov 2026, 09:30 UTC</dd>");
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("names the action only when the step's own name differs", async () => {
|
|
172
|
+
runtime.describeWaitpointByToken.mockResolvedValueOnce({
|
|
173
|
+
workflowName: "wf",
|
|
174
|
+
stepName: "Create approval links",
|
|
175
|
+
actionName: "Create Approval Links",
|
|
176
|
+
status: "PENDING",
|
|
177
|
+
waitingSince: "2026-10-28T09:30:00.000Z",
|
|
178
|
+
});
|
|
179
|
+
const body = await (await fetch(`${base}/confirm`)).text();
|
|
180
|
+
expect(body).toContain("<dd>Create approval links</dd>");
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it.each([
|
|
184
|
+
["COMPLETED", "Already responded"],
|
|
185
|
+
["CONSUMED", "Already responded"],
|
|
186
|
+
["EXPIRED", "Request expired"],
|
|
187
|
+
["CANCELLED", "Run cancelled"],
|
|
188
|
+
] as const)("shows a %s waitpoint without a form", async (status, title) => {
|
|
189
|
+
runtime.describeWaitpointByToken.mockResolvedValueOnce({
|
|
190
|
+
workflowName: "wf",
|
|
191
|
+
stepName: "step",
|
|
192
|
+
status,
|
|
193
|
+
waitingSince: "2026-10-28T09:30:00.000Z",
|
|
194
|
+
});
|
|
195
|
+
const body = await (await fetch(`${base}/confirm`)).text();
|
|
196
|
+
expect(body).toContain(title);
|
|
197
|
+
expect(body).not.toContain("<form");
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("answers 404 for a token the runtime does not know", async () => {
|
|
201
|
+
runtime.describeWaitpointByToken.mockResolvedValueOnce(undefined);
|
|
202
|
+
expect((await fetch(`${base}/confirm`)).status).toBe(404);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("resumes on POST with body, headers and query, answering JSON", async () => {
|
|
206
|
+
const response = await fetch(`${base}?a=1`, {
|
|
207
|
+
method: "POST",
|
|
208
|
+
headers: {
|
|
209
|
+
"content-type": "application/json",
|
|
210
|
+
authorization: "Bearer secret",
|
|
211
|
+
},
|
|
212
|
+
body: JSON.stringify({ ok: true }),
|
|
213
|
+
});
|
|
214
|
+
expect(response.status).toBe(200);
|
|
215
|
+
expect(await response.json()).toMatchObject({ status: "resumed" });
|
|
216
|
+
const [token, payload] = runtime.resumeWaitpointByToken.mock.calls[0]!;
|
|
217
|
+
expect(token).toBe(TOKEN);
|
|
218
|
+
expect(payload.body).toEqual({ ok: true });
|
|
219
|
+
expect(payload.queryParams).toEqual({ a: "1" });
|
|
220
|
+
expect(payload.headers?.["content-type"]).toBe("application/json");
|
|
221
|
+
// Credentials are not journaled with the payload.
|
|
222
|
+
expect(payload.headers?.authorization).toBeUndefined();
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it("answers the sync sub-path with the resumed run's reply", async () => {
|
|
226
|
+
const response = await fetch(`${base}/sync`, { method: "POST" });
|
|
227
|
+
expect(runtime.resumeWaitpointByTokenSync).toHaveBeenCalledOnce();
|
|
228
|
+
expect(runtime.resumeWaitpointByToken).not.toHaveBeenCalled();
|
|
229
|
+
expect(response.status).toBe(201);
|
|
230
|
+
expect(response.headers.get("x-next")).toBe("later");
|
|
231
|
+
expect(await response.json()).toEqual({ ok: true });
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it("answers a gone waitpoint on the sync sub-path with 410", async () => {
|
|
235
|
+
runtime.resumeWaitpointByTokenSync.mockResolvedValue({ status: "gone" });
|
|
236
|
+
const response = await fetch(`${base}/sync`, { method: "POST" });
|
|
237
|
+
expect(response.status).toBe(410);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("answers the confirm form with an HTML page", async () => {
|
|
241
|
+
const response = await form("disapprove", "too expensive");
|
|
242
|
+
expect(response.headers.get("content-type")).toContain("text/html");
|
|
243
|
+
expect(await response.text()).toContain("You disapproved this request.");
|
|
244
|
+
const [, payload] = runtime.resumeWaitpointByToken.mock.calls[0]!;
|
|
245
|
+
expect(payload.body).toEqual({ reason: "too expensive" });
|
|
246
|
+
expect(payload.queryParams).toEqual({
|
|
247
|
+
action: "disapprove",
|
|
248
|
+
reason: "too expensive",
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("refuses a confirm POST without an action, recording nothing", async () => {
|
|
253
|
+
expect((await form("maybe")).status).toBe(400);
|
|
254
|
+
expect(runtime.resumeWaitpointByToken).not.toHaveBeenCalled();
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it("refuses an over-long reason, recording nothing", async () => {
|
|
258
|
+
const response = await form("approve", "x".repeat(MAX_REASON_LENGTH + 1));
|
|
259
|
+
expect(response.status).toBe(400);
|
|
260
|
+
expect(runtime.resumeWaitpointByToken).not.toHaveBeenCalled();
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it("refuses a body past 1 MiB", async () => {
|
|
264
|
+
const response = await fetch(base, {
|
|
265
|
+
method: "POST",
|
|
266
|
+
headers: { "content-type": "text/plain" },
|
|
267
|
+
body: "x".repeat(1_048_577),
|
|
268
|
+
});
|
|
269
|
+
expect(response.status).toBe(413);
|
|
270
|
+
expect(runtime.resumeWaitpointByToken).not.toHaveBeenCalled();
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it("answers a repeat as already responded and a gone waitpoint as 410", async () => {
|
|
274
|
+
runtime.resumeWaitpointByToken.mockResolvedValueOnce({ status: "already" });
|
|
275
|
+
const already = await form("approve");
|
|
276
|
+
expect(already.status).toBe(200);
|
|
277
|
+
expect(await already.text()).toContain("Already responded");
|
|
278
|
+
|
|
279
|
+
runtime.resumeWaitpointByToken.mockResolvedValueOnce({ status: "gone" });
|
|
280
|
+
const gone = await fetch(base, { method: "POST" });
|
|
281
|
+
expect(gone.status).toBe(410);
|
|
282
|
+
expect(await gone.json()).toMatchObject({
|
|
283
|
+
status: "gone",
|
|
284
|
+
discarded: true,
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("tells a sub-flow's response whether it was discarded", async () => {
|
|
289
|
+
const respond = () =>
|
|
290
|
+
fetch(base, {
|
|
291
|
+
method: "POST",
|
|
292
|
+
headers: { "content-type": "application/json" },
|
|
293
|
+
body: JSON.stringify({ status: "success", data: { ok: true } }),
|
|
294
|
+
});
|
|
295
|
+
runtime.resumeWaitpointByToken.mockResolvedValueOnce({ status: "resumed" });
|
|
296
|
+
expect(await (await respond()).json()).toMatchObject({
|
|
297
|
+
status: "resumed",
|
|
298
|
+
discarded: false,
|
|
299
|
+
});
|
|
300
|
+
runtime.resumeWaitpointByToken.mockResolvedValueOnce({ status: "already" });
|
|
301
|
+
expect(await (await respond()).json()).toMatchObject({
|
|
302
|
+
status: "already",
|
|
303
|
+
discarded: false,
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// The resume routes wired to a real runtime over a real socket: a POST, a
|
|
2
|
+
// /sync POST and the confirm page each resume a waiting run.
|
|
3
|
+
import {
|
|
4
|
+
createHttpAdapter,
|
|
5
|
+
getDbClient,
|
|
6
|
+
HttpRouteService,
|
|
7
|
+
} from "@powerhousedao/reactor-api";
|
|
8
|
+
import {
|
|
9
|
+
CORE_PIECE_NAME,
|
|
10
|
+
CORE_PIECE_VERSION,
|
|
11
|
+
createWorkflowRuntime,
|
|
12
|
+
type WorkflowRuntimeService,
|
|
13
|
+
} from "@powerhousedao/reactor-workflow";
|
|
14
|
+
import {
|
|
15
|
+
createRelationalDb,
|
|
16
|
+
type IRelationalDb,
|
|
17
|
+
} from "@powerhousedao/shared/processors";
|
|
18
|
+
import {
|
|
19
|
+
actions,
|
|
20
|
+
reducer,
|
|
21
|
+
utils,
|
|
22
|
+
type WorkflowDocument,
|
|
23
|
+
} from "@powerhousedao/workflow/document-models/workflow";
|
|
24
|
+
import type { Action } from "document-model";
|
|
25
|
+
import type { Kysely } from "kysely";
|
|
26
|
+
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
27
|
+
import {
|
|
28
|
+
registerWaitpointRoutes,
|
|
29
|
+
waitpointBaseUrlOf,
|
|
30
|
+
} from "../../src/workflow/waitpoint-routes.js";
|
|
31
|
+
|
|
32
|
+
const CTX = { headers: {}, db: {}, user: { address: "0xabc" } } as never;
|
|
33
|
+
const POLL = { timeout: 15_000, interval: 25 };
|
|
34
|
+
|
|
35
|
+
const documents = new Map<string, WorkflowDocument>();
|
|
36
|
+
let service: WorkflowRuntimeService;
|
|
37
|
+
let close: () => Promise<void>;
|
|
38
|
+
|
|
39
|
+
// Manual trigger → Respond and wait for webhook → a Stop run answering `text`.
|
|
40
|
+
function workflow(id: string, text: string) {
|
|
41
|
+
let document = utils.createDocument();
|
|
42
|
+
document.header.id = id;
|
|
43
|
+
const step = (key: string, actionName: string, config: object) =>
|
|
44
|
+
actions.addStep({
|
|
45
|
+
id: key,
|
|
46
|
+
key,
|
|
47
|
+
name: key,
|
|
48
|
+
pieceName: CORE_PIECE_NAME,
|
|
49
|
+
pieceVersion: CORE_PIECE_VERSION,
|
|
50
|
+
actionName,
|
|
51
|
+
config,
|
|
52
|
+
});
|
|
53
|
+
const list: Action[] = [
|
|
54
|
+
actions.setTrigger({
|
|
55
|
+
id: "t1",
|
|
56
|
+
pieceName: CORE_PIECE_NAME,
|
|
57
|
+
pieceVersion: CORE_PIECE_VERSION,
|
|
58
|
+
triggerName: "manual",
|
|
59
|
+
config: {},
|
|
60
|
+
}),
|
|
61
|
+
step("wait", "waitForWebhook", {}),
|
|
62
|
+
step("stop", "stop", {
|
|
63
|
+
responseType: "raw",
|
|
64
|
+
text,
|
|
65
|
+
}),
|
|
66
|
+
actions.addEdge({ id: "e0", from: "t1", to: "wait", port: "next" }),
|
|
67
|
+
actions.addEdge({ id: "e1", from: "wait", to: "stop", port: "next" }),
|
|
68
|
+
actions.publishWorkflow({ publishedAt: "2026-01-01T00:00:00.000Z" }),
|
|
69
|
+
actions.setWorkflowStatus({ status: "ENABLED" }),
|
|
70
|
+
];
|
|
71
|
+
for (const action of list) document = reducer(document, action as never);
|
|
72
|
+
documents.set(id, document);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Fires the workflow to WAITING; returns the run and its resume URL.
|
|
76
|
+
async function waiting(id: string, text = "done") {
|
|
77
|
+
workflow(id, text);
|
|
78
|
+
const fired = await service.fire(id, undefined, "manual", undefined, CTX);
|
|
79
|
+
expect(fired.status).toBe("WAITING");
|
|
80
|
+
const runId = fired.runId!;
|
|
81
|
+
const wait = (await (await service.store())!.getSteps(runId)).find(
|
|
82
|
+
(row) => row.step_key === "wait",
|
|
83
|
+
)!;
|
|
84
|
+
const { resumeUrl } = JSON.parse(wait.output!) as { resumeUrl: string };
|
|
85
|
+
return { runId, resumeUrl };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function settles(runId: string) {
|
|
89
|
+
await expect
|
|
90
|
+
.poll(
|
|
91
|
+
async () => (await (await service.store())!.getRun(runId))?.status,
|
|
92
|
+
POLL,
|
|
93
|
+
)
|
|
94
|
+
.toBe("SUCCEEDED");
|
|
95
|
+
const rows = await (await service.store())!.getSteps(runId);
|
|
96
|
+
return Object.fromEntries(rows.map((row) => [row.step_key, row]));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
beforeAll(async () => {
|
|
100
|
+
const { adapter } = await createHttpAdapter("express");
|
|
101
|
+
adapter.setupMiddleware({});
|
|
102
|
+
const server = await adapter.listen(0, undefined, "127.0.0.1");
|
|
103
|
+
const { port } = server.address() as { port: number };
|
|
104
|
+
const routes = new HttpRouteService({
|
|
105
|
+
httpAdapter: adapter,
|
|
106
|
+
publicUrl: `http://127.0.0.1:${port}`,
|
|
107
|
+
});
|
|
108
|
+
const scope = routes.scopeFor("@powerhousedao/workflow");
|
|
109
|
+
const { db } = getDbClient();
|
|
110
|
+
service = createWorkflowRuntime({
|
|
111
|
+
relationalDb: createRelationalDb(
|
|
112
|
+
db as unknown as Kysely<unknown>,
|
|
113
|
+
) as IRelationalDb,
|
|
114
|
+
reactorClient: {
|
|
115
|
+
find: () => Promise.resolve({ results: [] }),
|
|
116
|
+
get: (id: string) => {
|
|
117
|
+
const document = documents.get(id);
|
|
118
|
+
return document
|
|
119
|
+
? Promise.resolve(structuredClone(document))
|
|
120
|
+
: Promise.reject(new Error(`No document ${id}`));
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
assertCanRead: () => Promise.resolve(undefined),
|
|
124
|
+
assertCanWrite: () => Promise.resolve(undefined),
|
|
125
|
+
waitpointBaseUrl: waitpointBaseUrlOf(scope),
|
|
126
|
+
} as never);
|
|
127
|
+
const handles = registerWaitpointRoutes(scope, service);
|
|
128
|
+
close = async () => {
|
|
129
|
+
for (const handle of handles) handle.dispose();
|
|
130
|
+
service.shutdown();
|
|
131
|
+
await new Promise((done) => server.close(() => done(undefined)));
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
afterAll(() => close());
|
|
136
|
+
|
|
137
|
+
describe("a resume URL served by the switchboard", () => {
|
|
138
|
+
it("resumes the run on a POST, with its body and query", async () => {
|
|
139
|
+
const { runId, resumeUrl } = await waiting("wf-route-post");
|
|
140
|
+
expect(resumeUrl).toMatch(/\/api\/@powerhousedao\/workflow\/waitpoints\//);
|
|
141
|
+
|
|
142
|
+
const response = await fetch(`${resumeUrl}?action=go`, {
|
|
143
|
+
method: "POST",
|
|
144
|
+
headers: { "content-type": "application/json" },
|
|
145
|
+
body: JSON.stringify({ n: 1 }),
|
|
146
|
+
});
|
|
147
|
+
expect(response.status).toBe(200);
|
|
148
|
+
expect(await response.json()).toMatchObject({ status: "resumed" });
|
|
149
|
+
|
|
150
|
+
const steps = await settles(runId);
|
|
151
|
+
expect(JSON.parse(steps.wait!.output!)).toMatchObject({
|
|
152
|
+
body: { n: 1 },
|
|
153
|
+
queryParams: { action: "go" },
|
|
154
|
+
});
|
|
155
|
+
// Used once.
|
|
156
|
+
const again = await fetch(resumeUrl, { method: "POST" });
|
|
157
|
+
expect(await again.json()).toMatchObject({ status: "already" });
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("answers a /sync POST with the resumed run's reply", async () => {
|
|
161
|
+
const { runId, resumeUrl } = await waiting(
|
|
162
|
+
"wf-route-sync",
|
|
163
|
+
"got {{steps.wait.output.body.n}}",
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const response = await fetch(`${resumeUrl}/sync`, {
|
|
167
|
+
method: "POST",
|
|
168
|
+
headers: { "content-type": "application/json" },
|
|
169
|
+
body: JSON.stringify({ n: 7 }),
|
|
170
|
+
});
|
|
171
|
+
expect(response.status).toBe(200);
|
|
172
|
+
expect(await response.text()).toBe("got 7");
|
|
173
|
+
await settles(runId);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("shows the confirm page, and resumes on its form", async () => {
|
|
177
|
+
const { runId, resumeUrl } = await waiting("wf-route-confirm");
|
|
178
|
+
|
|
179
|
+
const page = await fetch(`${resumeUrl}/confirm`);
|
|
180
|
+
expect(page.status).toBe(200);
|
|
181
|
+
expect(await page.text()).toContain("<form");
|
|
182
|
+
expect((await (await service.store())!.getRun(runId))?.status).toBe(
|
|
183
|
+
"WAITING",
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const form = await fetch(`${resumeUrl}/confirm?action=approve`, {
|
|
187
|
+
method: "POST",
|
|
188
|
+
headers: {
|
|
189
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
190
|
+
accept: "text/html",
|
|
191
|
+
},
|
|
192
|
+
body: new URLSearchParams({ reason: "ok" }).toString(),
|
|
193
|
+
});
|
|
194
|
+
expect(form.status).toBe(200);
|
|
195
|
+
expect(await form.text()).toContain("You approved");
|
|
196
|
+
|
|
197
|
+
const steps = await settles(runId);
|
|
198
|
+
expect(JSON.parse(steps.wait!.output!)).toMatchObject({
|
|
199
|
+
body: { reason: "ok" },
|
|
200
|
+
queryParams: { action: "approve" },
|
|
201
|
+
});
|
|
202
|
+
expect((await fetch(`${resumeUrl}/confirm`)).status).toBe(200);
|
|
203
|
+
});
|
|
204
|
+
});
|