@flowriki/agent 0.1.0-beta.21 → 0.1.0-beta.22

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.21";
9
+ var AGENT_VERSION = "0.1.0-beta.22";
10
10
  async function prepareBrowsers() {
11
11
  if (browsersReady()) {
12
12
  return { ok: true, already: true, message: "chromium is already installed" };
@@ -458,7 +458,7 @@ import path7 from "path";
458
458
  // ../engine-playwright/dist/index.js
459
459
  import path3 from "path";
460
460
 
461
- // ../test-model/dist/chunk-RQ5E3H3R.js
461
+ // ../test-model/dist/chunk-X4X4KGMA.js
462
462
  import { z as z3 } from "zod";
463
463
  var LocatorOverrideSchema = z3.object({
464
464
  strategy: z3.enum(["css", "xpath", "id", "testId", "text", "label", "placeholder", "altText", "title"]),
@@ -542,11 +542,13 @@ var RecordedTargetSchema = z3.object({
542
542
  * find its element has none — although the field is sitting in plain sight
543
543
  * and two other things about it are unchanged.
544
544
  *
545
- * Tried in order, and ONLY where the one before found nothing. Two matches
546
- * is a question the test has to answer, never one to guess at, so ambiguity
547
- * stops the walk rather than passing it along. A step that resolves by
548
- * anything other than its first choice says so in the result — a repair
549
- * nobody can see is a repair nobody can trust. */
545
+ * Tried in order, and ONLY where the one before did not identify a single
546
+ * element. EXACTLY ONE MATCH WINS: a locator matching several is
547
+ * disqualified rather than obeyed, so choosing between two elements never
548
+ * happens — and where nothing identifies one, the run stops and names the
549
+ * ambiguity. A step that resolves by anything other than its first choice
550
+ * says so in the result: a repair nobody can see is a repair nobody can
551
+ * trust. */
550
552
  candidates: z3.array(LocatorOverrideSchema).max(4).optional(),
551
553
  nth: z3.number().int().nonnegative().optional()
552
554
  });
@@ -4814,25 +4816,27 @@ async function ensureTarget(page, step, timeout) {
4814
4816
  const primary = candidates[0];
4815
4817
  const firstWait = Math.max(500, Math.floor(timeout * 0.45));
4816
4818
  const recovery = Math.max(1e3, Math.floor(timeout * 0.35));
4819
+ let several = null;
4817
4820
  try {
4818
4821
  await primary.waitFor({ state: "attached", timeout: firstWait });
4819
4822
  return { loc: primary };
4820
4823
  } catch (error) {
4821
- if (/strict mode violation/.test(String(error))) {
4822
- throw Object.assign(error, { kind: "ambiguous" });
4823
- }
4824
+ if (/strict mode violation/.test(String(error))) several = error;
4824
4825
  }
4826
+ let crowded = null;
4825
4827
  for (let at = 1; at < candidates.length; at += 1) {
4826
4828
  const found = await candidates[at].count().catch(() => 0);
4827
4829
  if (found === 1) return { loc: candidates[at], foundBy: described[at] ?? "another locator" };
4828
- if (found > 1) {
4829
- throw Object.assign(
4830
- new Error(
4831
- `"${step.name}" could not be found the way this step records it, and ${found} elements match ${described[at]} \u2014 narrow it in the editor`
4832
- ),
4833
- { kind: "ambiguous" }
4834
- );
4835
- }
4830
+ if (found > 1 && !crowded) crowded = { where: described[at] ?? "another locator", count: found };
4831
+ }
4832
+ if (several) throw Object.assign(several, { kind: "ambiguous" });
4833
+ if (crowded) {
4834
+ throw Object.assign(
4835
+ new Error(
4836
+ `"${step.name}" could not be found the way this step records it, and ${crowded.count} elements match ${crowded.where} \u2014 nothing this step knows tells them apart, so narrow it in the editor`
4837
+ ),
4838
+ { kind: "ambiguous" }
4839
+ );
4836
4840
  }
4837
4841
  if (await scrollUntilFound(page, primary, recovery)) return { loc: primary };
4838
4842
  throw Object.assign(
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  resolveCheckouts,
9
9
  start,
10
10
  status
11
- } from "./chunk-U3QYIAXF.js";
11
+ } from "./chunk-O3S4QSN4.js";
12
12
 
13
13
  // src/cli.ts
14
14
  import { parseArgs } from "util";
package/dist/engine.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  resolveCheckouts,
10
10
  start,
11
11
  status
12
- } from "./chunk-U3QYIAXF.js";
12
+ } from "./chunk-O3S4QSN4.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.21",
3
+ "version": "0.1.0-beta.22",
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",