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

Fix e2e tests & playwright comment job (#2392)

#skip-bb <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2392"> <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 Fixes failing Next.js e2e tests by selecting the correct chat mode and restarting after upgrades, and improves the Playwright PR comment with clearer run/update commands. Also increases local test timeout to reduce flaky failures. - **Bug Fixes** - Selects “build” chat mode in Next.js tests. - Adds restart after upgrade in select component test. - Updates snapshot to expect the “next” template ID. - Raises local timeout to 75s to reduce flakes. - **New Features** - Playwright PR comment now includes copy-paste commands to run and update snapshots for each failed test. - Uses -g "pattern" with proper escaping; groups many commands in a collapsible section. <sup>Written for commit 5124cf2f3e8aa80e9de63b412ff0b6aeeff81eb5. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->
上级 19ce70cd
...@@ -124,6 +124,7 @@ testSkipIfWindows("upgrade app to select component", async ({ po }) => { ...@@ -124,6 +124,7 @@ testSkipIfWindows("upgrade app to select component", async ({ po }) => {
await po.clickOpenInChatButton(); await po.clickOpenInChatButton();
// There should be another version from the upgrade being committed. // There should be another version from the upgrade being committed.
await expect(po.page.getByText("Version 2")).toBeVisible(); await expect(po.page.getByText("Version 2")).toBeVisible();
await po.clickRestart();
await po.clickPreviewPickElement(); await po.clickPreviewPickElement();
...@@ -141,7 +142,7 @@ testSkipIfWindows("select component next.js", async ({ po }) => { ...@@ -141,7 +142,7 @@ testSkipIfWindows("select component next.js", async ({ po }) => {
await po.setUp(); await po.setUp();
await po.goToHubAndSelectTemplate("Next.js Template"); await po.goToHubAndSelectTemplate("Next.js Template");
await po.selectChatMode("build");
await po.sendPrompt("tc=basic"); await po.sendPrompt("tc=basic");
await po.clickTogglePreviewPanel(); await po.clickTogglePreviewPanel();
await po.clickPreviewPickElement(); await po.clickPreviewPickElement();
......
- "selectedChatMode": "build"
+ "selectedChatMode": "local-agent"
- "selectedTemplateId": "react" - "selectedTemplateId": "react"
+ "selectedTemplateId": "next" + "selectedTemplateId": "next"
\ No newline at end of file
...@@ -5,6 +5,7 @@ test("create next.js app", async ({ po }) => { ...@@ -5,6 +5,7 @@ test("create next.js app", async ({ po }) => {
await po.setUp(); await po.setUp();
const beforeSettings = po.recordSettings(); const beforeSettings = po.recordSettings();
await po.goToHubAndSelectTemplate("Next.js Template"); await po.goToHubAndSelectTemplate("Next.js Template");
await po.selectChatMode("build");
po.snapshotSettingsDelta(beforeSettings); po.snapshotSettingsDelta(beforeSettings);
// Create an app // Create an app
......
...@@ -7,7 +7,7 @@ const config: PlaywrightTestConfig = { ...@@ -7,7 +7,7 @@ const config: PlaywrightTestConfig = {
testDir: "./e2e-tests", testDir: "./e2e-tests",
workers: 1, workers: 1,
retries: process.env.CI ? 2 : 0, retries: process.env.CI ? 2 : 0,
timeout: process.env.CI ? 180_000 : 45_000, timeout: process.env.CI ? 180_000 : 75_000,
// Use a custom snapshot path template because Playwright's default // Use a custom snapshot path template because Playwright's default
// is platform-specific which isn't necessary for Dyad e2e tests // is platform-specific which isn't necessary for Dyad e2e tests
// which should be platform agnostic (we don't do screenshots; only textual diffs). // which should be platform agnostic (we don't do screenshots; only textual diffs).
......
...@@ -70,12 +70,21 @@ function parseTestTitle(fullTitle) { ...@@ -70,12 +70,21 @@ function parseTestTitle(fullTitle) {
return { specFile, testName }; return { specFile, testName };
} }
// Generate copy-paste command for updating snapshots // Generate copy-paste command for running a specific test
function generateUpdateCommand(fullTitle) { function generateTestCommand(fullTitle) {
const { specFile, testName } = parseTestTitle(fullTitle); const { specFile, testName } = parseTestTitle(fullTitle);
// Escape special characters in testName for the grep pattern // Escape special characters in testName for the grep pattern
const escapedTestName = testName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); const escapedTestName = testName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
return `npm run e2e e2e-tests/${specFile} -- --g="${escapedTestName}" --update-snapshots`; return `npm run e2e e2e-tests/${specFile} -- -g "${escapedTestName}"`;
}
// Generate both run and update commands for a test
function generateCommands(fullTitle) {
const testCmd = generateTestCommand(fullTitle);
return {
run: testCmd,
update: `${testCmd} --update-snapshots`,
};
} }
function detectOperatingSystemsFromReport(report) { function detectOperatingSystemsFromReport(report) {
...@@ -369,22 +378,25 @@ async function run({ github, context, core }) { ...@@ -369,22 +378,25 @@ async function run({ github, context, core }) {
// Add macOS copy-paste commands section // Add macOS copy-paste commands section
const macOsFailures = resultsByOs["macOS"]?.failures || []; const macOsFailures = resultsByOs["macOS"]?.failures || [];
if (macOsFailures.length > 0) { if (macOsFailures.length > 0) {
comment += "### 📋 Update Snapshot Commands (macOS)\n\n"; comment += "### 📋 Test Commands (macOS)\n\n";
comment += comment +=
"Copy and paste these commands to update snapshots for failed tests:\n\n"; "Copy and paste these commands to run or update snapshots for failed tests:\n\n";
if (macOsFailures.length > 5) { if (macOsFailures.length > 5) {
comment += `<details>\n<summary>Show all ${macOsFailures.length} commands</summary>\n\n`; comment += `<details>\n<summary>Show all ${macOsFailures.length} test commands</summary>\n\n`;
} }
comment += "```bash\n";
for (const f of macOsFailures) { for (const f of macOsFailures) {
comment += generateUpdateCommand(f.title) + "\n"; const cmds = generateCommands(f.title);
comment += `**\`${f.title}\`**\n`;
comment += "```bash\n";
comment += `# Run test\n${cmds.run}\n\n`;
comment += `# Update snapshots\n${cmds.update}\n`;
comment += "```\n\n";
} }
comment += "```\n";
if (macOsFailures.length > 5) { if (macOsFailures.length > 5) {
comment += "\n</details>\n"; comment += "</details>\n";
} }
comment += "\n"; comment += "\n";
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论