rivetkit 2.0.37 → 2.0.39
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/dist/tsup/{chunk-G4N7FZMM.cjs → chunk-7E3RWMR6.cjs} +195 -93
- package/dist/tsup/chunk-7E3RWMR6.cjs.map +1 -0
- package/dist/tsup/{chunk-J6TX5EFW.js → chunk-BQ36VTSB.js} +108 -6
- package/dist/tsup/chunk-BQ36VTSB.js.map +1 -0
- package/dist/tsup/{chunk-4V7MS7SO.cjs → chunk-C64FV764.cjs} +3 -3
- package/dist/tsup/{chunk-4V7MS7SO.cjs.map → chunk-C64FV764.cjs.map} +1 -1
- package/dist/tsup/{chunk-XI335ZED.js → chunk-CDK6DRO2.js} +6 -4
- package/dist/tsup/chunk-CDK6DRO2.js.map +1 -0
- package/dist/tsup/{chunk-LYYTV7DN.cjs → chunk-DY4H3ASE.cjs} +50 -46
- package/dist/tsup/chunk-DY4H3ASE.cjs.map +1 -0
- package/dist/tsup/{chunk-B6BP74X3.cjs → chunk-KMYFL3OL.cjs} +318 -92
- package/dist/tsup/chunk-KMYFL3OL.cjs.map +1 -0
- package/dist/tsup/{chunk-22NKW7F5.cjs → chunk-MZPYVTVG.cjs} +9 -9
- package/dist/tsup/{chunk-22NKW7F5.cjs.map → chunk-MZPYVTVG.cjs.map} +1 -1
- package/dist/tsup/{chunk-RBA5AQTB.js → chunk-OJZRCEIA.js} +5 -5
- package/dist/tsup/{chunk-RXA3ZMCL.js → chunk-PHCD25XO.js} +2 -2
- package/dist/tsup/{chunk-5XGZXH74.js → chunk-PVKUXMOA.js} +264 -38
- package/dist/tsup/chunk-PVKUXMOA.js.map +1 -0
- package/dist/tsup/{chunk-FIUSIG6J.js → chunk-T7IPDBWH.js} +8 -4
- package/dist/tsup/{chunk-FIUSIG6J.js.map → chunk-T7IPDBWH.js.map} +1 -1
- package/dist/tsup/{chunk-5VVIFC6M.cjs → chunk-UAX5E3EU.cjs} +443 -369
- package/dist/tsup/chunk-UAX5E3EU.cjs.map +1 -0
- package/dist/tsup/{chunk-X5IX3YPO.cjs → chunk-X72X7I7T.cjs} +6 -4
- package/dist/tsup/chunk-X72X7I7T.cjs.map +1 -0
- package/dist/tsup/{chunk-ZQBSQ6H3.js → chunk-XU74APB4.js} +208 -134
- package/dist/tsup/chunk-XU74APB4.js.map +1 -0
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.d.cts +3 -3
- package/dist/tsup/client/mod.d.ts +3 -3
- package/dist/tsup/client/mod.js +4 -4
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config--NjwiYlS.d.cts → config-BuBlMs6C.d.cts} +238 -60
- package/dist/tsup/{config-CRuzI6n4.d.ts → config-CBwo4ooA.d.ts} +238 -60
- package/dist/tsup/{driver-yKjYx9Yy.d.cts → driver-CPXmh8f8.d.cts} +1 -1
- package/dist/tsup/{driver-BcmckRaF.d.ts → driver-DxWa6HUO.d.ts} +1 -1
- package/dist/tsup/driver-helpers/mod.cjs +3 -3
- package/dist/tsup/driver-helpers/mod.d.cts +2 -2
- package/dist/tsup/driver-helpers/mod.d.ts +2 -2
- package/dist/tsup/driver-helpers/mod.js +2 -2
- package/dist/tsup/driver-test-suite/mod.cjs +81 -35
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +2 -2
- package/dist/tsup/driver-test-suite/mod.d.ts +2 -2
- package/dist/tsup/driver-test-suite/mod.js +407 -361
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/{kv-CTM8sCvx.d.cts → keys-Chhy4ylv.d.cts} +1 -0
- package/dist/tsup/{kv-CTM8sCvx.d.ts → keys-Chhy4ylv.d.ts} +1 -0
- package/dist/tsup/mod.cjs +19 -7
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +18 -6
- package/dist/tsup/test/mod.cjs +7 -7
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/package.json +6 -4
- package/src/actor/config.ts +198 -2
- package/src/actor/contexts/base/actor.ts +12 -0
- package/src/actor/instance/connection-manager.ts +1 -1
- package/src/actor/instance/keys.ts +29 -0
- package/src/actor/instance/kv.ts +240 -14
- package/src/actor/instance/mod.ts +5 -4
- package/src/actor/instance/state-manager.ts +1 -1
- package/src/actor/mod.ts +2 -1
- package/src/actor/router-websocket-endpoints.ts +2 -1
- package/src/client/actor-conn.ts +70 -81
- package/src/client/actor-handle.ts +35 -15
- package/src/client/actor-query.ts +47 -0
- package/src/client/errors.ts +22 -58
- package/src/client/mod.ts +1 -1
- package/src/client/utils.ts +33 -0
- package/src/driver-helpers/utils.ts +1 -1
- package/src/driver-test-suite/mod.ts +3 -0
- package/src/driver-test-suite/test-inline-client-driver.ts +3 -0
- package/src/driver-test-suite/tests/actor-kv.ts +44 -0
- package/src/driver-test-suite/utils.ts +4 -0
- package/src/drivers/engine/actor-driver.ts +3 -3
- package/src/drivers/file-system/manager.ts +5 -0
- package/src/manager/driver.ts +8 -3
- package/src/manager-api/actors.ts +1 -20
- package/src/registry/config/index.ts +68 -0
- package/src/remote-manager-driver/actor-http-client.ts +5 -3
- package/src/remote-manager-driver/actor-websocket-client.ts +18 -7
- package/src/remote-manager-driver/mod.ts +21 -1
- package/src/serverless/router.test.ts +166 -0
- package/src/serverless/router.ts +58 -5
- package/src/utils/env-vars.ts +4 -1
- package/dist/tsup/chunk-5VVIFC6M.cjs.map +0 -1
- package/dist/tsup/chunk-5XGZXH74.js.map +0 -1
- package/dist/tsup/chunk-B6BP74X3.cjs.map +0 -1
- package/dist/tsup/chunk-G4N7FZMM.cjs.map +0 -1
- package/dist/tsup/chunk-J6TX5EFW.js.map +0 -1
- package/dist/tsup/chunk-LYYTV7DN.cjs.map +0 -1
- package/dist/tsup/chunk-X5IX3YPO.cjs.map +0 -1
- package/dist/tsup/chunk-XI335ZED.js.map +0 -1
- package/dist/tsup/chunk-ZQBSQ6H3.js.map +0 -1
- /package/dist/tsup/{chunk-RBA5AQTB.js.map → chunk-OJZRCEIA.js.map} +0 -0
- /package/dist/tsup/{chunk-RXA3ZMCL.js.map → chunk-PHCD25XO.js.map} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPort
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-OJZRCEIA.js";
|
|
4
4
|
import {
|
|
5
5
|
actor
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-BQ36VTSB.js";
|
|
7
|
+
import "../chunk-T7IPDBWH.js";
|
|
8
8
|
import {
|
|
9
9
|
ActorError,
|
|
10
10
|
ClientConfigSchema,
|
|
11
11
|
createClient,
|
|
12
12
|
createClientWithDriver
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-XU74APB4.js";
|
|
14
14
|
import {
|
|
15
15
|
importWebSocket
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-PHCD25XO.js";
|
|
17
17
|
import {
|
|
18
18
|
HEADER_ACTOR_ID,
|
|
19
19
|
WS_PROTOCOL_ACTOR,
|
|
@@ -24,13 +24,13 @@ import {
|
|
|
24
24
|
WS_TEST_PROTOCOL_PATH,
|
|
25
25
|
assertUnreachable,
|
|
26
26
|
buildManagerRouter
|
|
27
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-PVKUXMOA.js";
|
|
28
28
|
import "../chunk-E6ZE2YEA.js";
|
|
29
29
|
import {
|
|
30
30
|
getLogger,
|
|
31
31
|
noopNext,
|
|
32
32
|
promiseWithResolvers
|
|
33
|
-
} from "../chunk-
|
|
33
|
+
} from "../chunk-CDK6DRO2.js";
|
|
34
34
|
import {
|
|
35
35
|
INTERNAL_ERROR_CODE,
|
|
36
36
|
INTERNAL_ERROR_DESCRIPTION
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
import { serve as honoServe } from "@hono/node-server";
|
|
41
41
|
import { createNodeWebSocket } from "@hono/node-ws";
|
|
42
42
|
import invariant2 from "invariant";
|
|
43
|
-
import { describe as
|
|
43
|
+
import { describe as describe23 } from "vitest";
|
|
44
44
|
|
|
45
45
|
// src/driver-test-suite/log.ts
|
|
46
46
|
function logger() {
|
|
@@ -177,6 +177,9 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
177
177
|
);
|
|
178
178
|
return upgradeWebSocket(() => wsHandler)(c, noopNext());
|
|
179
179
|
},
|
|
180
|
+
async buildGatewayUrl(actorId) {
|
|
181
|
+
return `${endpoint}/gateway/${actorId}`;
|
|
182
|
+
},
|
|
180
183
|
displayInformation() {
|
|
181
184
|
return { properties: {} };
|
|
182
185
|
},
|
|
@@ -248,7 +251,11 @@ async function setupDriverTest(c, driverTestConfig) {
|
|
|
248
251
|
endpoint,
|
|
249
252
|
namespace,
|
|
250
253
|
runnerName,
|
|
251
|
-
encoding: driverTestConfig.encoding
|
|
254
|
+
encoding: driverTestConfig.encoding,
|
|
255
|
+
// Disable metadata lookup to prevent redirect to the wrong port.
|
|
256
|
+
// Each test starts a new server on a dynamic port, but the
|
|
257
|
+
// registry's publicEndpoint defaults to port 6420.
|
|
258
|
+
disableMetadataLookup: true
|
|
252
259
|
});
|
|
253
260
|
} else if (driverTestConfig.clientType === "inline") {
|
|
254
261
|
const encoding = driverTestConfig.encoding ?? "bare";
|
|
@@ -2257,26 +2264,64 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2257
2264
|
});
|
|
2258
2265
|
}
|
|
2259
2266
|
|
|
2260
|
-
// src/driver-test-suite/tests/actor-
|
|
2267
|
+
// src/driver-test-suite/tests/actor-kv.ts
|
|
2261
2268
|
import { describe as describe14, expect as expect12, test as test12 } from "vitest";
|
|
2269
|
+
function runActorKvTests(driverTestConfig) {
|
|
2270
|
+
describe14("Actor KV Tests", () => {
|
|
2271
|
+
test12("supports text encoding and decoding", async (c) => {
|
|
2272
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2273
|
+
const kvHandle = client.kvActor.getOrCreate(["kv-text"]);
|
|
2274
|
+
await kvHandle.putText("greeting", "hello");
|
|
2275
|
+
const value = await kvHandle.getText("greeting");
|
|
2276
|
+
expect12(value).toBe("hello");
|
|
2277
|
+
await kvHandle.putText("prefix-a", "alpha");
|
|
2278
|
+
await kvHandle.putText("prefix-b", "beta");
|
|
2279
|
+
const results = await kvHandle.listText("prefix-");
|
|
2280
|
+
const sorted = results.sort((a, b) => a.key.localeCompare(b.key));
|
|
2281
|
+
expect12(sorted).toEqual([
|
|
2282
|
+
{ key: "prefix-a", value: "alpha" },
|
|
2283
|
+
{ key: "prefix-b", value: "beta" }
|
|
2284
|
+
]);
|
|
2285
|
+
});
|
|
2286
|
+
test12(
|
|
2287
|
+
"supports arrayBuffer encoding and decoding",
|
|
2288
|
+
async (c) => {
|
|
2289
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2290
|
+
const kvHandle = client.kvActor.getOrCreate(["kv-array-buffer"]);
|
|
2291
|
+
const values = await kvHandle.roundtripArrayBuffer("bytes", [
|
|
2292
|
+
4,
|
|
2293
|
+
8,
|
|
2294
|
+
15,
|
|
2295
|
+
16,
|
|
2296
|
+
23,
|
|
2297
|
+
42
|
|
2298
|
+
]);
|
|
2299
|
+
expect12(values).toEqual([4, 8, 15, 16, 23, 42]);
|
|
2300
|
+
}
|
|
2301
|
+
);
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
// src/driver-test-suite/tests/actor-metadata.ts
|
|
2306
|
+
import { describe as describe15, expect as expect13, test as test13 } from "vitest";
|
|
2262
2307
|
function runActorMetadataTests(driverTestConfig) {
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2308
|
+
describe15("Actor Metadata Tests", () => {
|
|
2309
|
+
describe15("Actor Name", () => {
|
|
2310
|
+
test13("should provide access to actor name", async (c) => {
|
|
2266
2311
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2267
2312
|
const handle = client.metadataActor.getOrCreate();
|
|
2268
2313
|
const actorName = await handle.getActorName();
|
|
2269
|
-
|
|
2314
|
+
expect13(actorName).toBe("metadataActor");
|
|
2270
2315
|
});
|
|
2271
|
-
|
|
2316
|
+
test13("should preserve actor name in state during onWake", async (c) => {
|
|
2272
2317
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2273
2318
|
const handle = client.metadataActor.getOrCreate();
|
|
2274
2319
|
const storedName = await handle.getStoredActorName();
|
|
2275
|
-
|
|
2320
|
+
expect13(storedName).toBe("metadataActor");
|
|
2276
2321
|
});
|
|
2277
2322
|
});
|
|
2278
|
-
|
|
2279
|
-
|
|
2323
|
+
describe15("Actor Tags", () => {
|
|
2324
|
+
test13("should provide access to tags", async (c) => {
|
|
2280
2325
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2281
2326
|
const handle = client.metadataActor.getOrCreate();
|
|
2282
2327
|
await handle.setupTestTags({
|
|
@@ -2284,12 +2329,12 @@ function runActorMetadataTests(driverTestConfig) {
|
|
|
2284
2329
|
purpose: "metadata-test"
|
|
2285
2330
|
});
|
|
2286
2331
|
const tags = await handle.getTags();
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2332
|
+
expect13(tags).toHaveProperty("env");
|
|
2333
|
+
expect13(tags.env).toBe("test");
|
|
2334
|
+
expect13(tags).toHaveProperty("purpose");
|
|
2335
|
+
expect13(tags.purpose).toBe("metadata-test");
|
|
2291
2336
|
});
|
|
2292
|
-
|
|
2337
|
+
test13("should allow accessing individual tags", async (c) => {
|
|
2293
2338
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2294
2339
|
const handle = client.metadataActor.getOrCreate();
|
|
2295
2340
|
await handle.setupTestTags({
|
|
@@ -2299,110 +2344,110 @@ function runActorMetadataTests(driverTestConfig) {
|
|
|
2299
2344
|
const category = await handle.getTag("category");
|
|
2300
2345
|
const version = await handle.getTag("version");
|
|
2301
2346
|
const nonexistent = await handle.getTag("nonexistent");
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2347
|
+
expect13(category).toBe("test-actor");
|
|
2348
|
+
expect13(version).toBe("1.0");
|
|
2349
|
+
expect13(nonexistent).toBeNull();
|
|
2305
2350
|
});
|
|
2306
2351
|
});
|
|
2307
|
-
|
|
2308
|
-
|
|
2352
|
+
describe15("Metadata Structure", () => {
|
|
2353
|
+
test13("should provide complete metadata object", async (c) => {
|
|
2309
2354
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2310
2355
|
const handle = client.metadataActor.getOrCreate();
|
|
2311
2356
|
await handle.setupTestTags({ type: "metadata-test" });
|
|
2312
2357
|
await handle.setupTestRegion("us-west-1");
|
|
2313
2358
|
const metadata = await handle.getMetadata();
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2359
|
+
expect13(metadata).toHaveProperty("name");
|
|
2360
|
+
expect13(metadata.name).toBe("metadataActor");
|
|
2361
|
+
expect13(metadata).toHaveProperty("tags");
|
|
2362
|
+
expect13(metadata.tags).toHaveProperty("type");
|
|
2363
|
+
expect13(metadata.tags.type).toBe("metadata-test");
|
|
2364
|
+
expect13(metadata).toHaveProperty("region");
|
|
2365
|
+
expect13(metadata.region).toBe("us-west-1");
|
|
2321
2366
|
});
|
|
2322
2367
|
});
|
|
2323
|
-
|
|
2324
|
-
|
|
2368
|
+
describe15("Region Information", () => {
|
|
2369
|
+
test13("should retrieve region information", async (c) => {
|
|
2325
2370
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2326
2371
|
const handle = client.metadataActor.getOrCreate();
|
|
2327
2372
|
await handle.setupTestRegion("eu-central-1");
|
|
2328
2373
|
const region = await handle.getRegion();
|
|
2329
|
-
|
|
2374
|
+
expect13(region).toBe("eu-central-1");
|
|
2330
2375
|
});
|
|
2331
2376
|
});
|
|
2332
2377
|
});
|
|
2333
2378
|
}
|
|
2334
2379
|
|
|
2335
2380
|
// src/driver-test-suite/tests/actor-onstatechange.ts
|
|
2336
|
-
import { describe as
|
|
2381
|
+
import { describe as describe16, expect as expect14, test as test14 } from "vitest";
|
|
2337
2382
|
function runActorOnStateChangeTests(driverTestConfig) {
|
|
2338
|
-
|
|
2339
|
-
|
|
2383
|
+
describe16("Actor onStateChange Tests", () => {
|
|
2384
|
+
test14("triggers onStateChange when state is modified", async (c) => {
|
|
2340
2385
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2341
2386
|
const actor2 = client.onStateChangeActor.getOrCreate();
|
|
2342
2387
|
await actor2.setValue(10);
|
|
2343
2388
|
const changeCount = await actor2.getChangeCount();
|
|
2344
|
-
|
|
2389
|
+
expect14(changeCount).toBe(1);
|
|
2345
2390
|
});
|
|
2346
|
-
|
|
2391
|
+
test14("triggers onChange multiple times for multiple state changes", async (c) => {
|
|
2347
2392
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2348
2393
|
const actor2 = client.onStateChangeActor.getOrCreate();
|
|
2349
2394
|
await actor2.incrementMultiple(3);
|
|
2350
2395
|
const changeCount = await actor2.getChangeCount();
|
|
2351
|
-
|
|
2396
|
+
expect14(changeCount).toBe(3);
|
|
2352
2397
|
});
|
|
2353
|
-
|
|
2398
|
+
test14("does NOT trigger onChange for read-only actions", async (c) => {
|
|
2354
2399
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2355
2400
|
const actor2 = client.onStateChangeActor.getOrCreate();
|
|
2356
2401
|
await actor2.setValue(5);
|
|
2357
2402
|
const value = await actor2.getValue();
|
|
2358
|
-
|
|
2403
|
+
expect14(value).toBe(5);
|
|
2359
2404
|
const changeCount = await actor2.getChangeCount();
|
|
2360
|
-
|
|
2405
|
+
expect14(changeCount).toBe(1);
|
|
2361
2406
|
});
|
|
2362
|
-
|
|
2407
|
+
test14("does NOT trigger onChange for computed values", async (c) => {
|
|
2363
2408
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2364
2409
|
const actor2 = client.onStateChangeActor.getOrCreate();
|
|
2365
2410
|
await actor2.setValue(3);
|
|
2366
2411
|
{
|
|
2367
2412
|
const changeCount = await actor2.getChangeCount();
|
|
2368
|
-
|
|
2413
|
+
expect14(changeCount).toBe(1);
|
|
2369
2414
|
}
|
|
2370
2415
|
const doubled = await actor2.getDoubled();
|
|
2371
|
-
|
|
2416
|
+
expect14(doubled).toBe(6);
|
|
2372
2417
|
{
|
|
2373
2418
|
const changeCount = await actor2.getChangeCount();
|
|
2374
|
-
|
|
2419
|
+
expect14(changeCount).toBe(1);
|
|
2375
2420
|
}
|
|
2376
2421
|
});
|
|
2377
|
-
|
|
2422
|
+
test14("simple: connect, call action, dispose does NOT trigger onChange", async (c) => {
|
|
2378
2423
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2379
2424
|
const actor2 = client.onStateChangeActor.getOrCreate();
|
|
2380
2425
|
const connection = await actor2.connect();
|
|
2381
2426
|
const value = await connection.getValue();
|
|
2382
|
-
|
|
2427
|
+
expect14(value).toBe(0);
|
|
2383
2428
|
await connection.dispose();
|
|
2384
2429
|
const changeCount = await actor2.getChangeCount();
|
|
2385
|
-
|
|
2430
|
+
expect14(changeCount).toBe(0);
|
|
2386
2431
|
});
|
|
2387
2432
|
});
|
|
2388
2433
|
}
|
|
2389
2434
|
|
|
2390
2435
|
// src/driver-test-suite/tests/actor-vars.ts
|
|
2391
|
-
import { describe as
|
|
2436
|
+
import { describe as describe17, expect as expect15, test as test15 } from "vitest";
|
|
2392
2437
|
function runActorVarsTests(driverTestConfig) {
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2438
|
+
describe17("Actor Variables", () => {
|
|
2439
|
+
describe17("Static vars", () => {
|
|
2440
|
+
test15("should provide access to static vars", async (c) => {
|
|
2396
2441
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2397
2442
|
const instance = client.staticVarActor.getOrCreate();
|
|
2398
2443
|
const result = await instance.getVars();
|
|
2399
|
-
|
|
2444
|
+
expect15(result).toEqual({ counter: 42, name: "test-actor" });
|
|
2400
2445
|
const name = await instance.getName();
|
|
2401
|
-
|
|
2446
|
+
expect15(name).toBe("test-actor");
|
|
2402
2447
|
});
|
|
2403
2448
|
});
|
|
2404
|
-
|
|
2405
|
-
|
|
2449
|
+
describe17("Deep cloning of static vars", () => {
|
|
2450
|
+
test15("should deep clone static vars between actor instances", async (c) => {
|
|
2406
2451
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2407
2452
|
const instance1 = client.nestedVarActor.getOrCreate([
|
|
2408
2453
|
"instance1"
|
|
@@ -2411,100 +2456,100 @@ function runActorVarsTests(driverTestConfig) {
|
|
|
2411
2456
|
"instance2"
|
|
2412
2457
|
]);
|
|
2413
2458
|
const modifiedVars = await instance1.modifyNested();
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2459
|
+
expect15(modifiedVars.nested.value).toBe("modified");
|
|
2460
|
+
expect15(modifiedVars.nested.array).toContain(4);
|
|
2461
|
+
expect15(modifiedVars.nested.obj.key).toBe("new-value");
|
|
2417
2462
|
const instance2Vars = await instance2.getVars();
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2463
|
+
expect15(instance2Vars.nested.value).toBe("original");
|
|
2464
|
+
expect15(instance2Vars.nested.array).toEqual([1, 2, 3]);
|
|
2465
|
+
expect15(instance2Vars.nested.obj.key).toBe("value");
|
|
2421
2466
|
});
|
|
2422
2467
|
});
|
|
2423
|
-
|
|
2424
|
-
|
|
2468
|
+
describe17("createVars", () => {
|
|
2469
|
+
test15("should support dynamic vars creation", async (c) => {
|
|
2425
2470
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2426
2471
|
const instance = client.dynamicVarActor.getOrCreate();
|
|
2427
2472
|
const vars = await instance.getVars();
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2473
|
+
expect15(vars).toHaveProperty("random");
|
|
2474
|
+
expect15(vars).toHaveProperty("computed");
|
|
2475
|
+
expect15(typeof vars.random).toBe("number");
|
|
2476
|
+
expect15(typeof vars.computed).toBe("string");
|
|
2477
|
+
expect15(vars.computed).toMatch(/^Actor-\d+$/);
|
|
2433
2478
|
});
|
|
2434
|
-
|
|
2479
|
+
test15("should create different vars for different instances", async (c) => {
|
|
2435
2480
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2436
2481
|
const instance1 = client.uniqueVarActor.getOrCreate(["test1"]);
|
|
2437
2482
|
const instance2 = client.uniqueVarActor.getOrCreate(["test2"]);
|
|
2438
2483
|
const vars1 = await instance1.getVars();
|
|
2439
2484
|
const vars2 = await instance2.getVars();
|
|
2440
|
-
|
|
2485
|
+
expect15(vars1.id).not.toBe(vars2.id);
|
|
2441
2486
|
});
|
|
2442
2487
|
});
|
|
2443
|
-
|
|
2444
|
-
|
|
2488
|
+
describe17("Driver Context", () => {
|
|
2489
|
+
test15("should provide access to driver context", async (c) => {
|
|
2445
2490
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2446
2491
|
const instance = client.driverCtxActor.getOrCreate();
|
|
2447
2492
|
const vars = await instance.getVars();
|
|
2448
|
-
|
|
2493
|
+
expect15(vars).toHaveProperty("hasDriverCtx");
|
|
2449
2494
|
});
|
|
2450
2495
|
});
|
|
2451
2496
|
});
|
|
2452
2497
|
}
|
|
2453
2498
|
|
|
2454
2499
|
// src/driver-test-suite/tests/manager-driver.ts
|
|
2455
|
-
import { describe as
|
|
2500
|
+
import { describe as describe18, expect as expect16, test as test16 } from "vitest";
|
|
2456
2501
|
function runManagerDriverTests(driverTestConfig) {
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2502
|
+
describe18("Manager Driver Tests", () => {
|
|
2503
|
+
describe18("Client Connection Methods", () => {
|
|
2504
|
+
test16("connect() - finds or creates a actor", async (c) => {
|
|
2460
2505
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2461
2506
|
const counterA = client.counter.getOrCreate();
|
|
2462
2507
|
await counterA.increment(5);
|
|
2463
2508
|
const counterAAgain = client.counter.getOrCreate();
|
|
2464
2509
|
const count = await counterAAgain.increment(0);
|
|
2465
|
-
|
|
2510
|
+
expect16(count).toBe(5);
|
|
2466
2511
|
const counterB = client.counter.getOrCreate([
|
|
2467
2512
|
"counter-b",
|
|
2468
2513
|
"testing"
|
|
2469
2514
|
]);
|
|
2470
2515
|
await counterB.increment(10);
|
|
2471
2516
|
const countB = await counterB.increment(0);
|
|
2472
|
-
|
|
2517
|
+
expect16(countB).toBe(10);
|
|
2473
2518
|
});
|
|
2474
|
-
|
|
2519
|
+
test16("throws ActorAlreadyExists when creating duplicate actors", async (c) => {
|
|
2475
2520
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2476
2521
|
const uniqueKey = ["duplicate-actor-test", crypto.randomUUID()];
|
|
2477
2522
|
const counter = client.counter.getOrCreate(uniqueKey);
|
|
2478
2523
|
await counter.increment(5);
|
|
2479
2524
|
try {
|
|
2480
2525
|
await client.counter.create(uniqueKey);
|
|
2481
|
-
|
|
2526
|
+
expect16.fail("did not error on duplicate create");
|
|
2482
2527
|
} catch (err) {
|
|
2483
|
-
|
|
2484
|
-
|
|
2528
|
+
expect16(err.group).toBe("actor");
|
|
2529
|
+
expect16(err.code).toBe("duplicate_key");
|
|
2485
2530
|
}
|
|
2486
2531
|
const count = await counter.increment(0);
|
|
2487
|
-
|
|
2532
|
+
expect16(count).toBe(5);
|
|
2488
2533
|
});
|
|
2489
2534
|
});
|
|
2490
|
-
|
|
2491
|
-
|
|
2535
|
+
describe18("Connection Options", () => {
|
|
2536
|
+
test16("get without create prevents actor creation", async (c) => {
|
|
2492
2537
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2493
2538
|
const nonexistentId = `nonexistent-${crypto.randomUUID()}`;
|
|
2494
2539
|
try {
|
|
2495
2540
|
await client.counter.get([nonexistentId]).resolve();
|
|
2496
|
-
|
|
2541
|
+
expect16.fail("did not error for get");
|
|
2497
2542
|
} catch (err) {
|
|
2498
|
-
|
|
2499
|
-
|
|
2543
|
+
expect16(err.group).toBe("actor");
|
|
2544
|
+
expect16(err.code).toBe("not_found");
|
|
2500
2545
|
}
|
|
2501
2546
|
const createdCounter = client.counter.getOrCreate(nonexistentId);
|
|
2502
2547
|
await createdCounter.increment(3);
|
|
2503
2548
|
const retrievedCounter = client.counter.get(nonexistentId);
|
|
2504
2549
|
const count = await retrievedCounter.increment(0);
|
|
2505
|
-
|
|
2550
|
+
expect16(count).toBe(3);
|
|
2506
2551
|
});
|
|
2507
|
-
|
|
2552
|
+
test16("connection params are passed to actors", async (c) => {
|
|
2508
2553
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2509
2554
|
const counter = client.counter.getOrCreate(void 0, {
|
|
2510
2555
|
params: {
|
|
@@ -2515,20 +2560,20 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
2515
2560
|
});
|
|
2516
2561
|
await counter.increment(1);
|
|
2517
2562
|
const count = await counter.increment(0);
|
|
2518
|
-
|
|
2563
|
+
expect16(count).toBe(1);
|
|
2519
2564
|
});
|
|
2520
2565
|
});
|
|
2521
|
-
|
|
2522
|
-
|
|
2566
|
+
describe18("Actor Creation & Retrieval", () => {
|
|
2567
|
+
test16("creates and retrieves actors by ID", async (c) => {
|
|
2523
2568
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2524
2569
|
const uniqueId = `test-counter-${crypto.randomUUID()}`;
|
|
2525
2570
|
const counter = client.counter.getOrCreate([uniqueId]);
|
|
2526
2571
|
await counter.increment(10);
|
|
2527
2572
|
const retrievedCounter = client.counter.getOrCreate([uniqueId]);
|
|
2528
2573
|
const count = await retrievedCounter.increment(0);
|
|
2529
|
-
|
|
2574
|
+
expect16(count).toBe(10);
|
|
2530
2575
|
});
|
|
2531
|
-
|
|
2576
|
+
test16("passes input to actor during creation", async (c) => {
|
|
2532
2577
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2533
2578
|
const testInput = {
|
|
2534
2579
|
name: "test-actor",
|
|
@@ -2539,17 +2584,17 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
2539
2584
|
input: testInput
|
|
2540
2585
|
});
|
|
2541
2586
|
const inputs = await actor2.getInputs();
|
|
2542
|
-
|
|
2543
|
-
|
|
2587
|
+
expect16(inputs.initialInput).toEqual(testInput);
|
|
2588
|
+
expect16(inputs.onCreateInput).toEqual(testInput);
|
|
2544
2589
|
});
|
|
2545
|
-
|
|
2590
|
+
test16("input is undefined when not provided", async (c) => {
|
|
2546
2591
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2547
2592
|
const actor2 = await client.inputActor.create();
|
|
2548
2593
|
const inputs = await actor2.getInputs();
|
|
2549
|
-
|
|
2550
|
-
|
|
2594
|
+
expect16(inputs.initialInput).toBeUndefined();
|
|
2595
|
+
expect16(inputs.onCreateInput).toBeUndefined();
|
|
2551
2596
|
});
|
|
2552
|
-
|
|
2597
|
+
test16("getOrCreate passes input to actor during creation", async (c) => {
|
|
2553
2598
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2554
2599
|
const uniqueKey = [`input-test-${crypto.randomUUID()}`];
|
|
2555
2600
|
const testInput = {
|
|
@@ -2561,16 +2606,16 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
2561
2606
|
createWithInput: testInput
|
|
2562
2607
|
});
|
|
2563
2608
|
const inputs = await actor2.getInputs();
|
|
2564
|
-
|
|
2565
|
-
|
|
2609
|
+
expect16(inputs.initialInput).toEqual(testInput);
|
|
2610
|
+
expect16(inputs.onCreateInput).toEqual(testInput);
|
|
2566
2611
|
const existingActor = client.inputActor.getOrCreate(uniqueKey);
|
|
2567
2612
|
const existingInputs = await existingActor.getInputs();
|
|
2568
|
-
|
|
2569
|
-
|
|
2613
|
+
expect16(existingInputs.initialInput).toEqual(testInput);
|
|
2614
|
+
expect16(existingInputs.onCreateInput).toEqual(testInput);
|
|
2570
2615
|
});
|
|
2571
2616
|
});
|
|
2572
|
-
|
|
2573
|
-
|
|
2617
|
+
describe18("Key Matching", () => {
|
|
2618
|
+
test16("matches actors only with exactly the same keys", async (c) => {
|
|
2574
2619
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2575
2620
|
const originalCounter = client.counter.getOrCreate([
|
|
2576
2621
|
"counter-match",
|
|
@@ -2584,20 +2629,20 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
2584
2629
|
"us-east"
|
|
2585
2630
|
]);
|
|
2586
2631
|
const exactMatchCount = await exactMatchCounter.increment(0);
|
|
2587
|
-
|
|
2632
|
+
expect16(exactMatchCount).toBe(10);
|
|
2588
2633
|
const subsetMatchCounter = client.counter.getOrCreate([
|
|
2589
2634
|
"counter-match",
|
|
2590
2635
|
"test"
|
|
2591
2636
|
]);
|
|
2592
2637
|
const subsetMatchCount = await subsetMatchCounter.increment(0);
|
|
2593
|
-
|
|
2638
|
+
expect16(subsetMatchCount).toBe(0);
|
|
2594
2639
|
const singleKeyCounter = client.counter.getOrCreate([
|
|
2595
2640
|
"counter-match"
|
|
2596
2641
|
]);
|
|
2597
2642
|
const singleKeyCount = await singleKeyCounter.increment(0);
|
|
2598
|
-
|
|
2643
|
+
expect16(singleKeyCount).toBe(0);
|
|
2599
2644
|
});
|
|
2600
|
-
|
|
2645
|
+
test16("string key matches array with single string key", async (c) => {
|
|
2601
2646
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2602
2647
|
const stringKeyCounter = client.counter.getOrCreate("string-key-test");
|
|
2603
2648
|
await stringKeyCounter.increment(7);
|
|
@@ -2605,20 +2650,20 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
2605
2650
|
"string-key-test"
|
|
2606
2651
|
]);
|
|
2607
2652
|
const count = await arrayKeyCounter.increment(0);
|
|
2608
|
-
|
|
2653
|
+
expect16(count).toBe(7);
|
|
2609
2654
|
});
|
|
2610
|
-
|
|
2655
|
+
test16("undefined key matches empty array key and no key", async (c) => {
|
|
2611
2656
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2612
2657
|
const undefinedKeyCounter = client.counter.getOrCreate(void 0);
|
|
2613
2658
|
await undefinedKeyCounter.increment(12);
|
|
2614
2659
|
const emptyArrayKeyCounter = client.counter.getOrCreate([]);
|
|
2615
2660
|
const emptyArrayCount = await emptyArrayKeyCounter.increment(0);
|
|
2616
|
-
|
|
2661
|
+
expect16(emptyArrayCount).toBe(12);
|
|
2617
2662
|
const noKeyCounter = client.counter.getOrCreate();
|
|
2618
2663
|
const noKeyCount = await noKeyCounter.increment(0);
|
|
2619
|
-
|
|
2664
|
+
expect16(noKeyCount).toBe(12);
|
|
2620
2665
|
});
|
|
2621
|
-
|
|
2666
|
+
test16("no keys does not match actors with keys", async (c) => {
|
|
2622
2667
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2623
2668
|
const keyedCounter = client.counter.getOrCreate([
|
|
2624
2669
|
"counter-with-keys",
|
|
@@ -2627,9 +2672,9 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
2627
2672
|
await keyedCounter.increment(15);
|
|
2628
2673
|
const noKeysCounter = client.counter.getOrCreate();
|
|
2629
2674
|
const count = await noKeysCounter.increment(10);
|
|
2630
|
-
|
|
2675
|
+
expect16(count).toBe(10);
|
|
2631
2676
|
});
|
|
2632
|
-
|
|
2677
|
+
test16("actors with keys match actors with no keys", async (c) => {
|
|
2633
2678
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2634
2679
|
const noKeysCounter = client.counter.getOrCreate();
|
|
2635
2680
|
await noKeysCounter.increment(25);
|
|
@@ -2638,11 +2683,11 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
2638
2683
|
"prod"
|
|
2639
2684
|
]);
|
|
2640
2685
|
const keyedCount = await keyedCounter.increment(0);
|
|
2641
|
-
|
|
2686
|
+
expect16(keyedCount).toBe(0);
|
|
2642
2687
|
});
|
|
2643
2688
|
});
|
|
2644
|
-
|
|
2645
|
-
|
|
2689
|
+
describe18("Multiple Actor Instances", () => {
|
|
2690
|
+
test16("creates multiple actor instances of the same type", async (c) => {
|
|
2646
2691
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2647
2692
|
const instance1 = client.counter.getOrCreate(["multi-1"]);
|
|
2648
2693
|
const instance2 = client.counter.getOrCreate(["multi-2"]);
|
|
@@ -2653,35 +2698,35 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
2653
2698
|
const retrieved1 = client.counter.getOrCreate(["multi-1"]);
|
|
2654
2699
|
const retrieved2 = client.counter.getOrCreate(["multi-2"]);
|
|
2655
2700
|
const retrieved3 = client.counter.getOrCreate(["multi-3"]);
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2701
|
+
expect16(await retrieved1.increment(0)).toBe(1);
|
|
2702
|
+
expect16(await retrieved2.increment(0)).toBe(2);
|
|
2703
|
+
expect16(await retrieved3.increment(0)).toBe(3);
|
|
2659
2704
|
});
|
|
2660
|
-
|
|
2705
|
+
test16("handles default instance with no explicit ID", async (c) => {
|
|
2661
2706
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2662
2707
|
const defaultCounter = client.counter.getOrCreate();
|
|
2663
2708
|
await defaultCounter.increment(5);
|
|
2664
2709
|
const sameDefaultCounter = client.counter.getOrCreate();
|
|
2665
2710
|
const count = await sameDefaultCounter.increment(0);
|
|
2666
|
-
|
|
2711
|
+
expect16(count).toBe(5);
|
|
2667
2712
|
});
|
|
2668
2713
|
});
|
|
2669
2714
|
});
|
|
2670
2715
|
}
|
|
2671
2716
|
|
|
2672
2717
|
// src/driver-test-suite/tests/raw-http.ts
|
|
2673
|
-
import { describe as
|
|
2718
|
+
import { describe as describe19, expect as expect17, test as test17 } from "vitest";
|
|
2674
2719
|
function runRawHttpTests(driverTestConfig) {
|
|
2675
|
-
|
|
2676
|
-
|
|
2720
|
+
describe19("raw http", () => {
|
|
2721
|
+
test17("should handle raw HTTP GET requests", async (c) => {
|
|
2677
2722
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2678
2723
|
const actor2 = client.rawHttpActor.getOrCreate(["test"]);
|
|
2679
2724
|
const helloResponse = await actor2.fetch("api/hello");
|
|
2680
|
-
|
|
2725
|
+
expect17(helloResponse.ok).toBe(true);
|
|
2681
2726
|
const helloData = await helloResponse.json();
|
|
2682
|
-
|
|
2727
|
+
expect17(helloData).toEqual({ message: "Hello from actor!" });
|
|
2683
2728
|
});
|
|
2684
|
-
|
|
2729
|
+
test17("should handle raw HTTP POST requests with echo", async (c) => {
|
|
2685
2730
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2686
2731
|
const actor2 = client.rawHttpActor.getOrCreate(["test"]);
|
|
2687
2732
|
const testData = { test: "data", number: 123 };
|
|
@@ -2692,22 +2737,22 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2692
2737
|
},
|
|
2693
2738
|
body: JSON.stringify(testData)
|
|
2694
2739
|
});
|
|
2695
|
-
|
|
2740
|
+
expect17(echoResponse.ok).toBe(true);
|
|
2696
2741
|
const echoData = await echoResponse.json();
|
|
2697
|
-
|
|
2742
|
+
expect17(echoData).toEqual(testData);
|
|
2698
2743
|
});
|
|
2699
|
-
|
|
2744
|
+
test17("should track state across raw HTTP requests", async (c) => {
|
|
2700
2745
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2701
2746
|
const actor2 = client.rawHttpActor.getOrCreate(["state-test"]);
|
|
2702
2747
|
await actor2.fetch("api/hello");
|
|
2703
2748
|
await actor2.fetch("api/hello");
|
|
2704
2749
|
await actor2.fetch("api/state");
|
|
2705
2750
|
const stateResponse = await actor2.fetch("api/state");
|
|
2706
|
-
|
|
2751
|
+
expect17(stateResponse.ok).toBe(true);
|
|
2707
2752
|
const stateData = await stateResponse.json();
|
|
2708
|
-
|
|
2753
|
+
expect17(stateData.requestCount).toBe(4);
|
|
2709
2754
|
});
|
|
2710
|
-
|
|
2755
|
+
test17("should pass headers correctly", async (c) => {
|
|
2711
2756
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2712
2757
|
const actor2 = client.rawHttpActor.getOrCreate(["headers-test"]);
|
|
2713
2758
|
const customHeaders = {
|
|
@@ -2717,44 +2762,44 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2717
2762
|
const response = await actor2.fetch("api/headers", {
|
|
2718
2763
|
headers: customHeaders
|
|
2719
2764
|
});
|
|
2720
|
-
|
|
2765
|
+
expect17(response.ok).toBe(true);
|
|
2721
2766
|
const headers = await response.json();
|
|
2722
|
-
|
|
2723
|
-
|
|
2767
|
+
expect17(headers["x-custom-header"]).toBe("test-value");
|
|
2768
|
+
expect17(headers["x-another-header"]).toBe("another-value");
|
|
2724
2769
|
});
|
|
2725
|
-
|
|
2770
|
+
test17("should return 404 for unhandled paths", async (c) => {
|
|
2726
2771
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2727
2772
|
const actor2 = client.rawHttpActor.getOrCreate(["404-test"]);
|
|
2728
2773
|
const response = await actor2.fetch("api/nonexistent");
|
|
2729
|
-
|
|
2730
|
-
|
|
2774
|
+
expect17(response.ok).toBe(false);
|
|
2775
|
+
expect17(response.status).toBe(404);
|
|
2731
2776
|
});
|
|
2732
|
-
|
|
2777
|
+
test17("should return 404 when no onRequest handler defined", async (c) => {
|
|
2733
2778
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2734
2779
|
const actor2 = client.rawHttpNoHandlerActor.getOrCreate([
|
|
2735
2780
|
"no-handler"
|
|
2736
2781
|
]);
|
|
2737
2782
|
const response = await actor2.fetch("api/anything");
|
|
2738
|
-
|
|
2739
|
-
|
|
2783
|
+
expect17(response.ok).toBe(false);
|
|
2784
|
+
expect17(response.status).toBe(404);
|
|
2740
2785
|
});
|
|
2741
|
-
|
|
2786
|
+
test17("should return 500 error when onRequest returns void", async (c) => {
|
|
2742
2787
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2743
2788
|
const actor2 = client.rawHttpVoidReturnActor.getOrCreate([
|
|
2744
2789
|
"void-return"
|
|
2745
2790
|
]);
|
|
2746
2791
|
const response = await actor2.fetch("api/anything");
|
|
2747
|
-
|
|
2748
|
-
|
|
2792
|
+
expect17(response.ok).toBe(false);
|
|
2793
|
+
expect17(response.status).toBe(500);
|
|
2749
2794
|
try {
|
|
2750
2795
|
const errorData = await response.json();
|
|
2751
|
-
|
|
2796
|
+
expect17(errorData.message).toContain(
|
|
2752
2797
|
"onRequest handler must return a Response"
|
|
2753
2798
|
);
|
|
2754
2799
|
} catch {
|
|
2755
2800
|
}
|
|
2756
2801
|
});
|
|
2757
|
-
|
|
2802
|
+
test17("should handle different HTTP methods", async (c) => {
|
|
2758
2803
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2759
2804
|
const actor2 = client.rawHttpActor.getOrCreate(["methods-test"]);
|
|
2760
2805
|
const methods = ["GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
@@ -2764,17 +2809,17 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2764
2809
|
body: ["POST", "PUT", "PATCH"].includes(method) ? JSON.stringify({ method }) : void 0
|
|
2765
2810
|
});
|
|
2766
2811
|
if (method === "POST") {
|
|
2767
|
-
|
|
2812
|
+
expect17(response.ok).toBe(true);
|
|
2768
2813
|
const data = await response.json();
|
|
2769
|
-
|
|
2814
|
+
expect17(data).toEqual({ method });
|
|
2770
2815
|
} else if (method === "GET") {
|
|
2771
|
-
|
|
2816
|
+
expect17(response.status).toBe(404);
|
|
2772
2817
|
} else {
|
|
2773
|
-
|
|
2818
|
+
expect17(response.status).toBe(404);
|
|
2774
2819
|
}
|
|
2775
2820
|
}
|
|
2776
2821
|
});
|
|
2777
|
-
|
|
2822
|
+
test17("should handle binary data", async (c) => {
|
|
2778
2823
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2779
2824
|
const actor2 = client.rawHttpActor.getOrCreate(["binary-test"]);
|
|
2780
2825
|
const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
|
|
@@ -2785,82 +2830,82 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2785
2830
|
},
|
|
2786
2831
|
body: binaryData
|
|
2787
2832
|
});
|
|
2788
|
-
|
|
2833
|
+
expect17(response.ok).toBe(true);
|
|
2789
2834
|
const responseBuffer = await response.arrayBuffer();
|
|
2790
2835
|
const responseArray = new Uint8Array(responseBuffer);
|
|
2791
|
-
|
|
2836
|
+
expect17(Array.from(responseArray)).toEqual([1, 2, 3, 4, 5]);
|
|
2792
2837
|
});
|
|
2793
|
-
|
|
2838
|
+
test17("should work with Hono router using createVars", async (c) => {
|
|
2794
2839
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2795
2840
|
const actor2 = client.rawHttpHonoActor.getOrCreate(["hono-test"]);
|
|
2796
2841
|
const rootResponse = await actor2.fetch("/");
|
|
2797
|
-
|
|
2842
|
+
expect17(rootResponse.ok).toBe(true);
|
|
2798
2843
|
const rootData = await rootResponse.json();
|
|
2799
|
-
|
|
2844
|
+
expect17(rootData).toEqual({ message: "Welcome to Hono actor!" });
|
|
2800
2845
|
const usersResponse = await actor2.fetch("/users");
|
|
2801
|
-
|
|
2846
|
+
expect17(usersResponse.ok).toBe(true);
|
|
2802
2847
|
const users = await usersResponse.json();
|
|
2803
|
-
|
|
2848
|
+
expect17(users).toEqual([
|
|
2804
2849
|
{ id: 1, name: "Alice" },
|
|
2805
2850
|
{ id: 2, name: "Bob" }
|
|
2806
2851
|
]);
|
|
2807
2852
|
const userResponse = await actor2.fetch("/users/1");
|
|
2808
|
-
|
|
2853
|
+
expect17(userResponse.ok).toBe(true);
|
|
2809
2854
|
const user = await userResponse.json();
|
|
2810
|
-
|
|
2855
|
+
expect17(user).toEqual({ id: 1, name: "Alice" });
|
|
2811
2856
|
const newUser = { name: "Charlie" };
|
|
2812
2857
|
const createResponse = await actor2.fetch("/users", {
|
|
2813
2858
|
method: "POST",
|
|
2814
2859
|
headers: { "Content-Type": "application/json" },
|
|
2815
2860
|
body: JSON.stringify(newUser)
|
|
2816
2861
|
});
|
|
2817
|
-
|
|
2818
|
-
|
|
2862
|
+
expect17(createResponse.ok).toBe(true);
|
|
2863
|
+
expect17(createResponse.status).toBe(201);
|
|
2819
2864
|
const createdUser = await createResponse.json();
|
|
2820
|
-
|
|
2865
|
+
expect17(createdUser).toEqual({ id: 3, name: "Charlie" });
|
|
2821
2866
|
const updateData = { name: "Alice Updated" };
|
|
2822
2867
|
const updateResponse = await actor2.fetch("/users/1", {
|
|
2823
2868
|
method: "PUT",
|
|
2824
2869
|
headers: { "Content-Type": "application/json" },
|
|
2825
2870
|
body: JSON.stringify(updateData)
|
|
2826
2871
|
});
|
|
2827
|
-
|
|
2872
|
+
expect17(updateResponse.ok).toBe(true);
|
|
2828
2873
|
const updatedUser = await updateResponse.json();
|
|
2829
|
-
|
|
2874
|
+
expect17(updatedUser).toEqual({ id: 1, name: "Alice Updated" });
|
|
2830
2875
|
const deleteResponse = await actor2.fetch("/users/2", {
|
|
2831
2876
|
method: "DELETE"
|
|
2832
2877
|
});
|
|
2833
|
-
|
|
2878
|
+
expect17(deleteResponse.ok).toBe(true);
|
|
2834
2879
|
const deleteResult = await deleteResponse.json();
|
|
2835
|
-
|
|
2880
|
+
expect17(deleteResult).toEqual({ message: "User 2 deleted" });
|
|
2836
2881
|
const notFoundResponse = await actor2.fetch("/api/unknown");
|
|
2837
|
-
|
|
2838
|
-
|
|
2882
|
+
expect17(notFoundResponse.ok).toBe(false);
|
|
2883
|
+
expect17(notFoundResponse.status).toBe(404);
|
|
2839
2884
|
});
|
|
2840
|
-
|
|
2885
|
+
test17("should handle paths with and without leading slashes", async (c) => {
|
|
2841
2886
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2842
2887
|
const actor2 = client.rawHttpActor.getOrCreate(["path-test"]);
|
|
2843
2888
|
const responseWithoutSlash = await actor2.fetch("api/hello");
|
|
2844
|
-
|
|
2889
|
+
expect17(responseWithoutSlash.ok).toBe(true);
|
|
2845
2890
|
const dataWithoutSlash = await responseWithoutSlash.json();
|
|
2846
|
-
|
|
2891
|
+
expect17(dataWithoutSlash).toEqual({ message: "Hello from actor!" });
|
|
2847
2892
|
const responseWithSlash = await actor2.fetch("/api/hello");
|
|
2848
|
-
|
|
2893
|
+
expect17(responseWithSlash.ok).toBe(true);
|
|
2849
2894
|
const dataWithSlash = await responseWithSlash.json();
|
|
2850
|
-
|
|
2895
|
+
expect17(dataWithSlash).toEqual({ message: "Hello from actor!" });
|
|
2851
2896
|
});
|
|
2852
|
-
|
|
2897
|
+
test17("should not create double slashes in request URLs", async (c) => {
|
|
2853
2898
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2854
2899
|
const actor2 = client.rawHttpHonoActor.getOrCreate(["url-test"]);
|
|
2855
2900
|
const response = await actor2.fetch("/users");
|
|
2856
|
-
|
|
2901
|
+
expect17(response.ok).toBe(true);
|
|
2857
2902
|
const data = await response.json();
|
|
2858
|
-
|
|
2903
|
+
expect17(data).toEqual([
|
|
2859
2904
|
{ id: 1, name: "Alice" },
|
|
2860
2905
|
{ id: 2, name: "Bob" }
|
|
2861
2906
|
]);
|
|
2862
2907
|
});
|
|
2863
|
-
|
|
2908
|
+
test17("should handle forwarded requests correctly without double slashes", async (c) => {
|
|
2864
2909
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2865
2910
|
const actor2 = client.rawHttpHonoActor.getOrCreate(["forward-test"]);
|
|
2866
2911
|
const truncatedPath = "/users";
|
|
@@ -2872,14 +2917,14 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2872
2917
|
truncatedPath,
|
|
2873
2918
|
newRequest
|
|
2874
2919
|
);
|
|
2875
|
-
|
|
2920
|
+
expect17(response.ok).toBe(true);
|
|
2876
2921
|
const users = await response.json();
|
|
2877
|
-
|
|
2922
|
+
expect17(users).toEqual([
|
|
2878
2923
|
{ id: 1, name: "Alice" },
|
|
2879
2924
|
{ id: 2, name: "Bob" }
|
|
2880
2925
|
]);
|
|
2881
2926
|
});
|
|
2882
|
-
|
|
2927
|
+
test17("example fix: should properly forward requests using just Request object", async (c) => {
|
|
2883
2928
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2884
2929
|
const actor2 = client.rawHttpHonoActor.getOrCreate(["forward-fix"]);
|
|
2885
2930
|
const truncatedPath = "/users/1";
|
|
@@ -2888,11 +2933,11 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2888
2933
|
method: "GET"
|
|
2889
2934
|
});
|
|
2890
2935
|
const response = await actor2.fetch(newRequest);
|
|
2891
|
-
|
|
2936
|
+
expect17(response.ok).toBe(true);
|
|
2892
2937
|
const user = await response.json();
|
|
2893
|
-
|
|
2938
|
+
expect17(user).toEqual({ id: 1, name: "Alice" });
|
|
2894
2939
|
});
|
|
2895
|
-
|
|
2940
|
+
test17("should support standard fetch API with URL and Request objects", async (c) => {
|
|
2896
2941
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2897
2942
|
const actor2 = client.rawHttpActor.getOrCreate(["fetch-api-test"]);
|
|
2898
2943
|
const url = new URL("/api/echo", "http://example.com");
|
|
@@ -2901,18 +2946,18 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2901
2946
|
headers: { "Content-Type": "application/json" },
|
|
2902
2947
|
body: JSON.stringify({ from: "URL object" })
|
|
2903
2948
|
});
|
|
2904
|
-
|
|
2949
|
+
expect17(urlResponse.ok).toBe(true);
|
|
2905
2950
|
const urlData = await urlResponse.json();
|
|
2906
|
-
|
|
2951
|
+
expect17(urlData).toEqual({ from: "URL object" });
|
|
2907
2952
|
const request = new Request("http://example.com/api/echo", {
|
|
2908
2953
|
method: "POST",
|
|
2909
2954
|
headers: { "Content-Type": "application/json" },
|
|
2910
2955
|
body: JSON.stringify({ from: "Request object" })
|
|
2911
2956
|
});
|
|
2912
2957
|
const requestResponse = await actor2.fetch(request);
|
|
2913
|
-
|
|
2958
|
+
expect17(requestResponse.ok).toBe(true);
|
|
2914
2959
|
const requestData = await requestResponse.json();
|
|
2915
|
-
|
|
2960
|
+
expect17(requestData).toEqual({ from: "Request object" });
|
|
2916
2961
|
const request2 = new Request("http://example.com/api/headers", {
|
|
2917
2962
|
method: "GET",
|
|
2918
2963
|
headers: { "X-Original": "request-header" }
|
|
@@ -2920,19 +2965,19 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2920
2965
|
const overrideResponse = await actor2.fetch(request2, {
|
|
2921
2966
|
headers: { "X-Override": "init-header" }
|
|
2922
2967
|
});
|
|
2923
|
-
|
|
2968
|
+
expect17(overrideResponse.ok).toBe(true);
|
|
2924
2969
|
const headers = await overrideResponse.json();
|
|
2925
|
-
|
|
2926
|
-
|
|
2970
|
+
expect17(headers["x-override"]).toBe("init-header");
|
|
2971
|
+
expect17(headers["x-original"]).toBe("request-header");
|
|
2927
2972
|
});
|
|
2928
2973
|
});
|
|
2929
2974
|
}
|
|
2930
2975
|
|
|
2931
2976
|
// src/driver-test-suite/tests/raw-http-request-properties.ts
|
|
2932
|
-
import { describe as
|
|
2977
|
+
import { describe as describe20, expect as expect18, test as test18 } from "vitest";
|
|
2933
2978
|
function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
2934
|
-
|
|
2935
|
-
|
|
2979
|
+
describe20("raw http request properties", () => {
|
|
2980
|
+
test18("should pass all Request properties correctly to onRequest", async (c) => {
|
|
2936
2981
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2937
2982
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
2938
2983
|
"test"
|
|
@@ -2946,22 +2991,22 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
2946
2991
|
},
|
|
2947
2992
|
body: JSON.stringify({ test: "data" })
|
|
2948
2993
|
});
|
|
2949
|
-
|
|
2994
|
+
expect18(response.ok).toBe(true);
|
|
2950
2995
|
const data = await response.json();
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2996
|
+
expect18(data.url).toContain("/test/path?foo=bar&baz=qux");
|
|
2997
|
+
expect18(data.pathname).toBe("/test/path");
|
|
2998
|
+
expect18(data.search).toBe("?foo=bar&baz=qux");
|
|
2999
|
+
expect18(data.searchParams).toEqual({
|
|
2955
3000
|
foo: "bar",
|
|
2956
3001
|
baz: "qux"
|
|
2957
3002
|
});
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
3003
|
+
expect18(data.method).toBe("POST");
|
|
3004
|
+
expect18(data.headers["content-type"]).toBe("application/json");
|
|
3005
|
+
expect18(data.headers["x-custom-header"]).toBe("custom-value");
|
|
3006
|
+
expect18(data.headers["authorization"]).toBe("Bearer test-token");
|
|
3007
|
+
expect18(data.body).toEqual({ test: "data" });
|
|
2963
3008
|
});
|
|
2964
|
-
|
|
3009
|
+
test18("should handle GET requests with no body", async (c) => {
|
|
2965
3010
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2966
3011
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
2967
3012
|
"test"
|
|
@@ -2969,12 +3014,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
2969
3014
|
const response = await actor2.fetch("test/get", {
|
|
2970
3015
|
method: "GET"
|
|
2971
3016
|
});
|
|
2972
|
-
|
|
3017
|
+
expect18(response.ok).toBe(true);
|
|
2973
3018
|
const data = await response.json();
|
|
2974
|
-
|
|
2975
|
-
|
|
3019
|
+
expect18(data.method).toBe("GET");
|
|
3020
|
+
expect18(data.body).toBeNull();
|
|
2976
3021
|
});
|
|
2977
|
-
|
|
3022
|
+
test18("should handle different content types", async (c) => {
|
|
2978
3023
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2979
3024
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
2980
3025
|
"test"
|
|
@@ -2989,12 +3034,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
2989
3034
|
},
|
|
2990
3035
|
body: formData.toString()
|
|
2991
3036
|
});
|
|
2992
|
-
|
|
3037
|
+
expect18(formResponse.ok).toBe(true);
|
|
2993
3038
|
const formResult = await formResponse.json();
|
|
2994
|
-
|
|
3039
|
+
expect18(formResult.headers["content-type"]).toBe(
|
|
2995
3040
|
"application/x-www-form-urlencoded"
|
|
2996
3041
|
);
|
|
2997
|
-
|
|
3042
|
+
expect18(formResult.bodyText).toBe("field1=value1&field2=value2");
|
|
2998
3043
|
const textResponse = await actor2.fetch("test/text", {
|
|
2999
3044
|
method: "POST",
|
|
3000
3045
|
headers: {
|
|
@@ -3002,12 +3047,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3002
3047
|
},
|
|
3003
3048
|
body: "Hello, World!"
|
|
3004
3049
|
});
|
|
3005
|
-
|
|
3050
|
+
expect18(textResponse.ok).toBe(true);
|
|
3006
3051
|
const textResult = await textResponse.json();
|
|
3007
|
-
|
|
3008
|
-
|
|
3052
|
+
expect18(textResult.headers["content-type"]).toBe("text/plain");
|
|
3053
|
+
expect18(textResult.bodyText).toBe("Hello, World!");
|
|
3009
3054
|
});
|
|
3010
|
-
|
|
3055
|
+
test18("should preserve all header casing and values", async (c) => {
|
|
3011
3056
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3012
3057
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3013
3058
|
"test"
|
|
@@ -3021,38 +3066,38 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3021
3066
|
"X-Request-ID": "12345"
|
|
3022
3067
|
}
|
|
3023
3068
|
});
|
|
3024
|
-
|
|
3069
|
+
expect18(response.ok).toBe(true);
|
|
3025
3070
|
const data = await response.json();
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3071
|
+
expect18(data.headers["accept"]).toBe("application/json");
|
|
3072
|
+
expect18(data.headers["accept-language"]).toBe("en-US,en;q=0.9");
|
|
3073
|
+
expect18(data.headers["cache-control"]).toBe("no-cache");
|
|
3074
|
+
expect18(data.headers["user-agent"]).toBeTruthy();
|
|
3075
|
+
expect18(data.headers["x-request-id"]).toBe("12345");
|
|
3031
3076
|
});
|
|
3032
|
-
|
|
3077
|
+
test18("should handle empty and special URL paths", async (c) => {
|
|
3033
3078
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3034
3079
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3035
3080
|
"test"
|
|
3036
3081
|
]);
|
|
3037
3082
|
const rootResponse = await actor2.fetch("");
|
|
3038
|
-
|
|
3083
|
+
expect18(rootResponse.ok).toBe(true);
|
|
3039
3084
|
const rootData = await rootResponse.json();
|
|
3040
|
-
|
|
3085
|
+
expect18(rootData.pathname).toBe("/");
|
|
3041
3086
|
const specialResponse = await actor2.fetch(
|
|
3042
3087
|
"test/path%20with%20spaces/and%2Fslashes"
|
|
3043
3088
|
);
|
|
3044
|
-
|
|
3089
|
+
expect18(specialResponse.ok).toBe(true);
|
|
3045
3090
|
const specialData = await specialResponse.json();
|
|
3046
|
-
|
|
3091
|
+
expect18(specialData.pathname).toMatch(
|
|
3047
3092
|
/path.*with.*spaces.*and.*slashes/
|
|
3048
3093
|
);
|
|
3049
3094
|
const fragmentResponse = await actor2.fetch("test/path#fragment");
|
|
3050
|
-
|
|
3095
|
+
expect18(fragmentResponse.ok).toBe(true);
|
|
3051
3096
|
const fragmentData = await fragmentResponse.json();
|
|
3052
|
-
|
|
3053
|
-
|
|
3097
|
+
expect18(fragmentData.pathname).toBe("/test/path");
|
|
3098
|
+
expect18(fragmentData.hash).toBe("");
|
|
3054
3099
|
});
|
|
3055
|
-
|
|
3100
|
+
test18("should handle request properties for all HTTP methods", async (c) => {
|
|
3056
3101
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3057
3102
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3058
3103
|
"test"
|
|
@@ -3076,21 +3121,21 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3076
3121
|
}
|
|
3077
3122
|
);
|
|
3078
3123
|
if (method === "HEAD") {
|
|
3079
|
-
|
|
3124
|
+
expect18(response.status).toBe(200);
|
|
3080
3125
|
const text = await response.text();
|
|
3081
|
-
|
|
3126
|
+
expect18(text).toBe("");
|
|
3082
3127
|
} else if (method === "OPTIONS") {
|
|
3083
|
-
|
|
3128
|
+
expect18(response.status).toBe(204);
|
|
3084
3129
|
const text = await response.text();
|
|
3085
|
-
|
|
3130
|
+
expect18(text).toBe("");
|
|
3086
3131
|
} else {
|
|
3087
|
-
|
|
3132
|
+
expect18(response.ok).toBe(true);
|
|
3088
3133
|
const data = await response.json();
|
|
3089
|
-
|
|
3134
|
+
expect18(data.method).toBe(method);
|
|
3090
3135
|
}
|
|
3091
3136
|
}
|
|
3092
3137
|
});
|
|
3093
|
-
|
|
3138
|
+
test18("should handle complex query parameters", async (c) => {
|
|
3094
3139
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3095
3140
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3096
3141
|
"test"
|
|
@@ -3098,13 +3143,13 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3098
3143
|
const response = await actor2.fetch(
|
|
3099
3144
|
"test?key=value1&key=value2&array[]=1&array[]=2&nested[prop]=val"
|
|
3100
3145
|
);
|
|
3101
|
-
|
|
3146
|
+
expect18(response.ok).toBe(true);
|
|
3102
3147
|
const data = await response.json();
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3148
|
+
expect18(data.searchParams.key).toBe("value2");
|
|
3149
|
+
expect18(data.searchParams["array[]"]).toBe("2");
|
|
3150
|
+
expect18(data.searchParams["nested[prop]"]).toBe("val");
|
|
3106
3151
|
});
|
|
3107
|
-
|
|
3152
|
+
test18("should handle multipart form data", async (c) => {
|
|
3108
3153
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3109
3154
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3110
3155
|
"test"
|
|
@@ -3128,27 +3173,27 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3128
3173
|
},
|
|
3129
3174
|
body
|
|
3130
3175
|
});
|
|
3131
|
-
|
|
3176
|
+
expect18(response.ok).toBe(true);
|
|
3132
3177
|
const data = await response.json();
|
|
3133
|
-
|
|
3178
|
+
expect18(data.headers["content-type"]).toContain(
|
|
3134
3179
|
"multipart/form-data"
|
|
3135
3180
|
);
|
|
3136
|
-
|
|
3137
|
-
|
|
3181
|
+
expect18(data.bodyText).toContain("field1");
|
|
3182
|
+
expect18(data.bodyText).toContain("value1");
|
|
3138
3183
|
});
|
|
3139
|
-
|
|
3184
|
+
test18("should handle very long URLs", async (c) => {
|
|
3140
3185
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3141
3186
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3142
3187
|
"test"
|
|
3143
3188
|
]);
|
|
3144
3189
|
const longValue = "x".repeat(1e3);
|
|
3145
3190
|
const response = await actor2.fetch(`test/long?param=${longValue}`);
|
|
3146
|
-
|
|
3191
|
+
expect18(response.ok).toBe(true);
|
|
3147
3192
|
const data = await response.json();
|
|
3148
|
-
|
|
3149
|
-
|
|
3193
|
+
expect18(data.searchParams.param).toBe(longValue);
|
|
3194
|
+
expect18(data.search.length).toBeGreaterThan(1e3);
|
|
3150
3195
|
});
|
|
3151
|
-
|
|
3196
|
+
test18.skip("should handle large request bodies", async (c) => {
|
|
3152
3197
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3153
3198
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3154
3199
|
"test"
|
|
@@ -3165,11 +3210,11 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3165
3210
|
},
|
|
3166
3211
|
body: JSON.stringify(largeArray)
|
|
3167
3212
|
});
|
|
3168
|
-
|
|
3213
|
+
expect18(response.ok).toBe(true);
|
|
3169
3214
|
const data = await response.json();
|
|
3170
|
-
|
|
3215
|
+
expect18(data.body).toHaveLength(1e4);
|
|
3171
3216
|
});
|
|
3172
|
-
|
|
3217
|
+
test18("should handle missing content-type header", async (c) => {
|
|
3173
3218
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3174
3219
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3175
3220
|
"test"
|
|
@@ -3178,11 +3223,11 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3178
3223
|
method: "POST",
|
|
3179
3224
|
body: "plain text without content-type"
|
|
3180
3225
|
});
|
|
3181
|
-
|
|
3226
|
+
expect18(response.ok).toBe(true);
|
|
3182
3227
|
const data = await response.json();
|
|
3183
|
-
|
|
3228
|
+
expect18(data.bodyText).toBe("plain text without content-type");
|
|
3184
3229
|
});
|
|
3185
|
-
|
|
3230
|
+
test18("should handle empty request body", async (c) => {
|
|
3186
3231
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3187
3232
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3188
3233
|
"test"
|
|
@@ -3194,9 +3239,9 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3194
3239
|
},
|
|
3195
3240
|
body: ""
|
|
3196
3241
|
});
|
|
3197
|
-
|
|
3242
|
+
expect18(response.ok).toBe(true);
|
|
3198
3243
|
});
|
|
3199
|
-
|
|
3244
|
+
test18("should handle custom HTTP methods", async (c) => {
|
|
3200
3245
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3201
3246
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3202
3247
|
"test"
|
|
@@ -3207,12 +3252,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3207
3252
|
});
|
|
3208
3253
|
if (response.ok) {
|
|
3209
3254
|
const data = await response.json();
|
|
3210
|
-
|
|
3255
|
+
expect18(data.method).toBe("CUSTOM");
|
|
3211
3256
|
}
|
|
3212
3257
|
} catch (error) {
|
|
3213
3258
|
}
|
|
3214
3259
|
});
|
|
3215
|
-
|
|
3260
|
+
test18("should handle cookies in headers", async (c) => {
|
|
3216
3261
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3217
3262
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3218
3263
|
"test"
|
|
@@ -3222,13 +3267,13 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3222
3267
|
Cookie: "session=abc123; user=test; preferences=dark_mode"
|
|
3223
3268
|
}
|
|
3224
3269
|
});
|
|
3225
|
-
|
|
3270
|
+
expect18(response.ok).toBe(true);
|
|
3226
3271
|
const data = await response.json();
|
|
3227
|
-
|
|
3272
|
+
expect18(data.headers.cookie).toBe(
|
|
3228
3273
|
"session=abc123; user=test; preferences=dark_mode"
|
|
3229
3274
|
);
|
|
3230
3275
|
});
|
|
3231
|
-
|
|
3276
|
+
test18("should handle URL encoding properly", async (c) => {
|
|
3232
3277
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3233
3278
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3234
3279
|
"test"
|
|
@@ -3236,13 +3281,13 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3236
3281
|
const response = await actor2.fetch(
|
|
3237
3282
|
"test/encoded?special=%20%21%40%23%24%25%5E%26&unicode=%E2%9C%93&email=test%40example.com"
|
|
3238
3283
|
);
|
|
3239
|
-
|
|
3284
|
+
expect18(response.ok).toBe(true);
|
|
3240
3285
|
const data = await response.json();
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3286
|
+
expect18(data.searchParams.special).toBe(" !@#$%^&");
|
|
3287
|
+
expect18(data.searchParams.unicode).toBe("\u2713");
|
|
3288
|
+
expect18(data.searchParams.email).toBe("test@example.com");
|
|
3244
3289
|
});
|
|
3245
|
-
|
|
3290
|
+
test18("should handle concurrent requests maintaining separate contexts", async (c) => {
|
|
3246
3291
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3247
3292
|
const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3248
3293
|
"test"
|
|
@@ -3266,24 +3311,24 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3266
3311
|
const results = await Promise.all(
|
|
3267
3312
|
responses.map((r) => r.json())
|
|
3268
3313
|
);
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3314
|
+
expect18(results[0].searchParams.id).toBe("1");
|
|
3315
|
+
expect18(results[0].method).toBe("POST");
|
|
3316
|
+
expect18(results[0].body).toEqual({ request: 1 });
|
|
3317
|
+
expect18(results[1].searchParams.id).toBe("2");
|
|
3318
|
+
expect18(results[1].method).toBe("PUT");
|
|
3319
|
+
expect18(results[1].body).toEqual({ request: 2 });
|
|
3320
|
+
expect18(results[2].searchParams.id).toBe("3");
|
|
3321
|
+
expect18(results[2].method).toBe("DELETE");
|
|
3322
|
+
expect18(results[2].body).toBeNull();
|
|
3278
3323
|
});
|
|
3279
3324
|
});
|
|
3280
3325
|
}
|
|
3281
3326
|
|
|
3282
3327
|
// src/driver-test-suite/tests/raw-websocket.ts
|
|
3283
|
-
import { describe as
|
|
3328
|
+
import { describe as describe21, expect as expect19, test as test19 } from "vitest";
|
|
3284
3329
|
function runRawWebSocketTests(driverTestConfig) {
|
|
3285
|
-
|
|
3286
|
-
|
|
3330
|
+
describe21("raw websocket", () => {
|
|
3331
|
+
test19("should establish raw WebSocket connection", async (c) => {
|
|
3287
3332
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3288
3333
|
const actor2 = client.rawWebSocketActor.getOrCreate(["basic"]);
|
|
3289
3334
|
const ws = await actor2.websocket();
|
|
@@ -3310,11 +3355,11 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3310
3355
|
);
|
|
3311
3356
|
ws.addEventListener("close", reject);
|
|
3312
3357
|
});
|
|
3313
|
-
|
|
3314
|
-
|
|
3358
|
+
expect19(welcomeMessage.type).toBe("welcome");
|
|
3359
|
+
expect19(welcomeMessage.connectionCount).toBe(1);
|
|
3315
3360
|
ws.close();
|
|
3316
3361
|
});
|
|
3317
|
-
|
|
3362
|
+
test19("should echo messages", async (c) => {
|
|
3318
3363
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3319
3364
|
const actor2 = client.rawWebSocketActor.getOrCreate(["echo"]);
|
|
3320
3365
|
const ws = await actor2.websocket();
|
|
@@ -3342,10 +3387,10 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3342
3387
|
);
|
|
3343
3388
|
ws.addEventListener("close", reject);
|
|
3344
3389
|
});
|
|
3345
|
-
|
|
3390
|
+
expect19(echoMessage).toEqual(testMessage);
|
|
3346
3391
|
ws.close();
|
|
3347
3392
|
});
|
|
3348
|
-
|
|
3393
|
+
test19("should handle ping/pong protocol", async (c) => {
|
|
3349
3394
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3350
3395
|
const actor2 = client.rawWebSocketActor.getOrCreate(["ping"]);
|
|
3351
3396
|
const ws = await actor2.websocket();
|
|
@@ -3371,11 +3416,11 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3371
3416
|
});
|
|
3372
3417
|
ws.addEventListener("close", reject);
|
|
3373
3418
|
});
|
|
3374
|
-
|
|
3375
|
-
|
|
3419
|
+
expect19(pongMessage.type).toBe("pong");
|
|
3420
|
+
expect19(pongMessage.timestamp).toBeDefined();
|
|
3376
3421
|
ws.close();
|
|
3377
3422
|
});
|
|
3378
|
-
|
|
3423
|
+
test19("should track stats across connections", async (c) => {
|
|
3379
3424
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3380
3425
|
const actor1 = client.rawWebSocketActor.getOrCreate(["stats"]);
|
|
3381
3426
|
const ws1 = await actor1.websocket();
|
|
@@ -3419,15 +3464,15 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3419
3464
|
});
|
|
3420
3465
|
ws1.send(JSON.stringify({ type: "getStats" }));
|
|
3421
3466
|
const stats = await statsPromise;
|
|
3422
|
-
|
|
3423
|
-
|
|
3467
|
+
expect19(stats.connectionCount).toBe(2);
|
|
3468
|
+
expect19(stats.messageCount).toBe(4);
|
|
3424
3469
|
const actionStats = await actor1.getStats();
|
|
3425
|
-
|
|
3426
|
-
|
|
3470
|
+
expect19(actionStats.connectionCount).toBe(2);
|
|
3471
|
+
expect19(actionStats.messageCount).toBe(4);
|
|
3427
3472
|
ws1.close();
|
|
3428
3473
|
ws2.close();
|
|
3429
3474
|
});
|
|
3430
|
-
|
|
3475
|
+
test19("should handle binary data", async (c) => {
|
|
3431
3476
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3432
3477
|
const actor2 = client.rawWebSocketBinaryActor.getOrCreate([
|
|
3433
3478
|
"binary"
|
|
@@ -3460,7 +3505,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3460
3505
|
const smallData = new Uint8Array([1, 2, 3, 4, 5]);
|
|
3461
3506
|
ws.send(smallData);
|
|
3462
3507
|
const smallReversed = await receiveBinaryMessage();
|
|
3463
|
-
|
|
3508
|
+
expect19(Array.from(smallReversed)).toEqual([5, 4, 3, 2, 1]);
|
|
3464
3509
|
const largeData = new Uint8Array(1024);
|
|
3465
3510
|
for (let i = 0; i < largeData.length; i++) {
|
|
3466
3511
|
largeData[i] = i % 256;
|
|
@@ -3468,13 +3513,13 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3468
3513
|
ws.send(largeData);
|
|
3469
3514
|
const largeReversed = await receiveBinaryMessage();
|
|
3470
3515
|
for (let i = 0; i < largeData.length; i++) {
|
|
3471
|
-
|
|
3516
|
+
expect19(largeReversed[i]).toBe(
|
|
3472
3517
|
largeData[largeData.length - 1 - i]
|
|
3473
3518
|
);
|
|
3474
3519
|
}
|
|
3475
3520
|
ws.close();
|
|
3476
3521
|
});
|
|
3477
|
-
|
|
3522
|
+
test19("should work with custom paths", async (c) => {
|
|
3478
3523
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3479
3524
|
const actor2 = client.rawWebSocketActor.getOrCreate(["paths"]);
|
|
3480
3525
|
const ws = await actor2.websocket("custom/path");
|
|
@@ -3494,10 +3539,10 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3494
3539
|
{ once: true }
|
|
3495
3540
|
);
|
|
3496
3541
|
});
|
|
3497
|
-
|
|
3542
|
+
expect19(welcomeMessage.type).toBe("welcome");
|
|
3498
3543
|
ws.close();
|
|
3499
3544
|
});
|
|
3500
|
-
|
|
3545
|
+
test19("should handle connection close properly", async (c) => {
|
|
3501
3546
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3502
3547
|
const actor2 = client.rawWebSocketActor.getOrCreate(["close-test"]);
|
|
3503
3548
|
const ws = await actor2.websocket();
|
|
@@ -3510,7 +3555,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3510
3555
|
});
|
|
3511
3556
|
}
|
|
3512
3557
|
const initialStats = await actor2.getStats();
|
|
3513
|
-
|
|
3558
|
+
expect19(initialStats.connectionCount).toBe(1);
|
|
3514
3559
|
const closePromise = new Promise((resolve) => {
|
|
3515
3560
|
ws.addEventListener("close", () => resolve(), { once: true });
|
|
3516
3561
|
});
|
|
@@ -3524,9 +3569,9 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3524
3569
|
}
|
|
3525
3570
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
3526
3571
|
}
|
|
3527
|
-
|
|
3572
|
+
expect19(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
|
|
3528
3573
|
});
|
|
3529
|
-
|
|
3574
|
+
test19("should properly handle onWebSocket open and close events", async (c) => {
|
|
3530
3575
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3531
3576
|
const actor2 = client.rawWebSocketActor.getOrCreate([
|
|
3532
3577
|
"open-close-test"
|
|
@@ -3546,8 +3591,8 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3546
3591
|
);
|
|
3547
3592
|
ws1.addEventListener("close", reject);
|
|
3548
3593
|
});
|
|
3549
|
-
|
|
3550
|
-
|
|
3594
|
+
expect19(welcome1.type).toBe("welcome");
|
|
3595
|
+
expect19(welcome1.connectionCount).toBe(1);
|
|
3551
3596
|
const ws2 = await actor2.websocket();
|
|
3552
3597
|
await new Promise((resolve, reject) => {
|
|
3553
3598
|
ws2.addEventListener("open", () => resolve(), { once: true });
|
|
@@ -3563,10 +3608,10 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3563
3608
|
);
|
|
3564
3609
|
ws2.addEventListener("close", reject);
|
|
3565
3610
|
});
|
|
3566
|
-
|
|
3567
|
-
|
|
3611
|
+
expect19(welcome2.type).toBe("welcome");
|
|
3612
|
+
expect19(welcome2.connectionCount).toBe(2);
|
|
3568
3613
|
const midStats = await actor2.getStats();
|
|
3569
|
-
|
|
3614
|
+
expect19(midStats.connectionCount).toBe(2);
|
|
3570
3615
|
ws1.close();
|
|
3571
3616
|
await new Promise((resolve) => {
|
|
3572
3617
|
ws1.addEventListener("close", () => resolve(), { once: true });
|
|
@@ -3579,7 +3624,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3579
3624
|
}
|
|
3580
3625
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
3581
3626
|
}
|
|
3582
|
-
|
|
3627
|
+
expect19(afterFirstClose == null ? void 0 : afterFirstClose.connectionCount).toBe(1);
|
|
3583
3628
|
ws2.close();
|
|
3584
3629
|
await new Promise((resolve) => {
|
|
3585
3630
|
ws2.addEventListener("close", () => resolve(), { once: true });
|
|
@@ -3592,9 +3637,9 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3592
3637
|
}
|
|
3593
3638
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
3594
3639
|
}
|
|
3595
|
-
|
|
3640
|
+
expect19(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
|
|
3596
3641
|
});
|
|
3597
|
-
|
|
3642
|
+
test19("should handle query parameters in websocket paths", async (c) => {
|
|
3598
3643
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3599
3644
|
const actor2 = client.rawWebSocketActor.getOrCreate([
|
|
3600
3645
|
"query-params"
|
|
@@ -3617,19 +3662,19 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3617
3662
|
});
|
|
3618
3663
|
ws.send(JSON.stringify({ type: "getRequestInfo" }));
|
|
3619
3664
|
const requestInfo = await requestInfoPromise;
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3665
|
+
expect19(requestInfo.url).toContain("api/v1/stream");
|
|
3666
|
+
expect19(requestInfo.url).toContain("token=abc123");
|
|
3667
|
+
expect19(requestInfo.url).toContain("user=test");
|
|
3623
3668
|
ws.close();
|
|
3624
3669
|
});
|
|
3625
3670
|
});
|
|
3626
3671
|
}
|
|
3627
3672
|
|
|
3628
3673
|
// src/driver-test-suite/tests/request-access.ts
|
|
3629
|
-
import { describe as
|
|
3674
|
+
import { describe as describe22, expect as expect20, test as test20 } from "vitest";
|
|
3630
3675
|
function runRequestAccessTests(driverTestConfig) {
|
|
3631
|
-
|
|
3632
|
-
|
|
3676
|
+
describe22("Request Access in Lifecycle Hooks", () => {
|
|
3677
|
+
test20("should have access to request object in onBeforeConnect and createConnState", async (c) => {
|
|
3633
3678
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3634
3679
|
const handle = client.requestAccessActor.getOrCreate(
|
|
3635
3680
|
["test-request"],
|
|
@@ -3640,23 +3685,23 @@ function runRequestAccessTests(driverTestConfig) {
|
|
|
3640
3685
|
const connection = handle.connect();
|
|
3641
3686
|
const requestInfo = await connection.getRequestInfo();
|
|
3642
3687
|
if (driverTestConfig.clientType === "http") {
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3688
|
+
expect20(requestInfo.onBeforeConnect.hasRequest).toBe(true);
|
|
3689
|
+
expect20(requestInfo.onBeforeConnect.requestUrl).toBeDefined();
|
|
3690
|
+
expect20(requestInfo.onBeforeConnect.requestMethod).toBeDefined();
|
|
3691
|
+
expect20(
|
|
3647
3692
|
requestInfo.onBeforeConnect.requestHeaders
|
|
3648
3693
|
).toBeDefined();
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3694
|
+
expect20(requestInfo.createConnState.hasRequest).toBe(true);
|
|
3695
|
+
expect20(requestInfo.createConnState.requestUrl).toBeDefined();
|
|
3696
|
+
expect20(requestInfo.createConnState.requestMethod).toBeDefined();
|
|
3697
|
+
expect20(
|
|
3653
3698
|
requestInfo.createConnState.requestHeaders
|
|
3654
3699
|
).toBeDefined();
|
|
3655
3700
|
} else {
|
|
3656
3701
|
}
|
|
3657
3702
|
await connection.dispose();
|
|
3658
3703
|
});
|
|
3659
|
-
|
|
3704
|
+
test20("should not have request when trackRequest is false", async (c) => {
|
|
3660
3705
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3661
3706
|
const handle = client.requestAccessActor.getOrCreate(
|
|
3662
3707
|
["test-no-request"],
|
|
@@ -3666,21 +3711,21 @@ function runRequestAccessTests(driverTestConfig) {
|
|
|
3666
3711
|
);
|
|
3667
3712
|
const connection = handle.connect();
|
|
3668
3713
|
const requestInfo = await connection.getRequestInfo();
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3714
|
+
expect20(requestInfo.onBeforeConnect.hasRequest).toBe(false);
|
|
3715
|
+
expect20(requestInfo.onBeforeConnect.requestUrl).toBeNull();
|
|
3716
|
+
expect20(requestInfo.onBeforeConnect.requestMethod).toBeNull();
|
|
3717
|
+
expect20(
|
|
3673
3718
|
Object.keys(requestInfo.onBeforeConnect.requestHeaders)
|
|
3674
3719
|
).toHaveLength(0);
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3720
|
+
expect20(requestInfo.createConnState.hasRequest).toBe(false);
|
|
3721
|
+
expect20(requestInfo.createConnState.requestUrl).toBeNull();
|
|
3722
|
+
expect20(requestInfo.createConnState.requestMethod).toBeNull();
|
|
3723
|
+
expect20(
|
|
3679
3724
|
Object.keys(requestInfo.createConnState.requestHeaders)
|
|
3680
3725
|
).toHaveLength(0);
|
|
3681
3726
|
await connection.dispose();
|
|
3682
3727
|
});
|
|
3683
|
-
|
|
3728
|
+
test20("should capture request headers and method", async (c) => {
|
|
3684
3729
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3685
3730
|
const handle = client.requestAccessActor.getOrCreate(
|
|
3686
3731
|
["test-headers"],
|
|
@@ -3691,18 +3736,18 @@ function runRequestAccessTests(driverTestConfig) {
|
|
|
3691
3736
|
const connection = handle.connect();
|
|
3692
3737
|
const requestInfo = await connection.getRequestInfo();
|
|
3693
3738
|
if (driverTestConfig.clientType === "http") {
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3739
|
+
expect20(requestInfo.onBeforeConnect.hasRequest).toBe(true);
|
|
3740
|
+
expect20(requestInfo.onBeforeConnect.requestMethod).toBeTruthy();
|
|
3741
|
+
expect20(requestInfo.onBeforeConnect.requestUrl).toBeTruthy();
|
|
3742
|
+
expect20(requestInfo.onBeforeConnect.requestHeaders).toBeTruthy();
|
|
3743
|
+
expect20(typeof requestInfo.onBeforeConnect.requestHeaders).toBe(
|
|
3699
3744
|
"object"
|
|
3700
3745
|
);
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3746
|
+
expect20(requestInfo.createConnState.hasRequest).toBe(true);
|
|
3747
|
+
expect20(requestInfo.createConnState.requestMethod).toBeTruthy();
|
|
3748
|
+
expect20(requestInfo.createConnState.requestUrl).toBeTruthy();
|
|
3749
|
+
expect20(requestInfo.createConnState.requestHeaders).toBeTruthy();
|
|
3750
|
+
expect20(typeof requestInfo.createConnState.requestHeaders).toBe(
|
|
3706
3751
|
"object"
|
|
3707
3752
|
);
|
|
3708
3753
|
} else {
|
|
@@ -3717,10 +3762,10 @@ function runDriverTests(driverTestConfigPartial) {
|
|
|
3717
3762
|
var _a;
|
|
3718
3763
|
const clientTypes = ((_a = driverTestConfigPartial.skip) == null ? void 0 : _a.inline) ? ["http"] : ["http", "inline"];
|
|
3719
3764
|
for (const clientType of clientTypes) {
|
|
3720
|
-
|
|
3765
|
+
describe23(`client type (${clientType})`, () => {
|
|
3721
3766
|
const encodings = ["bare", "cbor", "json"];
|
|
3722
3767
|
for (const encoding of encodings) {
|
|
3723
|
-
|
|
3768
|
+
describe23(`encoding (${encoding})`, () => {
|
|
3724
3769
|
const driverTestConfig = {
|
|
3725
3770
|
...driverTestConfigPartial,
|
|
3726
3771
|
clientType,
|
|
@@ -3740,6 +3785,7 @@ function runDriverTests(driverTestConfigPartial) {
|
|
|
3740
3785
|
runActorOnStateChangeTests(driverTestConfig);
|
|
3741
3786
|
runActorErrorHandlingTests(driverTestConfig);
|
|
3742
3787
|
runActorInlineClientTests(driverTestConfig);
|
|
3788
|
+
runActorKvTests(driverTestConfig);
|
|
3743
3789
|
runRawHttpTests(driverTestConfig);
|
|
3744
3790
|
runRawHttpRequestPropertiesTests(driverTestConfig);
|
|
3745
3791
|
runRawWebSocketTests(driverTestConfig);
|