@elench/testkit 0.1.81 → 0.1.82
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/README.md +28 -21
- package/lib/config-api/auth-fixtures.mjs +762 -0
- package/lib/config-api/index.d.ts +92 -108
- package/lib/config-api/index.mjs +22 -12
- package/lib/config-api/index.test.mjs +61 -222
- package/lib/index.d.ts +29 -9
- package/lib/runtime/index.d.ts +50 -33
- package/lib/runtime/index.mjs +0 -1
- package/lib/runtime-src/k6/http-suite-runtime.js +147 -0
- package/lib/runtime-src/k6/http.js +80 -41
- package/lib/runtime-src/k6/scenario-suite.js +13 -110
- package/lib/runtime-src/k6/suite.js +13 -107
- package/node_modules/@elench/next-analysis/package.json +1 -1
- package/node_modules/@elench/testkit-bridge/package.json +2 -2
- package/node_modules/@elench/testkit-protocol/package.json +1 -1
- package/node_modules/@elench/ts-analysis/package.json +1 -1
- package/package.json +5 -5
- package/lib/config-api/profiles.mjs +0 -640
package/README.md
CHANGED
|
@@ -380,32 +380,39 @@ Named HTTP profiles live in `testkit.config.ts` and can be referenced by name:
|
|
|
380
380
|
|
|
381
381
|
```ts
|
|
382
382
|
import { defineHttpSuite } from "@elench/testkit";
|
|
383
|
-
import {
|
|
383
|
+
import { auth, defineConfig } from "@elench/testkit/config";
|
|
384
|
+
|
|
385
|
+
const appAuth = auth.fixture({
|
|
386
|
+
contract: auth.contracts.jsonSession({
|
|
387
|
+
authCookie: "session",
|
|
388
|
+
organizationIdPath: "data.organizations[0].id",
|
|
389
|
+
}),
|
|
390
|
+
topology: auth.topologies.crossOrg({
|
|
391
|
+
namespace: "example-app",
|
|
392
|
+
actors: {
|
|
393
|
+
primary: { org: "primary" },
|
|
394
|
+
reviewer: { org: "primary" },
|
|
395
|
+
outsider: { org: "secondary" },
|
|
396
|
+
},
|
|
397
|
+
}),
|
|
398
|
+
});
|
|
384
399
|
|
|
385
400
|
export default defineConfig({
|
|
386
401
|
profiles: {
|
|
387
|
-
http: {
|
|
388
|
-
defaultAuth:
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
session: {
|
|
396
|
-
authCookie: "session",
|
|
397
|
-
},
|
|
398
|
-
headers: {
|
|
399
|
-
contentTypeJson: true,
|
|
400
|
-
forwardedFor: "deterministic",
|
|
401
|
-
},
|
|
402
|
-
}).session(),
|
|
403
|
-
},
|
|
402
|
+
http: appAuth.profiles({
|
|
403
|
+
defaultAuth: auth.profile.actor("primary"),
|
|
404
|
+
reviewers: auth.profile.actors({
|
|
405
|
+
actors: ["reviewer", "outsider"],
|
|
406
|
+
primaryActor: "reviewer",
|
|
407
|
+
}),
|
|
408
|
+
raw: auth.profile.raw(),
|
|
409
|
+
}),
|
|
404
410
|
},
|
|
405
411
|
});
|
|
406
412
|
|
|
407
|
-
const suite = defineHttpSuite({ profile: "defaultAuth" }, ({
|
|
408
|
-
req("
|
|
413
|
+
const suite = defineHttpSuite({ profile: "defaultAuth" }, ({ actor, req }) => {
|
|
414
|
+
req.get("/api/auth/session");
|
|
415
|
+
actor?.req.get("/api/auth/session");
|
|
409
416
|
});
|
|
410
417
|
```
|
|
411
418
|
|
|
@@ -455,7 +462,7 @@ Consumers should not set local timeout values in test files.
|
|
|
455
462
|
import { waitFor } from "@elench/testkit/runtime";
|
|
456
463
|
|
|
457
464
|
const response = waitFor(
|
|
458
|
-
() => req("
|
|
465
|
+
() => req.get("/api/v1/jobs/123"),
|
|
459
466
|
(res) => JSON.parse(res.body).data?.status === "completed",
|
|
460
467
|
{ description: "job 123 to complete" }
|
|
461
468
|
);
|