fix: resolve 3 protocol bugs, improve CLI and snapshot code quality (#487)
## Summary - Fix `allowFileAccess` being silently stripped from launch commands by adding it to the Zod schema in `protocol.ts` (the `--allow-file-access` CLI flag was not reaching the browser) - Fix `trace stop` requiring a path argument despite help text documenting it as optional -- now works with or without a path - Fix `addscript`/`addstyle` silently succeeding when neither `content` nor `url` is provided -- now returns a validation error - Replace hardcoded ANSI escape code with `color::error_indicator()` in `main.rs` to respect `NO_COLOR` - Fix double-parse pattern and add descriptive expect messages in `commands.rs` - Fix incomplete string escaping in `snapshot.ts` `buildSelector` (use `JSON.stringify` instead of manual quote escaping) - Simplify redundant ternary in `snapshot.ts` cursor-interactive role assignment - Sync docs changelog with CHANGELOG.md (v0.8.1 through v0.10.0)
This commit is contained in:
+3
-3
@@ -132,8 +132,8 @@ const STRUCTURAL_ROLES = new Set([
|
||||
*/
|
||||
function buildSelector(role: string, name?: string): string {
|
||||
if (name) {
|
||||
const escapedName = name.replace(/"/g, '\\"');
|
||||
return `getByRole('${role}', { name: "${escapedName}", exact: true })`;
|
||||
const escapedName = JSON.stringify(name);
|
||||
return `getByRole('${role}', { name: ${escapedName}, exact: true })`;
|
||||
}
|
||||
return `getByRole('${role}')`;
|
||||
}
|
||||
@@ -307,7 +307,7 @@ export async function getEnhancedSnapshot(
|
||||
existingTexts.add(elTextLower);
|
||||
|
||||
const ref = nextRef();
|
||||
const role = el.hasCursorPointer ? 'clickable' : el.hasOnClick ? 'clickable' : 'focusable';
|
||||
const role = el.hasCursorPointer || el.hasOnClick ? 'clickable' : 'focusable';
|
||||
|
||||
refs[ref] = {
|
||||
selector: el.selector,
|
||||
|
||||
Reference in New Issue
Block a user