Skip to content

Commit de5c32c

Browse files
thymikeeclaude
andcommitted
test(help): accept escaped quotes in a find ... exists query
Address review: the canonical plan keeps escaped quotes, and the double-quoted query pattern stopped at the first one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4c7a756 commit de5c32c

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎scripts/__tests__/help-conformance-expectation-fixtures.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ export const EXPECTATION_FIXTURES: Record<string, ExpectationFixture> = {
166166
{ id: 'existsInFindQuery', commands: ['agent-device find text "Sent exists"'] },
167167
{ id: 'findFillsExists', commands: ['agent-device find text Sent fill exists'] },
168168
],
169-
metamorphic: { commands: ['agent-device find text "Welcome back" exists'] },
169+
// An escaped quote inside the query still reads as one query.
170+
metamorphic: { commands: [String.raw`agent-device find text "Welcome \"back\"" exists`] },
170171
},
171172
usesDogfoodEvidence: {
172173
passing: {

‎scripts/help-conformance-expectations.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ function isPnpmScript(command, script) {
2626
*/
2727
export function findExistsSource(subject = '') {
2828
const unquoted = subject ? String.raw`[^\s"']*${subject}[^\s"']*` : String.raw`[^\s"']+`;
29-
return String.raw`\bfind\s+(?:(?:text|label|value|role|id)\s+)?(?:"[^"\n]*${subject}[^"\n]*"|'[^'\n]*${subject}[^'\n]*'|${unquoted})\s+exists(?:\s|$)`;
29+
// A double-quoted query may hold escaped quotes, as the plan canonicalizer emits them.
30+
const doubleQuoted = String.raw`"(?:[^"\\\n]|\\.)*${subject}(?:[^"\\\n]|\\.)*"`;
31+
return String.raw`\bfind\s+(?:(?:text|label|value|role|id)\s+)?(?:${doubleQuoted}|'[^'\n]*${subject}[^'\n]*'|${unquoted})\s+exists(?:\s|$)`;
3032
}

0 commit comments

Comments
 (0)