Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
4907fcaf
Unverified
提交
4907fcaf
authored
6月 06, 2025
作者:
Will Chen
提交者:
GitHub
6月 06, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
E2E test for fixing errors (#351)
上级
d3fbb484
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
144 行增加
和
6 行删除
+144
-6
fix_error.spec.ts
e2e-tests/fix_error.spec.ts
+21
-0
create-error.md
e2e-tests/fixtures/create-error.md
+25
-0
test_helper.ts
e2e-tests/helpers/test_helper.ts
+18
-4
fix_error.spec.ts_fix-error-with-AI-1.aria.yml
.../snapshots/fix_error.spec.ts_fix-error-with-AI-1.aria.yml
+9
-0
fix_error.spec.ts_fix-error-with-AI-2.aria.yml
.../snapshots/fix_error.spec.ts_fix-error-with-AI-2.aria.yml
+9
-0
fix_error.spec.ts_fix-error-with-AI-3.aria.yml
.../snapshots/fix_error.spec.ts_fix-error-with-AI-3.aria.yml
+21
-0
fix_error.spec.ts_fix-error-with-AI-4.aria.yml
.../snapshots/fix_error.spec.ts_fix-error-with-AI-4.aria.yml
+7
-0
playwright.config.ts
playwright.config.ts
+1
-1
PreviewIframe.tsx
src/components/preview_panel/PreviewIframe.tsx
+4
-1
chatCompletionHandler.ts
testing/fake-llm-server/chatCompletionHandler.ts
+29
-0
没有找到文件。
e2e-tests/fix_error.spec.ts
0 → 100644
浏览文件 @
4907fcaf
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
();
});
e2e-tests/fixtures/create-error.md
0 → 100644
浏览文件 @
4907fcaf
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>
e2e-tests/helpers/test_helper.ts
浏览文件 @
4907fcaf
...
...
@@ -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
({
...
...
e2e-tests/snapshots/fix_error.spec.ts_fix-error-with-AI-1.aria.yml
0 → 100644
浏览文件 @
4907fcaf
-
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
\ No newline at end of file
e2e-tests/snapshots/fix_error.spec.ts_fix-error-with-AI-2.aria.yml
0 → 100644
浏览文件 @
4907fcaf
-
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
\ No newline at end of file
e2e-tests/snapshots/fix_error.spec.ts_fix-error-with-AI-3.aria.yml
0 → 100644
浏览文件 @
4907fcaf
-
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
\ No newline at end of file
e2e-tests/snapshots/fix_error.spec.ts_fix-error-with-AI-4.aria.yml
0 → 100644
浏览文件 @
4907fcaf
-
region "Notifications (F8)"
:
-
list
-
region "Notifications alt+T"
-
heading "No more errors!" [level=1]
-
link "Made with Dyad"
:
-
/url
:
https://www.dyad.sh/
\ No newline at end of file
playwright.config.ts
浏览文件 @
4907fcaf
...
...
@@ -5,7 +5,7 @@ const config: PlaywrightTestConfig = {
workers
:
1
,
retries
:
process
.
env
.
CI
?
1
:
0
,
// maxFailures: 1,
timeout
:
process
.
env
.
CI
?
1
2
0
_000
:
30
_000
,
timeout
:
process
.
env
.
CI
?
1
8
0
_000
:
30
_000
,
// Use a custom snapshot path template because Playwright's default
// is platform-specific which isn't necessary for Dyad e2e tests
// which should be platform agnostic (we don't do screenshots; only textual diffs).
...
...
src/components/preview_panel/PreviewIframe.tsx
浏览文件 @
4907fcaf
...
...
@@ -51,7 +51,10 @@ const ErrorBanner = ({ error, onDismiss, onAIFix }: ErrorBannerProps) => {
};
return
(
<
div
className=
"absolute top-2 left-2 right-2 z-10 bg-red-50 dark:bg-red-950 border border-red-200 dark:border-red-800 rounded-md shadow-sm p-2"
>
<
div
className=
"absolute top-2 left-2 right-2 z-10 bg-red-50 dark:bg-red-950 border border-red-200 dark:border-red-800 rounded-md shadow-sm p-2"
data
-
testid=
"preview-error-banner"
>
{
/* Close button in top left */
}
<
button
onClick=
{
onDismiss
}
...
...
testing/fake-llm-server/chatCompletionHandler.ts
浏览文件 @
4907fcaf
...
...
@@ -24,6 +24,35 @@ export const createChatCompletionHandler =
}
let
messageContent
=
CANNED_MESSAGE
;
if
(
lastMessage
&&
typeof
lastMessage
.
content
===
"string"
&&
lastMessage
.
content
.
startsWith
(
"Fix error: Error Line 6 error"
)
)
{
messageContent
=
`
Fixing the error...
<dyad-write path="src/pages/Index.tsx">
import { MadeWithDyad } from "@/components/made-with-dyad";
const Index = () => {
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">No more errors!</h1>
</div>
<MadeWithDyad />
</div>
);
};
export default Index;
</dyad-write>
`
;
}
console
.
error
(
"LASTMESSAGE"
,
lastMessage
);
// Check if the last message is "[dump]" to write messages to file and return path
if
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论