Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: shorten path to socket (#38940)
Pavel Feldman7d1680149eb3
diff --git a/packages/playwright/src/mcp/terminal/helpGenerator.ts b/packages/playwright/src/mcp/terminal/helpGenerator.tsindex a3b5bd6de3..59ad7934ee 100644--- a/packages/playwright/src/mcp/terminal/helpGenerator.ts+++ b/packages/playwright/src/mcp/terminal/helpGenerator.ts@@ -80,6 +80,7 @@ const categories: { name: Category, title: string }[] = [function generateHelp() {const lines: string[] = [];lines.push('Usage: playwright-cli <command> [args] [options]');+const commandsByCategory = new Map<string, AnyCommandSchema[]>();for (const c of categories)commandsByCategory.set(c.name, []);@@ -97,6 +98,30 @@ function generateHelp() {return lines.join('\n');}++function generateReadme() {+ const lines: string[] = [];+ lines.push('\n## Commands');++ const commandsByCategory = new Map<string, AnyCommandSchema[]>();+ for (const c of categories)+ commandsByCategory.set(c.name, []);+ for (const command of Object.values(commands))+ commandsByCategory.get(command.category)!.push(command);++ for (const c of categories) {+ const cc = commandsByCategory.get(c.name)!;+ if (!cc.length)+ continue;+ lines.push(`\n### ${c.title}\n`);+ lines.push('```bash');+ for (const command of cc)+ lines.push(generateReadmeEntry(command));+ lines.push('```');+ }+ return lines.join('\n');+}+function generateHelpEntry(command: AnyCommandSchema): string {const args = commandArgs(command);const prefix = ` ${command.name} ${commandArgsText(args)}`;@@ -104,6 +129,13 @@ function generateHelpEntry(command: AnyCommandSchema): string {return formatWithGap(prefix, suffix);}+function generateReadmeEntry(command: AnyCommandSchema): string {+ const args = commandArgs(command);+ const prefix = `playwright-cli ${command.name} ${commandArgsText(args)}`;+ const suffix = '# ' + command.description.toLowerCase();+ return formatWithGap(prefix, suffix, 40);+}+async function main() {const help = {global: generateHelp(),@@ -111,16 +143,19 @@ async function main() {Object.entries(commands).map(([name, command]) => [name, generateCommandHelp(command)])),};+ const readme = generateReadme();const fileName = path.resolve(__dirname, 'help.json').replace('lib', 'src');// eslint-disable-next-line no-consoleconsole.log('Writing ', path.relative(process.cwd(), fileName));await fs.promises.writeFile(fileName, JSON.stringify(help, null, 2));// eslint-disable-next-line no-consoleconsole.log(help.global);+ // eslint-disable-next-line no-console+ console.log(readme);}-function formatWithGap(prefix: string, text: string) {- const indent = Math.max(1, 30 - prefix.length);+function formatWithGap(prefix: string, text: string, threshold: number = 30) {+ const indent = Math.max(1, threshold - prefix.length);return prefix + ' '.repeat(indent) + text;}diff --git a/packages/playwright/src/mcp/terminal/program.ts b/packages/playwright/src/mcp/terminal/program.tsindex 5a8a74c81c..af8a248285 100644--- a/packages/playwright/src/mcp/terminal/program.ts+++ b/packages/playwright/src/mcp/terminal/program.ts@@ -291,7 +291,7 @@ async function handleSessionCommand(sessionManager: SessionManager, args: any):const socketDirHash = (() => {const hash = crypto.createHash('sha1');hash.update(require.resolve('../../../package.json'));- return hash.digest('hex');+ return hash.digest('hex').substring(0, 16);})();const daemonSocketDir = (() => {@@ -304,7 +304,7 @@ const daemonSocketDir = (() => {localCacheDir = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');if (!localCacheDir)throw new Error('Unsupported platform: ' + process.platform);- return path.join(localCacheDir, 'ms-playwright', 'daemon', 'daemon', socketDirHash);+ return path.join(localCacheDir, 'ms-playwright', 'daemon', socketDirHash);})();function spawnDaemon(socketPath: string, userDataDir: string, options: SpawnOptions) {