Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一杯枸杞茶ya
csdn-workflow
提交
139ff6b8
C
csdn-workflow
项目概览
一杯枸杞茶ya
/
csdn-workflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
csdn-workflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
139ff6b8
编写于
3月 01, 2021
作者:
T
Tomas Vik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test(mr review): add integration tests for initializing MR discussions
上级
309b8e5e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
6 deletion
+67
-6
src/data_providers/items/mr_item_model.test.ts
src/data_providers/items/mr_item_model.test.ts
+1
-1
test/integration/fixtures/graphql/discussions.js
test/integration/fixtures/graphql/discussions.js
+19
-3
test/integration/mr_review.test.js
test/integration/mr_review.test.js
+45
-0
test/integration/webview.test.js
test/integration/webview.test.js
+2
-2
未找到文件。
src/data_providers/items/mr_item_model.test.ts
浏览文件 @
139ff6b8
...
...
@@ -43,7 +43,7 @@ describe('MrItemModel', () => {
const
[
uri
,
range
]
=
createCommentThreadMock
.
mock
.
calls
[
0
];
expect
(
uri
.
path
).
toBe
(
'
src/webview/src/components/LabelNote.vue
'
);
expect
(
range
.
start
.
x
).
toBe
(
47
);
expect
(
commentThread
.
comments
.
length
).
toBe
(
2
);
expect
(
commentThread
.
comments
.
length
).
toBe
(
1
);
const
firstComment
=
commentThread
.
comments
[
0
];
expect
(
firstComment
.
author
.
name
).
toBe
(
'
Tomas Vik
'
);
expect
(
firstComment
.
mode
).
toBe
(
vscode
.
CommentMode
.
Preview
);
...
...
test/integration/fixtures/graphql/discussions.js
浏览文件 @
139ff6b8
...
...
@@ -132,11 +132,11 @@ const discussionOnDiff = {
hasNextPage
:
false
,
endCursor
:
'
MQ
'
,
},
nodes
:
[
noteOnDiff
,
note2
],
nodes
:
[
noteOnDiff
],
},
};
const
projectWithDiscussions
=
{
const
projectWith
Issue
Discussions
=
{
project
:
{
id
:
'
gid://gitlab/Project/278964
'
,
issue
:
{
...
...
@@ -151,8 +151,24 @@ const projectWithDiscussions = {
},
};
const
projectWithMrDiscussions
=
{
project
:
{
id
:
'
gid://gitlab/Project/278964
'
,
mergeRequest
:
{
discussions
:
{
pageInfo
:
{
hasNextPage
:
false
,
endCursor
:
'
Nw
'
,
},
nodes
:
[
systemNote
,
singleNote
,
discussionOnDiff
],
},
},
},
};
module
.
exports
=
{
projectWithDiscussions
,
projectWithIssueDiscussions
,
projectWithMrDiscussions
,
note1
,
note1TextSnippet
,
note2
,
...
...
test/integration/mr_review.test.js
浏览文件 @
139ff6b8
const
assert
=
require
(
'
assert
'
);
const
sinon
=
require
(
'
sinon
'
);
const
vscode
=
require
(
'
vscode
'
);
const
{
graphql
}
=
require
(
'
msw
'
);
const
IssuableDataProvider
=
require
(
'
../../src/data_providers/issuable
'
).
DataProvider
;
const
{
MrItemModel
}
=
require
(
'
../../src/data_providers/items/mr_item_model
'
);
const
{
tokenService
}
=
require
(
'
../../src/services/token_service
'
);
const
openMergeRequestResponse
=
require
(
'
./fixtures/rest/open_mr.json
'
);
const
versionsResponse
=
require
(
'
./fixtures/rest/versions.json
'
);
const
versionResponse
=
require
(
'
./fixtures/rest/mr_version.json
'
);
const
{
projectWithMrDiscussions
,
noteOnDiff
}
=
require
(
'
./fixtures/graphql/discussions
'
);
const
{
getServer
,
createJsonEndpoint
,
...
...
@@ -31,6 +36,11 @@ describe('MR Review', () => {
'
?ref=1f0fa02de1f6b913d674a8be10899fb8540237a9
'
:
'
Old Version
'
,
'
?ref=b6d6f6fd17b52b8cf4e961218c572805e9aa7463
'
:
'
New Version
'
,
}),
graphql
.
query
(
'
GetMrDiscussions
'
,
(
req
,
res
,
ctx
)
=>
{
if
(
req
.
variables
.
projectPath
===
'
gitlab-org/gitlab
'
&&
req
.
variables
.
iid
===
'
33824
'
)
return
res
(
ctx
.
data
(
projectWithMrDiscussions
));
return
res
(
ctx
.
data
({
project
:
null
}));
}),
]);
await
tokenService
.
setToken
(
GITLAB_URL
,
'
abcd-secret
'
);
});
...
...
@@ -73,6 +83,41 @@ describe('MR Review', () => {
);
});
describe
(
'
discussions
'
,
()
=>
{
const
sandbox
=
sinon
.
createSandbox
();
let
thread
;
let
commentController
;
beforeEach
(()
=>
{
thread
=
{};
/* We fake createCommentController implementation to check
that when we initialize an MR review, we create a correct comment controller
we save the created thread for later use in assertions */
commentController
=
{
createCommentThread
:
(
uri
,
range
,
comments
)
=>
{
thread
=
{
uri
,
range
,
comments
};
return
thread
;
},
};
sandbox
.
stub
(
vscode
.
comments
,
'
createCommentController
'
).
returns
(
commentController
);
});
afterEach
(()
=>
{
sandbox
.
restore
();
});
it
(
'
loads MR discussions
'
,
async
()
=>
{
const
mrItem
=
getTreeItem
(
mrItemModel
);
assert
.
strictEqual
(
mrItem
.
label
,
'
!33824 · Web IDE - remove unused actions (mappings)
'
);
await
dataProvider
.
getChildren
(
mrItemModel
);
const
{
uri
,
range
,
comments
}
=
thread
;
assert
.
strictEqual
(
uri
.
path
,
`/
${
noteOnDiff
.
position
.
newPath
}
`
);
assert
.
strictEqual
(
range
.
start
.
line
,
noteOnDiff
.
position
.
oldLine
-
1
);
assert
.
strictEqual
(
comments
[
0
].
body
,
noteOnDiff
.
body
);
});
});
describe
(
'
clicking on a changed file
'
,
()
=>
{
let
mrFiles
;
...
...
test/integration/webview.test.js
浏览文件 @
139ff6b8
...
...
@@ -6,7 +6,7 @@ const { graphql } = require('msw');
const
webviewController
=
require
(
'
../../src/webview_controller
'
);
const
{
tokenService
}
=
require
(
'
../../src/services/token_service
'
);
const
openIssueResponse
=
require
(
'
./fixtures/rest/open_issue.json
'
);
const
{
projectWithDiscussions
}
=
require
(
'
./fixtures/graphql/discussions
'
);
const
{
projectWith
Issue
Discussions
}
=
require
(
'
./fixtures/graphql/discussions
'
);
const
{
getServer
,
createJsonEndpoint
}
=
require
(
'
./test_infrastructure/mock_server
'
);
const
{
GITLAB_URL
}
=
require
(
'
./test_infrastructure/constants
'
);
...
...
@@ -29,7 +29,7 @@ describe('GitLab webview', () => {
server
=
getServer
([
graphql
.
query
(
'
GetIssueDiscussions
'
,
(
req
,
res
,
ctx
)
=>
{
if
(
req
.
variables
.
projectPath
===
'
gitlab-org/gitlab
'
)
return
res
(
ctx
.
data
(
projectWithDiscussions
));
return
res
(
ctx
.
data
(
projectWith
Issue
Discussions
));
return
res
(
ctx
.
data
({
project
:
null
}));
}),
graphql
.
mutation
(
'
CreateNote
'
,
(
req
,
res
,
ctx
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录