Unverified 提交 4aa7a011 authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

Simplify Playwright summary to single re-run command (#2605)

## Summary - Replace per-test `npm run e2e` commands in the Playwright PR comment with a single combined command listing all unique failing spec files - Remove unused `isSnapshotFailure` and `generateTestCommand` helper functions - Makes it easier to copy-paste and re-run all failures at once ## Test plan - Verify the generated PR comment format by inspecting the next CI run with test failures - The command section should show a single `npm run e2e` with backslash-joined spec file paths 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2605" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Simplified the Playwright PR comment to a single copy-paste command that re-runs all failing spec files at once. This reduces noise and speeds up local reproduction. - **Refactors** - Generate one command using backslash-joined unique failing spec paths; sanitize file paths. - Remove isSnapshotFailure and generateTestCommand; drop snapshot flags and error previews from the comment. <sup>Written for commit 9e24baa4782ab82cb93b7cbf3fa579063e269b51. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Only changes CI comment output formatting/commands and removes unused helpers; no impact to test execution itself, but could slightly affect how developers re-run failures locally. > > **Overview** > Simplifies the Playwright PR comment’s macOS re-run section to output a **single** `npm run e2e` command listing all *unique failing spec files*, instead of generating per-test `-g` commands. > > Removes the snapshot-detection and per-test command helpers (`isSnapshotFailure`, `generateTestCommand`), dropping `--update-snapshots` suggestions and reducing comment noise. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 9e24baa4782ab82cb93b7cbf3fa579063e269b51. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
上级 05e5403f
...@@ -70,34 +70,6 @@ function parseTestTitle(fullTitle) { ...@@ -70,34 +70,6 @@ function parseTestTitle(fullTitle) {
return { specFile, testName }; return { specFile, testName };
} }
// Detect if a test failure is due to a snapshot mismatch
function isSnapshotFailure(errorMessage) {
if (!errorMessage) return false;
const lower = errorMessage.toLowerCase();
return [
"screenshot comparison failed",
"snapshot comparison failed",
"expected to match snapshot",
"tomatchsnapshot",
"tohavescreenshot",
"screenshots are different",
"snapshots don't match",
"snapshot mismatch",
"snapshot",
"ratio of different pixels",
].some((pattern) => lower.includes(pattern));
}
// Generate copy-paste command for running a specific test
function generateTestCommand(fullTitle) {
const { specFile, testName } = parseTestTitle(fullTitle);
// Sanitize specFile to only allow safe path characters
const safeSpecFile = specFile.replace(/[^a-zA-Z0-9._\-/]/g, "");
// Escape special characters in testName for the grep pattern
const escapedTestName = testName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
return `npm run e2e e2e-tests/${safeSpecFile} -- -g "${escapedTestName}"`;
}
function detectOperatingSystemsFromReport(report) { function detectOperatingSystemsFromReport(report) {
const detected = new Set(); const detected = new Set();
...@@ -386,37 +358,26 @@ async function run({ github, context, core }) { ...@@ -386,37 +358,26 @@ async function run({ github, context, core }) {
comment += "\n"; comment += "\n";
} }
// Add macOS copy-paste commands section // Add macOS copy-paste command section
const macOsFailures = resultsByOs["macOS"]?.failures || []; const macOsFailures = resultsByOs["macOS"]?.failures || [];
if (macOsFailures.length > 0) { if (macOsFailures.length > 0) {
comment += "### 📋 Test Commands (macOS)\n\n"; comment += "### 📋 Re-run Failing Tests (macOS)\n\n";
comment += "Copy and paste to re-run failing tests locally:\n\n"; comment += "Copy and paste to re-run all failing spec files locally:\n\n";
if (macOsFailures.length > 5) { // Collect unique spec files from failures
comment += `<details>\n<summary>Show all ${macOsFailures.length} test commands</summary>\n\n`; const specFiles = [
} ...new Set(
macOsFailures.map((f) => {
const { specFile } = parseTestTitle(f.title);
return `e2e-tests/${specFile.replace(/[^a-zA-Z0-9._\-/]/g, "")}`;
}),
),
];
comment += "```bash\n"; comment += "```bash\n";
comment += "export PLAYWRIGHT_HTML_OPEN=never\n"; comment += "npm run e2e \\\n";
for (const f of macOsFailures) { comment += specFiles.map((s) => ` ${s}`).join(" \\\n");
const cmd = generateTestCommand(f.title); comment += "\n```\n\n";
const snapshot = isSnapshotFailure(f.error);
const errorPreview =
f.error.length > 120 ? f.error.substring(0, 120) + "..." : f.error;
comment += `\n# ${f.title.replace(/\n/g, " ").replace(/`/g, "'")}\n`;
comment += `# Expected: ${errorPreview.replace(/\n/g, " ").replace(/`/g, "'")}\n`;
if (snapshot) {
comment += `${cmd} --update-snapshots\n`;
} else {
comment += `${cmd}\n`;
}
}
comment += "```\n\n";
if (macOsFailures.length > 5) {
comment += "</details>\n";
}
comment += "\n";
} }
// List flaky tests // List flaky tests
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论