E2E test for fixing errors (#351)

This commit is contained in:
Will Chen
2025-06-05 23:29:52 -07:00
committed by GitHub
parent d3fbb48472
commit 4907fcafd8
10 changed files with 140 additions and 6 deletions

View File

@@ -0,0 +1,21 @@
import { testSkipIfWindows } from "./helpers/test_helper";
testSkipIfWindows("fix error with AI", async ({ po }) => {
await po.setUp({ autoApprove: true });
await po.sendPrompt("tc=create-error");
await po.snapshotPreviewErrorBanner();
await po.page.getByText("Error Line 6 error", { exact: true }).click();
await po.snapshotPreviewErrorBanner();
await po.clickFixErrorWithAI();
await po.waitForChatCompletion();
await po.snapshotMessages();
// TODO: this is an actual bug where the error banner should not
// be shown, however there's some kind of race condition and
// we don't reliably detect when the HMR update has completed.
// await po.locatePreviewErrorBanner().waitFor({ state: "hidden" });
await po.snapshotPreview();
});

View File

@@ -0,0 +1,25 @@
I will intentionally add an error
<dyad-write path="src/pages/Index.tsx" description="intentionally add an error">
// Update this page (the content is just a fallback if you fail to update the page)
import { MadeWithDyad } from "@/components/made-with-dyad";
const Index = () => {
throw new Error("Line 6 error");
return (
<div className="min-h-screen flex items-center justify-center bg-gray-100">
<div className="text-center">
<h1 className="text-4xl font-bold mb-4">Welcome to Your Blank App</h1>
<p className="text-xl text-gray-600">
Start building your amazing project here!
</p>
</div>
<MadeWithDyad />
</div>
);
};
export default Index;
</dyad-write>

View File

@@ -10,10 +10,10 @@ import { generateAppFilesSnapshotData } from "./generateAppFilesSnapshotData";
const showDebugLogs = process.env.DEBUG_LOGS === "true";
export const Timeout = {
// Why make this a constant? In some platforms, perhaps locally,
// we may want to shorten this.
LONG: os.platform() === "win32" ? 60_000 : 30_000,
MEDIUM: os.platform() === "win32" ? 30_000 : 15_000,
// Things generally take longer on CI, so we make them longer.
EXTRA_LONG: process.env.CI ? 120_000 : 60_000,
LONG: process.env.CI ? 60_000 : 30_000,
MEDIUM: process.env.CI ? 30_000 : 15_000,
};
export class PageObject {
@@ -165,6 +165,20 @@ export class PageObject {
return this.page.getByTestId("preview-iframe-element");
}
async clickFixErrorWithAI() {
await this.page.getByRole("button", { name: "Fix error with AI" }).click();
}
async snapshotPreviewErrorBanner() {
await expect(this.locatePreviewErrorBanner()).toMatchAriaSnapshot({
timeout: Timeout.LONG,
});
}
locatePreviewErrorBanner() {
return this.page.getByTestId("preview-error-banner");
}
async snapshotPreview({ name }: { name?: string } = {}) {
const iframe = this.getPreviewIframeElement();
await expect(iframe.contentFrame().locator("body")).toMatchAriaSnapshot({

View File

@@ -0,0 +1,8 @@
- button:
- img
- img
- text: Error Line 6 error
- img
- text: "Tip: Check if restarting the app fixes the error."
- button "Fix error with AI":
- img

View File

@@ -0,0 +1,8 @@
- button:
- img
- img
- text: "/Error Line 6 error Stack trace: Index \\(http:\\/\\/localhost:\\d+\\/src\\/pages\\/Index\\.tsx:6:6\\)/"
- img
- text: "Tip: Check if restarting the app fixes the error."
- button "Fix error with AI":
- img

View File

@@ -0,0 +1,20 @@
- paragraph: tc=create-error
- paragraph: I will intentionally add an error
- img
- text: Index.tsx
- img
- text: "src/pages/Index.tsx Summary: intentionally add an error"
- img
- text: Approved
- paragraph: "/Fix error: Error Line 6 error Stack trace: Index \\(http:\\/\\/localhost:\\d+\\/src\\/pages\\/Index\\.tsx:6:6\\)/"
- code: Fixing the error...
- img
- text: Index.tsx
- img
- text: src/pages/Index.tsx
- img
- text: Approved
- button "Undo":
- img
- button "Retry":
- img

View File

@@ -0,0 +1,6 @@
- region "Notifications (F8)":
- list
- region "Notifications alt+T"
- heading "No more errors!" [level=1]
- link "Made with Dyad":
- /url: https://www.dyad.sh/