Skip to content

Commit eb909bb

Browse files
authored
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 5124cf2. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->
1 parent 19ce70c commit eb909bb

5 files changed

Lines changed: 26 additions & 14 deletions

e2e-tests/select_component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ testSkipIfWindows("upgrade app to select component", async ({ po }) => {
124124
await po.clickOpenInChatButton();
125125
// There should be another version from the upgrade being committed.
126126
await expect(po.page.getByText("Version 2")).toBeVisible();
127+
await po.clickRestart();
127128

128129
await po.clickPreviewPickElement();
129130

@@ -141,7 +142,7 @@ testSkipIfWindows("select component next.js", async ({ po }) => {
141142
await po.setUp();
142143

143144
await po.goToHubAndSelectTemplate("Next.js Template");
144-
145+
await po.selectChatMode("build");
145146
await po.sendPrompt("tc=basic");
146147
await po.clickTogglePreviewPanel();
147148
await po.clickPreviewPickElement();
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
- "selectedChatMode": "build"
2-
+ "selectedChatMode": "local-agent"
31
- "selectedTemplateId": "react"
42
+ "selectedTemplateId": "next"

e2e-tests/template-create-nextjs.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test("create next.js app", async ({ po }) => {
55
await po.setUp();
66
const beforeSettings = po.recordSettings();
77
await po.goToHubAndSelectTemplate("Next.js Template");
8+
await po.selectChatMode("build");
89
po.snapshotSettingsDelta(beforeSettings);
910

1011
// Create an app

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const config: PlaywrightTestConfig = {
77
testDir: "./e2e-tests",
88
workers: 1,
99
retries: process.env.CI ? 2 : 0,
10-
timeout: process.env.CI ? 180_000 : 45_000,
10+
timeout: process.env.CI ? 180_000 : 75_000,
1111
// Use a custom snapshot path template because Playwright's default
1212
// is platform-specific which isn't necessary for Dyad e2e tests
1313
// which should be platform agnostic (we don't do screenshots; only textual diffs).

scripts/generate-playwright-summary.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,21 @@ function parseTestTitle(fullTitle) {
7070
return { specFile, testName };
7171
}
7272

73-
// Generate copy-paste command for updating snapshots
74-
function generateUpdateCommand(fullTitle) {
73+
// Generate copy-paste command for running a specific test
74+
function generateTestCommand(fullTitle) {
7575
const { specFile, testName } = parseTestTitle(fullTitle);
7676
// Escape special characters in testName for the grep pattern
7777
const escapedTestName = testName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
78-
return `npm run e2e e2e-tests/${specFile} -- --g="${escapedTestName}" --update-snapshots`;
78+
return `npm run e2e e2e-tests/${specFile} -- -g "${escapedTestName}"`;
79+
}
80+
81+
// Generate both run and update commands for a test
82+
function generateCommands(fullTitle) {
83+
const testCmd = generateTestCommand(fullTitle);
84+
return {
85+
run: testCmd,
86+
update: `${testCmd} --update-snapshots`,
87+
};
7988
}
8089

8190
function detectOperatingSystemsFromReport(report) {
@@ -369,22 +378,25 @@ async function run({ github, context, core }) {
369378
// Add macOS copy-paste commands section
370379
const macOsFailures = resultsByOs["macOS"]?.failures || [];
371380
if (macOsFailures.length > 0) {
372-
comment += "### 📋 Update Snapshot Commands (macOS)\n\n";
381+
comment += "### 📋 Test Commands (macOS)\n\n";
373382
comment +=
374-
"Copy and paste these commands to update snapshots for failed tests:\n\n";
383+
"Copy and paste these commands to run or update snapshots for failed tests:\n\n";
375384

376385
if (macOsFailures.length > 5) {
377-
comment += `<details>\n<summary>Show all ${macOsFailures.length} commands</summary>\n\n`;
386+
comment += `<details>\n<summary>Show all ${macOsFailures.length} test commands</summary>\n\n`;
378387
}
379388

380-
comment += "```bash\n";
381389
for (const f of macOsFailures) {
382-
comment += generateUpdateCommand(f.title) + "\n";
390+
const cmds = generateCommands(f.title);
391+
comment += `**\`${f.title}\`**\n`;
392+
comment += "```bash\n";
393+
comment += `# Run test\n${cmds.run}\n\n`;
394+
comment += `# Update snapshots\n${cmds.update}\n`;
395+
comment += "```\n\n";
383396
}
384-
comment += "```\n";
385397

386398
if (macOsFailures.length > 5) {
387-
comment += "\n</details>\n";
399+
comment += "</details>\n";
388400
}
389401
comment += "\n";
390402
}

0 commit comments

Comments
 (0)