@cutleryapp/agent 1.0.10 → 1.0.12

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.
@@ -92,26 +92,22 @@ class TestExecutor {
92
92
  }
93
93
  }
94
94
  else if (lower.includes("fill") || lower.includes("type") || lower.includes("enter")) {
95
- const quoted = raw.match(/(?:enter|fill|type)\s+"([^"]+)"\s+(?:in|into)\s+(?:the\s+)?(?:"([^"]+)"|(\w[\w\s]*?)\s*(?:field|input|box|area)?)\s*$/i);
96
- if (quoted) {
97
- const value = quoted[1];
98
- const quotedTarget = quoted[2];
99
- const bareLabel = quoted[3];
100
- // A token in quotes is usually a human-readable label
101
- // (e.g. `Fill "standard_user" in "Username"`), not a CSS
102
- // selector. Only treat it as a CSS selector when it actually
103
- // looks like one — otherwise resolve via tryFill so the
104
- // label can match placeholder/aria/data-test/label etc.
95
+ // Support both quoted and unquoted formats:
96
+ // Fill "standard_user" in "Username"
97
+ // Fill standard_user in Username field
98
+ // Split on first " in " / " into " to separate value from field
99
+ const match = raw.match(/(?:enter|fill|type)\s+"([^"]+)"\s+(?:in|into)\s+(?:the\s+)?"?([^"]+?)"?\s*(?:field|input|box|area)?\s*$/i) ||
100
+ raw.match(/(?:enter|fill|type)\s+(\S+)\s+(?:in|into)\s+(?:the\s+)?(.+?)\s*(?:field|input|box|area)?\s*$/i);
101
+ if (match) {
102
+ const value = match[1].trim();
103
+ const fieldLabel = match[2].trim();
105
104
  const looksLikeCss = (s) => /[#.\[\]:>]/.test(s);
106
- if (quotedTarget && looksLikeCss(quotedTarget)) {
107
- await page.waitForSelector(quotedTarget, { state: "visible", timeout: 5000 });
108
- await page.fill(quotedTarget, value);
105
+ if (looksLikeCss(fieldLabel)) {
106
+ await page.waitForSelector(fieldLabel, { state: "visible", timeout: 5000 });
107
+ await page.fill(fieldLabel, value);
109
108
  }
110
- else if (quotedTarget) {
111
- await tryFill(page, quotedTarget.trim(), value);
112
- }
113
- else if (bareLabel) {
114
- await tryFill(page, bareLabel.trim(), value);
109
+ else {
110
+ await tryFill(page, fieldLabel, value);
115
111
  }
116
112
  }
117
113
  }
@@ -223,11 +219,12 @@ async function tryClick(page, nameRe, label) {
223
219
  }
224
220
  async function tryClickScoped(page, nameRe, target, scope) {
225
221
  const FAST = 3000;
226
- // Find a container that contains the scope text, then click the target inside it
222
+ // Strip trailing generic nouns that won't appear verbatim on the page
223
+ const cleanScope = scope.replace(/\s+(?:product|item|section|card|row|container|element|button|link|area|panel|block)$/i, '').trim();
227
224
  const strategies = [
228
- () => page.locator(`:has-text("${scope}")`).last().getByRole('button', { name: nameRe }).first().click({ timeout: FAST }),
229
- () => page.locator(`:has-text("${scope}")`).last().getByRole('link', { name: nameRe }).first().click({ timeout: FAST }),
230
- () => page.locator(`:has-text("${scope}")`).last().getByText(nameRe).first().click({ timeout: FAST }),
225
+ () => page.locator(`:has-text("${cleanScope}")`).last().getByRole('button', { name: nameRe }).first().click({ timeout: FAST }),
226
+ () => page.locator(`:has-text("${cleanScope}")`).last().getByRole('link', { name: nameRe }).first().click({ timeout: FAST }),
227
+ () => page.locator(`:has-text("${cleanScope}")`).last().getByText(nameRe).first().click({ timeout: FAST }),
231
228
  // Fallback: ignore scope and click anywhere
232
229
  () => page.getByRole('button', { name: nameRe }).first().click({ timeout: FAST }),
233
230
  () => page.getByText(nameRe).first().click({ timeout: FAST }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cutleryapp/agent",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Local agent that connects your machine to the Cutlery QA platform and runs UI tests via Playwright",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {