@muuktest/amikoo-playwright 2.0.0

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.
Files changed (70) hide show
  1. package/README.md +26 -0
  2. package/dist/capture.cjs +57 -0
  3. package/dist/capture.cjs.map +1 -0
  4. package/dist/capture.d.cts +6 -0
  5. package/dist/capture.d.ts +6 -0
  6. package/dist/capture.js +23 -0
  7. package/dist/capture.js.map +1 -0
  8. package/dist/cli/agent-setup.cjs +68 -0
  9. package/dist/cli/agent-setup.cjs.map +1 -0
  10. package/dist/cli/agent-setup.d.cts +11 -0
  11. package/dist/cli/agent-setup.d.ts +11 -0
  12. package/dist/cli/agent-setup.js +31 -0
  13. package/dist/cli/agent-setup.js.map +1 -0
  14. package/dist/cli/amikoo-playwright-agent.md +82 -0
  15. package/dist/cli/fixture-creator.cjs +163 -0
  16. package/dist/cli/fixture-creator.cjs.map +1 -0
  17. package/dist/cli/fixture-creator.d.cts +12 -0
  18. package/dist/cli/fixture-creator.d.ts +12 -0
  19. package/dist/cli/fixture-creator.js +128 -0
  20. package/dist/cli/fixture-creator.js.map +1 -0
  21. package/dist/cli/index.cjs +134 -0
  22. package/dist/cli/index.cjs.map +1 -0
  23. package/dist/cli/index.d.cts +1 -0
  24. package/dist/cli/index.d.ts +1 -0
  25. package/dist/cli/index.js +111 -0
  26. package/dist/cli/index.js.map +1 -0
  27. package/dist/cli/mcp-setup.cjs +116 -0
  28. package/dist/cli/mcp-setup.cjs.map +1 -0
  29. package/dist/cli/mcp-setup.d.cts +12 -0
  30. package/dist/cli/mcp-setup.d.ts +12 -0
  31. package/dist/cli/mcp-setup.js +81 -0
  32. package/dist/cli/mcp-setup.js.map +1 -0
  33. package/dist/cli/scanner.cjs +137 -0
  34. package/dist/cli/scanner.cjs.map +1 -0
  35. package/dist/cli/scanner.d.cts +16 -0
  36. package/dist/cli/scanner.d.ts +16 -0
  37. package/dist/cli/scanner.js +100 -0
  38. package/dist/cli/scanner.js.map +1 -0
  39. package/dist/cli/test-updater.cjs +131 -0
  40. package/dist/cli/test-updater.cjs.map +1 -0
  41. package/dist/cli/test-updater.d.cts +12 -0
  42. package/dist/cli/test-updater.d.ts +12 -0
  43. package/dist/cli/test-updater.js +96 -0
  44. package/dist/cli/test-updater.js.map +1 -0
  45. package/dist/dom/buildDomTree.js +1760 -0
  46. package/dist/helpers/dom-extractor.cjs +344 -0
  47. package/dist/helpers/dom-extractor.cjs.map +1 -0
  48. package/dist/helpers/dom-extractor.d.cts +9 -0
  49. package/dist/helpers/dom-extractor.d.ts +9 -0
  50. package/dist/helpers/dom-extractor.js +318 -0
  51. package/dist/helpers/dom-extractor.js.map +1 -0
  52. package/dist/helpers/dom-service.cjs +365 -0
  53. package/dist/helpers/dom-service.cjs.map +1 -0
  54. package/dist/helpers/dom-service.d.cts +82 -0
  55. package/dist/helpers/dom-service.d.ts +82 -0
  56. package/dist/helpers/dom-service.js +338 -0
  57. package/dist/helpers/dom-service.js.map +1 -0
  58. package/dist/helpers/failure-analyzer.cjs +276 -0
  59. package/dist/helpers/failure-analyzer.cjs.map +1 -0
  60. package/dist/helpers/failure-analyzer.d.cts +100 -0
  61. package/dist/helpers/failure-analyzer.d.ts +100 -0
  62. package/dist/helpers/failure-analyzer.js +241 -0
  63. package/dist/helpers/failure-analyzer.js.map +1 -0
  64. package/dist/index.cjs +32 -0
  65. package/dist/index.cjs.map +1 -0
  66. package/dist/index.d.cts +3 -0
  67. package/dist/index.d.ts +3 -0
  68. package/dist/index.js +7 -0
  69. package/dist/index.js.map +1 -0
  70. package/package.json +51 -0
@@ -0,0 +1,96 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { isESM } from "./scanner.js";
4
+ function toRelativePath(from, to) {
5
+ let rel = path.relative(path.dirname(from), to);
6
+ rel = rel.replace(/\.(ts|tsx)$/, "");
7
+ if (!rel.startsWith(".")) rel = "./" + rel;
8
+ return rel;
9
+ }
10
+ function updateTestImports(testFiles, fixturePath, projectRoot) {
11
+ const updated = [];
12
+ const skipped = [];
13
+ for (const testFile of testFiles) {
14
+ let content = fs.readFileSync(testFile, "utf8");
15
+ const relPath = toRelativePath(testFile, fixturePath);
16
+ if (content.includes(relPath)) {
17
+ skipped.push(testFile);
18
+ continue;
19
+ }
20
+ const esm = isESM(testFile, content, projectRoot);
21
+ let changed = false;
22
+ if (esm) {
23
+ const importRegex = /^import\s+\{([^}]+)\}\s+from\s+['"]@playwright\/test['"]/gm;
24
+ content = content.replace(importRegex, (match, imports) => {
25
+ if (/^import\s+type/.test(match)) return match;
26
+ const importList = imports.split(",").map((s) => s.trim()).filter(Boolean);
27
+ const hasTest = importList.some((i) => i === "test" || i.startsWith("test ") || i.includes(" as test"));
28
+ if (!hasTest) return match;
29
+ changed = true;
30
+ return `import { ${importList.join(", ")} } from '${relPath}'`;
31
+ });
32
+ } else {
33
+ const requireRegex = /const\s+\{([^}]+)\}\s*=\s*require\s*\(\s*['"]@playwright\/test['"]\s*\)/g;
34
+ content = content.replace(requireRegex, (match, imports) => {
35
+ const importList = imports.split(",").map((s) => s.trim()).filter(Boolean);
36
+ const hasTest = importList.some((i) => i === "test" || i.startsWith("test ") || i.includes(": test"));
37
+ if (!hasTest) return match;
38
+ changed = true;
39
+ return `const { ${importList.join(", ")} } = require('${relPath}')`;
40
+ });
41
+ }
42
+ if (changed) {
43
+ fs.writeFileSync(testFile, content, "utf8");
44
+ updated.push(testFile);
45
+ } else {
46
+ skipped.push(testFile);
47
+ }
48
+ }
49
+ return { updated, skipped };
50
+ }
51
+ function planTestImports(testFiles, fixturePath, projectRoot) {
52
+ const toUpdate = [];
53
+ const toSkip = [];
54
+ for (const testFile of testFiles) {
55
+ const content = fs.readFileSync(testFile, "utf8");
56
+ const relPath = toRelativePath(testFile, fixturePath);
57
+ if (content.includes(relPath)) {
58
+ toSkip.push(testFile);
59
+ continue;
60
+ }
61
+ const esm = isESM(testFile, content, projectRoot);
62
+ let wouldChange = false;
63
+ if (esm) {
64
+ const importRegex = /^import\s+\{([^}]+)\}\s+from\s+['"]@playwright\/test['"]/gm;
65
+ let m;
66
+ while ((m = importRegex.exec(content)) !== null) {
67
+ if (/^import\s+type/.test(m[0])) continue;
68
+ const importList = m[1].split(",").map((s) => s.trim()).filter(Boolean);
69
+ const hasTest = importList.some((i) => i === "test" || i.startsWith("test ") || i.includes(" as test"));
70
+ if (hasTest) {
71
+ wouldChange = true;
72
+ break;
73
+ }
74
+ }
75
+ } else {
76
+ const requireRegex = /const\s+\{([^}]+)\}\s*=\s*require\s*\(\s*['"]@playwright\/test['"]\s*\)/g;
77
+ let m;
78
+ while ((m = requireRegex.exec(content)) !== null) {
79
+ const importList = m[1].split(",").map((s) => s.trim()).filter(Boolean);
80
+ const hasTest = importList.some((i) => i === "test" || i.startsWith("test ") || i.includes(": test"));
81
+ if (hasTest) {
82
+ wouldChange = true;
83
+ break;
84
+ }
85
+ }
86
+ }
87
+ if (wouldChange) toUpdate.push(testFile);
88
+ else toSkip.push(testFile);
89
+ }
90
+ return { toUpdate, toSkip };
91
+ }
92
+ export {
93
+ planTestImports,
94
+ updateTestImports
95
+ };
96
+ //# sourceMappingURL=test-updater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cli/test-updater.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { isESM } from './scanner.js';\n\nexport interface UpdateResult {\n updated: string[];\n skipped: string[];\n}\n\nexport interface TestImportPlan {\n toUpdate: string[];\n toSkip: string[];\n}\n\nfunction toRelativePath(from: string, to: string): string {\n let rel = path.relative(path.dirname(from), to);\n // Remove extension for cleaner imports\n rel = rel.replace(/\\.(ts|tsx)$/, '');\n if (!rel.startsWith('.')) rel = './' + rel;\n return rel;\n}\n\nexport function updateTestImports(testFiles: string[], fixturePath: string, projectRoot: string): UpdateResult {\n const updated: string[] = [];\n const skipped: string[] = [];\n\n for (const testFile of testFiles) {\n let content = fs.readFileSync(testFile, 'utf8');\n const relPath = toRelativePath(testFile, fixturePath);\n\n // Skip if already importing from fixture path\n if (content.includes(relPath)) {\n skipped.push(testFile);\n continue;\n }\n\n const esm = isESM(testFile, content, projectRoot);\n let changed = false;\n\n if (esm) {\n // Replace: import { test[, expect] } from '@playwright/test'\n // but NOT import type lines, and NOT standalone expect-only imports\n const importRegex = /^import\\s+\\{([^}]+)\\}\\s+from\\s+['\"]@playwright\\/test['\"]/gm;\n content = content.replace(importRegex, (match, imports: string) => {\n // Skip `import type` — handled by checking what came before\n if (/^import\\s+type/.test(match)) return match;\n\n const importList = imports.split(',').map((s: string) => s.trim()).filter(Boolean);\n const hasTest = importList.some(i => i === 'test' || i.startsWith('test ') || i.includes(' as test'));\n if (!hasTest) return match; // leave standalone expect imports alone\n\n changed = true;\n return `import { ${importList.join(', ')} } from '${relPath}'`;\n });\n } else {\n // Replace: const { test[, expect] } = require('@playwright/test')\n const requireRegex = /const\\s+\\{([^}]+)\\}\\s*=\\s*require\\s*\\(\\s*['\"]@playwright\\/test['\"]\\s*\\)/g;\n content = content.replace(requireRegex, (match, imports: string) => {\n const importList = imports.split(',').map((s: string) => s.trim()).filter(Boolean);\n const hasTest = importList.some(i => i === 'test' || i.startsWith('test ') || i.includes(': test'));\n if (!hasTest) return match;\n\n changed = true;\n return `const { ${importList.join(', ')} } = require('${relPath}')`;\n });\n }\n\n if (changed) {\n fs.writeFileSync(testFile, content, 'utf8');\n updated.push(testFile);\n } else {\n skipped.push(testFile);\n }\n }\n\n return { updated, skipped };\n}\n\nexport function planTestImports(\n testFiles: string[],\n fixturePath: string,\n projectRoot: string\n): TestImportPlan {\n const toUpdate: string[] = [];\n const toSkip: string[] = [];\n\n for (const testFile of testFiles) {\n const content = fs.readFileSync(testFile, 'utf8');\n const relPath = toRelativePath(testFile, fixturePath);\n\n if (content.includes(relPath)) { toSkip.push(testFile); continue; }\n\n const esm = isESM(testFile, content, projectRoot);\n let wouldChange = false;\n\n if (esm) {\n const importRegex = /^import\\s+\\{([^}]+)\\}\\s+from\\s+['\"]@playwright\\/test['\"]/gm;\n let m;\n while ((m = importRegex.exec(content)) !== null) {\n if (/^import\\s+type/.test(m[0])) continue;\n const importList = m[1].split(',').map((s: string) => s.trim()).filter(Boolean);\n const hasTest = importList.some((i: string) => i === 'test' || i.startsWith('test ') || i.includes(' as test'));\n if (hasTest) { wouldChange = true; break; }\n }\n } else {\n const requireRegex = /const\\s+\\{([^}]+)\\}\\s*=\\s*require\\s*\\(\\s*['\"]@playwright\\/test['\"]\\s*\\)/g;\n let m;\n while ((m = requireRegex.exec(content)) !== null) {\n const importList = m[1].split(',').map((s: string) => s.trim()).filter(Boolean);\n const hasTest = importList.some((i: string) => i === 'test' || i.startsWith('test ') || i.includes(': test'));\n if (hasTest) { wouldChange = true; break; }\n }\n }\n\n if (wouldChange) toUpdate.push(testFile);\n else toSkip.push(testFile);\n }\n\n return { toUpdate, toSkip };\n}\n"],"mappings":"AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,aAAa;AAYtB,SAAS,eAAe,MAAc,IAAoB;AACxD,MAAI,MAAM,KAAK,SAAS,KAAK,QAAQ,IAAI,GAAG,EAAE;AAE9C,QAAM,IAAI,QAAQ,eAAe,EAAE;AACnC,MAAI,CAAC,IAAI,WAAW,GAAG,EAAG,OAAM,OAAO;AACvC,SAAO;AACT;AAEO,SAAS,kBAAkB,WAAqB,aAAqB,aAAmC;AAC7G,QAAM,UAAoB,CAAC;AAC3B,QAAM,UAAoB,CAAC;AAE3B,aAAW,YAAY,WAAW;AAChC,QAAI,UAAU,GAAG,aAAa,UAAU,MAAM;AAC9C,UAAM,UAAU,eAAe,UAAU,WAAW;AAGpD,QAAI,QAAQ,SAAS,OAAO,GAAG;AAC7B,cAAQ,KAAK,QAAQ;AACrB;AAAA,IACF;AAEA,UAAM,MAAM,MAAM,UAAU,SAAS,WAAW;AAChD,QAAI,UAAU;AAEd,QAAI,KAAK;AAGP,YAAM,cAAc;AACpB,gBAAU,QAAQ,QAAQ,aAAa,CAAC,OAAO,YAAo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