@flowriki/agent 0.1.0-beta.30 → 0.1.0-beta.31

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.
@@ -6,7 +6,7 @@ import os from "os";
6
6
  import path from "path";
7
7
  import { createRequire } from "module";
8
8
  import { spawnSync } from "child_process";
9
- var AGENT_VERSION = "0.1.0-beta.30";
9
+ var AGENT_VERSION = "0.1.0-beta.31";
10
10
  async function prepareBrowsers() {
11
11
  if (browsersReady()) {
12
12
  return { ok: true, already: true, message: "chromium is already installed" };
@@ -462,6 +462,7 @@ import fs7 from "fs";
462
462
  import path7 from "path";
463
463
 
464
464
  // ../engine-playwright/dist/index.js
465
+ import { randomBytes } from "crypto";
465
466
  import path3 from "path";
466
467
 
467
468
  // ../test-model/dist/chunk-GALEMMJW.js
@@ -1719,7 +1720,7 @@ var DeliveredHelperSchema = z42.object({
1719
1720
  }).strict();
1720
1721
 
1721
1722
  // ../engine-playwright/dist/index.js
1722
- import { createHmac, randomBytes } from "crypto";
1723
+ import { createHmac, randomBytes as randomBytes2 } from "crypto";
1723
1724
  import { errors as errors2 } from "playwright";
1724
1725
 
1725
1726
  // ../core/dist/index.js
@@ -3505,11 +3506,20 @@ import { fileURLToPath } from "url";
3505
3506
  import "playwright";
3506
3507
  import fs32 from "fs";
3507
3508
  import "playwright";
3509
+ function makeUnique(now = Date.now()) {
3510
+ return `${now.toString(36)}${randomBytes(3).toString("hex")}`;
3511
+ }
3512
+ function runtimeValue(values, name) {
3513
+ if (values.has(name)) return values.get(name);
3514
+ if (name === "unique") {
3515
+ const value = makeUnique();
3516
+ values.set(name, value);
3517
+ return value;
3518
+ }
3519
+ throw new Error(`Runtime value "${name}" has not been captured yet`);
3520
+ }
3508
3521
  function withRuntimeValues(step, values) {
3509
- const expand = (text) => text.replace(/\{\{([a-zA-Z][a-zA-Z0-9_]*)\}\}/g, (_, name) => {
3510
- if (!values.has(name)) throw new Error(`Runtime value "${name}" has not been captured yet`);
3511
- return values.get(name);
3512
- });
3522
+ const expand = (text) => text.replace(/\{\{([a-zA-Z][a-zA-Z0-9_]*)\}\}/g, (_, name) => runtimeValue(values, name));
3513
3523
  return {
3514
3524
  ...step,
3515
3525
  value: step.secret ? step.value : expand(step.value),
@@ -3525,10 +3535,8 @@ async function performHelperStep(page, step, options) {
3525
3535
  if (!options.runHelper) {
3526
3536
  throw new Error("helpers run only on runs started from the dashboard \u2014 this machine was not sent any");
3527
3537
  }
3528
- const inputs = Object.fromEntries(Object.entries(helper.inputs ?? {}).map(([name, text]) => [name, text.replace(NAME, (_, used) => {
3529
- if (!options.values.has(used)) throw new Error(`Runtime value "${used}" has not been captured yet`);
3530
- return options.values.get(used);
3531
- })]));
3538
+ const inputs = Object.fromEntries(Object.entries(helper.inputs ?? {}).map(([name, text]) => [name, text.replace(NAME, (_, used) => runtimeValue(options.values, used))]));
3539
+ inputs["unique"] ??= runtimeValue(options.values, "unique");
3532
3540
  const got = await options.runHelper(helper.helperId, inputs);
3533
3541
  if (got.value.length > 16384) throw new Error("The helper's value is over 16 KB");
3534
3542
  options.values.set(helper.saveAs, got.value);
@@ -3561,7 +3569,7 @@ function authenticationResolver(input) {
3561
3569
  return matches[0];
3562
3570
  };
3563
3571
  }
3564
- var PEPPER = randomBytes(32);
3572
+ var PEPPER = randomBytes2(32);
3565
3573
  function preparationKey(identity) {
3566
3574
  const material = JSON.stringify([
3567
3575
  identity.scope,
@@ -11210,6 +11218,7 @@ export {
11210
11218
  resolveService,
11211
11219
  connect,
11212
11220
  RecordedStepSchema,
11221
+ runtimeValue,
11213
11222
  authenticationResolver,
11214
11223
  checkAssertion,
11215
11224
  openRunSession,
package/dist/cli.js CHANGED
@@ -16,9 +16,10 @@ import {
16
16
  replayFlow,
17
17
  resolveCheckouts,
18
18
  resolveService,
19
+ runtimeValue,
19
20
  start,
20
21
  status
21
- } from "./chunk-JYXRKBN5.js";
22
+ } from "./chunk-XSH3IU5Y.js";
22
23
 
23
24
  // src/cli.ts
24
25
  import { parseArgs } from "util";
@@ -340,8 +341,10 @@ ${await this.snapshot()}`;
340
341
  ...input.op && input.op !== "equals" ? { op: input.op } : {},
341
342
  ...input.role ? { target: { role: input.role, name: input.name ?? "", ...scopeOf(input.within) } } : {}
342
343
  });
344
+ const filled = (text2) => text2.replace(/\{\{([a-zA-Z][a-zA-Z0-9_]*)\}\}/g, (_, name) => runtimeValue(this.values, name));
345
+ const expected = Array.isArray(assertion.value) ? assertion.value.map(filled) : filled(assertion.value);
343
346
  try {
344
- await checkAssertion(page, assertion.kind, assertion.value, 5e3, assertion);
347
+ await checkAssertion(page, assertion.kind, expected, 5e3, { ...assertion, value: expected });
345
348
  } catch (error) {
346
349
  throw new Error(`That is not true of the page right now, so it was not kept: ${error.message.split("\n")[0]}`);
347
350
  }
@@ -499,8 +502,11 @@ How to write a good Flowriki test:
499
502
  step fails there, fix it (remove_step, act again) and replay again.
500
503
  8. Save with save_flow and give the person the review link it returns.
501
504
  Test data you invent (a new user's email or password for a sign-up) is fine to
502
- type; prefer an address the project's mailbox helper can read, such as
503
- qa+something@ the mailbox's own domain.`;
505
+ type. For anything that must be NEW on every run \u2014 a sign-up's email or
506
+ username \u2014 use {{unique}}: it is different on every run and the same within
507
+ one, e.g. qa+{{unique}}@ the domain of the project's mailbox helper, so the
508
+ helper can read that address's verification email with {"email": "qa+{{unique}}@\u2026"}.
509
+ A test that types a fixed new email passes once and fails every run after.`;
504
510
  var text = (value, isError = false) => ({ content: [{ type: "text", text: value }], ...isError ? { isError } : {} });
505
511
  var str = (value) => typeof value === "string" ? value : value === void 0 || value === null ? void 0 : String(value);
506
512
  function authoringTools(service, session) {
package/dist/engine.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  resolveCheckouts,
10
10
  start,
11
11
  status
12
- } from "./chunk-JYXRKBN5.js";
12
+ } from "./chunk-XSH3IU5Y.js";
13
13
  export {
14
14
  AGENT_VERSION,
15
15
  browsersReady,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowriki/agent",
3
- "version": "0.1.0-beta.30",
3
+ "version": "0.1.0-beta.31",
4
4
  "description": "Run Flowriki UI tests on your own computer. Connects this machine to your Flowriki account.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",