Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
ac98a52a
Unverified
提交
ac98a52a
authored
6月 09, 2025
作者:
Will Chen
提交者:
GitHub
6月 09, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix unit test & run in CI (#372)
上级
34ea5939
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
45 行增加
和
3 行删除
+45
-3
ci.yml
.github/workflows/ci.yml
+4
-0
chat_stream_handlers.test.ts
src/__tests__/chat_stream_handlers.test.ts
+41
-3
没有找到文件。
.github/workflows/ci.yml
浏览文件 @
ac98a52a
...
@@ -49,6 +49,10 @@ jobs:
...
@@ -49,6 +49,10 @@ jobs:
# do not run this on windows (it's redunant)
# do not run this on windows (it's redunant)
if
:
contains(matrix.os.name, 'macos')
if
:
contains(matrix.os.name, 'macos')
run
:
npm run ts
run
:
npm run ts
-
name
:
Unit tests
# do not run this on windows (it's redunant)
if
:
contains(matrix.os.name, 'macos')
run
:
npm run test
-
name
:
Install Chromium browser for Playwright
-
name
:
Install Chromium browser for Playwright
run
:
npx playwright install chromium --with-deps
run
:
npx playwright install chromium --with-deps
-
name
:
Build
-
name
:
Build
...
...
src/__tests__/chat_stream_handlers.test.ts
浏览文件 @
ac98a52a
...
@@ -19,6 +19,10 @@ vi.mock("node:fs", async () => {
...
@@ -19,6 +19,10 @@ vi.mock("node:fs", async () => {
existsSync
:
vi
.
fn
(),
existsSync
:
vi
.
fn
(),
renameSync
:
vi
.
fn
(),
renameSync
:
vi
.
fn
(),
unlinkSync
:
vi
.
fn
(),
unlinkSync
:
vi
.
fn
(),
lstatSync
:
vi
.
fn
().
mockReturnValue
({
isDirectory
:
()
=>
false
}),
promises
:
{
readFile
:
vi
.
fn
().
mockResolvedValue
(
""
),
},
},
},
};
};
});
});
...
@@ -29,6 +33,7 @@ vi.mock("isomorphic-git", () => ({
...
@@ -29,6 +33,7 @@ vi.mock("isomorphic-git", () => ({
add
:
vi
.
fn
().
mockResolvedValue
(
undefined
),
add
:
vi
.
fn
().
mockResolvedValue
(
undefined
),
remove
:
vi
.
fn
().
mockResolvedValue
(
undefined
),
remove
:
vi
.
fn
().
mockResolvedValue
(
undefined
),
commit
:
vi
.
fn
().
mockResolvedValue
(
undefined
),
commit
:
vi
.
fn
().
mockResolvedValue
(
undefined
),
statusMatrix
:
vi
.
fn
().
mockResolvedValue
([]),
},
},
}));
}));
...
@@ -37,6 +42,7 @@ vi.mock("../paths/paths", () => ({
...
@@ -37,6 +42,7 @@ vi.mock("../paths/paths", () => ({
getDyadAppPath
:
vi
.
fn
().
mockImplementation
((
appPath
)
=>
{
getDyadAppPath
:
vi
.
fn
().
mockImplementation
((
appPath
)
=>
{
return
`/mock/user/data/path/
${
appPath
}
`
;
return
`/mock/user/data/path/
${
appPath
}
`
;
}),
}),
getUserDataPath
:
vi
.
fn
().
mockReturnValue
(
"/mock/user/data/path"
),
}));
}));
// Mock db
// Mock db
...
@@ -46,7 +52,15 @@ vi.mock("../db", () => ({
...
@@ -46,7 +52,15 @@ vi.mock("../db", () => ({
chats
:
{
chats
:
{
findFirst
:
vi
.
fn
(),
findFirst
:
vi
.
fn
(),
},
},
messages
:
{
findFirst
:
vi
.
fn
(),
},
},
},
update
:
vi
.
fn
(()
=>
({
set
:
vi
.
fn
(()
=>
({
where
:
vi
.
fn
().
mockResolvedValue
(
undefined
),
})),
})),
},
},
}));
}));
...
@@ -99,6 +113,7 @@ console.log("TodoItem");
...
@@ -99,6 +113,7 @@ console.log("TodoItem");
expect
(
result
).
toEqual
([
expect
(
result
).
toEqual
([
{
{
path
:
"src/components/TodoItem.tsx"
,
path
:
"src/components/TodoItem.tsx"
,
description
:
"Creating a component for individual todo items"
,
content
:
`import React from "react";
content
:
`import React from "react";
console.log("TodoItem");`
,
console.log("TodoItem");`
,
},
},
...
@@ -117,6 +132,7 @@ console.log("TodoItem");
...
@@ -117,6 +132,7 @@ console.log("TodoItem");
expect
(
result
).
toEqual
([
expect
(
result
).
toEqual
([
{
{
path
:
"src/components/TodoItem.tsx"
,
path
:
"src/components/TodoItem.tsx"
,
description
:
"Creating a component for individual todo items"
,
content
:
`import React from "react";
content
:
`import React from "react";
console.log("TodoItem");`
,
console.log("TodoItem");`
,
},
},
...
@@ -515,6 +531,16 @@ describe("processFullResponse", () => {
...
@@ -515,6 +531,16 @@ describe("processFullResponse", () => {
messages
:
[],
messages
:
[],
}
as
any
);
}
as
any
);
vi
.
mocked
(
db
.
query
.
messages
.
findFirst
).
mockResolvedValue
({
id
:
1
,
chatId
:
1
,
role
:
"assistant"
,
content
:
"some content"
,
createdAt
:
new
Date
(),
approvalState
:
null
,
commitHash
:
null
,
}
as
any
);
// Default mock for existsSync to return true
// Default mock for existsSync to return true
vi
.
mocked
(
fs
.
existsSync
).
mockReturnValue
(
true
);
vi
.
mocked
(
fs
.
existsSync
).
mockReturnValue
(
true
);
});
});
...
@@ -528,7 +554,11 @@ describe("processFullResponse", () => {
...
@@ -528,7 +554,11 @@ describe("processFullResponse", () => {
messageId
:
1
,
messageId
:
1
,
},
},
);
);
expect
(
result
).
toEqual
({});
expect
(
result
).
toEqual
({
updatedFiles
:
false
,
extraFiles
:
undefined
,
extraFilesError
:
undefined
,
});
expect
(
fs
.
mkdirSync
).
not
.
toHaveBeenCalled
();
expect
(
fs
.
mkdirSync
).
not
.
toHaveBeenCalled
();
expect
(
fs
.
writeFileSync
).
not
.
toHaveBeenCalled
();
expect
(
fs
.
writeFileSync
).
not
.
toHaveBeenCalled
();
});
});
...
@@ -703,7 +733,11 @@ describe("processFullResponse", () => {
...
@@ -703,7 +733,11 @@ describe("processFullResponse", () => {
expect
(
fs
.
mkdirSync
).
toHaveBeenCalled
();
expect
(
fs
.
mkdirSync
).
toHaveBeenCalled
();
expect
(
fs
.
renameSync
).
not
.
toHaveBeenCalled
();
expect
(
fs
.
renameSync
).
not
.
toHaveBeenCalled
();
expect
(
git
.
commit
).
not
.
toHaveBeenCalled
();
expect
(
git
.
commit
).
not
.
toHaveBeenCalled
();
expect
(
result
).
toEqual
({});
expect
(
result
).
toEqual
({
updatedFiles
:
false
,
extraFiles
:
undefined
,
extraFilesError
:
undefined
,
});
});
});
it
(
"should process dyad-delete tags and delete files"
,
async
()
=>
{
it
(
"should process dyad-delete tags and delete files"
,
async
()
=>
{
...
@@ -744,7 +778,11 @@ describe("processFullResponse", () => {
...
@@ -744,7 +778,11 @@ describe("processFullResponse", () => {
expect
(
fs
.
unlinkSync
).
not
.
toHaveBeenCalled
();
expect
(
fs
.
unlinkSync
).
not
.
toHaveBeenCalled
();
expect
(
git
.
remove
).
not
.
toHaveBeenCalled
();
expect
(
git
.
remove
).
not
.
toHaveBeenCalled
();
expect
(
git
.
commit
).
not
.
toHaveBeenCalled
();
expect
(
git
.
commit
).
not
.
toHaveBeenCalled
();
expect
(
result
).
toEqual
({});
expect
(
result
).
toEqual
({
updatedFiles
:
false
,
extraFiles
:
undefined
,
extraFilesError
:
undefined
,
});
});
});
it
(
"should process mixed operations (write, rename, delete) in one response"
,
async
()
=>
{
it
(
"should process mixed operations (write, rename, delete) in one response"
,
async
()
=>
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论