Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
44a0121a
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
44a0121a
编写于
11月 30, 2018
作者:
S
Sam Bigelow
提交者:
Phil Hughes
11月 30, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Resolve "Merge request refactor does not highlight selected line"
上级
0d5cbd16
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
288 addition
and
12 deletion
+288
-12
app/assets/javascripts/diffs/components/app.vue
app/assets/javascripts/diffs/components/app.vue
+7
-0
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
...javascripts/diffs/components/diff_line_gutter_content.vue
+15
-2
app/assets/javascripts/diffs/components/diff_table_cell.vue
app/assets/javascripts/diffs/components/diff_table_cell.vue
+8
-1
app/assets/javascripts/diffs/components/inline_diff_table_row.vue
...ts/javascripts/diffs/components/inline_diff_table_row.vue
+18
-2
app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
.../javascripts/diffs/components/parallel_diff_table_row.vue
+26
-3
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+6
-2
app/assets/javascripts/diffs/store/modules/diff_state.js
app/assets/javascripts/diffs/store/modules/diff_state.js
+1
-0
app/assets/javascripts/diffs/store/mutation_types.js
app/assets/javascripts/diffs/store/mutation_types.js
+1
-0
app/assets/javascripts/diffs/store/mutations.js
app/assets/javascripts/diffs/store/mutations.js
+3
-0
changelogs/unreleased/48496-merge-request-refactor-does-not-highlight-selected-line.yml
...rge-request-refactor-does-not-highlight-selected-line.yml
+5
-0
spec/javascripts/diffs/components/app_spec.js
spec/javascripts/diffs/components/app_spec.js
+13
-0
spec/javascripts/diffs/components/diff_table_cell_spec.js
spec/javascripts/diffs/components/diff_table_cell_spec.js
+37
-0
spec/javascripts/diffs/components/inline_diff_table_row_spec.js
...avascripts/diffs/components/inline_diff_table_row_spec.js
+42
-0
spec/javascripts/diffs/components/parallel_diff_table_row_spec.js
...ascripts/diffs/components/parallel_diff_table_row_spec.js
+85
-0
spec/javascripts/diffs/store/actions_spec.js
spec/javascripts/diffs/store/actions_spec.js
+11
-2
spec/javascripts/diffs/store/mutations_spec.js
spec/javascripts/diffs/store/mutations_spec.js
+10
-0
未找到文件。
app/assets/javascripts/diffs/components/app.vue
浏览文件 @
44a0121a
...
@@ -102,6 +102,12 @@ export default {
...
@@ -102,6 +102,12 @@ export default {
if
(
this
.
shouldShow
)
{
if
(
this
.
shouldShow
)
{
this
.
fetchData
();
this
.
fetchData
();
}
}
const
id
=
window
&&
window
.
location
&&
window
.
location
.
hash
;
if
(
id
)
{
this
.
setHighlightedRow
(
id
.
slice
(
1
));
}
},
},
created
()
{
created
()
{
this
.
adjustView
();
this
.
adjustView
();
...
@@ -114,6 +120,7 @@ export default {
...
@@ -114,6 +120,7 @@ export default {
'
fetchDiffFiles
'
,
'
fetchDiffFiles
'
,
'
startRenderDiffsQueue
'
,
'
startRenderDiffsQueue
'
,
'
assignDiscussionsToDiff
'
,
'
assignDiscussionsToDiff
'
,
'
setHighlightedRow
'
,
]),
]),
fetchData
()
{
fetchData
()
{
this
.
fetchDiffFiles
()
this
.
fetchDiffFiles
()
...
...
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
浏览文件 @
44a0121a
...
@@ -72,6 +72,13 @@ export default {
...
@@ -72,6 +72,13 @@ export default {
diffFiles
:
state
=>
state
.
diffs
.
diffFiles
,
diffFiles
:
state
=>
state
.
diffs
.
diffFiles
,
}),
}),
...
mapGetters
([
'
isLoggedIn
'
]),
...
mapGetters
([
'
isLoggedIn
'
]),
lineCode
()
{
return
(
this
.
line
.
line_code
||
(
this
.
line
.
left
&&
this
.
line
.
line
.
left
.
line_code
)
||
(
this
.
line
.
right
&&
this
.
line
.
right
.
line_code
)
);
},
lineHref
()
{
lineHref
()
{
return
`#
${
this
.
line
.
line_code
||
''
}
`
;
return
`#
${
this
.
line
.
line_code
||
''
}
`
;
},
},
...
@@ -97,7 +104,7 @@ export default {
...
@@ -97,7 +104,7 @@ export default {
},
},
},
},
methods
:
{
methods
:
{
...
mapActions
(
'
diffs
'
,
[
'
loadMoreLines
'
,
'
showCommentForm
'
]),
...
mapActions
(
'
diffs
'
,
[
'
loadMoreLines
'
,
'
showCommentForm
'
,
'
setHighlightedRow
'
]),
handleCommentButton
()
{
handleCommentButton
()
{
this
.
showCommentForm
({
lineCode
:
this
.
line
.
line_code
,
fileHash
:
this
.
fileHash
});
this
.
showCommentForm
({
lineCode
:
this
.
line
.
line_code
,
fileHash
:
this
.
fileHash
});
},
},
...
@@ -168,7 +175,13 @@ export default {
...
@@ -168,7 +175,13 @@ export default {
>
>
<icon
:size=
"12"
name=
"comment"
/>
<icon
:size=
"12"
name=
"comment"
/>
</button>
</button>
<a
v-if=
"lineNumber"
:data-linenumber=
"lineNumber"
:href=
"lineHref"
>
</a>
<a
v-if=
"lineNumber"
:data-linenumber=
"lineNumber"
:href=
"lineHref"
@
click=
"setHighlightedRow(lineCode);"
>
</a>
<diff-gutter-avatars
v-if=
"shouldShowAvatarsOnGutter"
:discussions=
"line.discussions"
/>
<diff-gutter-avatars
v-if=
"shouldShowAvatarsOnGutter"
:discussions=
"line.discussions"
/>
</
template
>
</
template
>
</div>
</div>
...
...
app/assets/javascripts/diffs/components/diff_table_cell.vue
浏览文件 @
44a0121a
<
script
>
<
script
>
import
{
mapGetters
}
from
'
vuex
'
;
import
{
mapGetters
,
mapActions
}
from
'
vuex
'
;
import
DiffLineGutterContent
from
'
./diff_line_gutter_content.vue
'
;
import
DiffLineGutterContent
from
'
./diff_line_gutter_content.vue
'
;
import
{
import
{
MATCH_LINE_TYPE
,
MATCH_LINE_TYPE
,
...
@@ -30,6 +30,11 @@ export default {
...
@@ -30,6 +30,11 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
isHighlighted
:
{
type
:
Boolean
,
required
:
true
,
default
:
false
,
},
diffViewType
:
{
diffViewType
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
...
@@ -85,6 +90,7 @@ export default {
...
@@ -85,6 +90,7 @@ export default {
const
{
type
}
=
this
.
line
;
const
{
type
}
=
this
.
line
;
return
{
return
{
hll
:
this
.
isHighlighted
,
[
type
]:
type
,
[
type
]:
type
,
[
LINE_UNFOLD_CLASS_NAME
]:
this
.
isMatchLine
,
[
LINE_UNFOLD_CLASS_NAME
]:
this
.
isMatchLine
,
[
LINE_HOVER_CLASS_NAME
]:
[
LINE_HOVER_CLASS_NAME
]:
...
@@ -99,6 +105,7 @@ export default {
...
@@ -99,6 +105,7 @@ export default {
return
this
.
lineType
===
OLD_LINE_TYPE
?
this
.
line
.
old_line
:
this
.
line
.
new_line
;
return
this
.
lineType
===
OLD_LINE_TYPE
?
this
.
line
.
old_line
:
this
.
line
.
new_line
;
},
},
},
},
methods
:
mapActions
(
'
diffs
'
,
[
'
setHighlightedRow
'
]),
};
};
</
script
>
</
script
>
...
...
app/assets/javascripts/diffs/components/inline_diff_table_row.vue
浏览文件 @
44a0121a
<
script
>
<
script
>
import
{
mapGetters
,
mapActions
}
from
'
vuex
'
;
import
{
mapGetters
,
mapActions
,
mapState
}
from
'
vuex
'
;
import
DiffTableCell
from
'
./diff_table_cell.vue
'
;
import
DiffTableCell
from
'
./diff_table_cell.vue
'
;
import
{
import
{
NEW_LINE_TYPE
,
NEW_LINE_TYPE
,
...
@@ -40,6 +40,11 @@ export default {
...
@@ -40,6 +40,11 @@ export default {
};
};
},
},
computed
:
{
computed
:
{
...
mapState
({
isHighlighted
(
state
)
{
return
this
.
line
.
line_code
!==
null
&&
this
.
line
.
line_code
===
state
.
diffs
.
highlightedRow
;
},
}),
...
mapGetters
(
'
diffs
'
,
[
'
isInlineView
'
]),
...
mapGetters
(
'
diffs
'
,
[
'
isInlineView
'
]),
isContextLine
()
{
isContextLine
()
{
return
this
.
line
.
type
===
CONTEXT_LINE_TYPE
;
return
this
.
line
.
type
===
CONTEXT_LINE_TYPE
;
...
@@ -91,6 +96,7 @@ export default {
...
@@ -91,6 +96,7 @@ export default {
:is-bottom=
"isBottom"
:is-bottom=
"isBottom"
:is-hover=
"isHover"
:is-hover=
"isHover"
:show-comment-button=
"true"
:show-comment-button=
"true"
:is-highlighted=
"isHighlighted"
class=
"diff-line-num old_line"
class=
"diff-line-num old_line"
/>
/>
<diff-table-cell
<diff-table-cell
...
@@ -100,8 +106,18 @@ export default {
...
@@ -100,8 +106,18 @@ export default {
:line-type=
"newLineType"
:line-type=
"newLineType"
:is-bottom=
"isBottom"
:is-bottom=
"isBottom"
:is-hover=
"isHover"
:is-hover=
"isHover"
:is-highlighted=
"isHighlighted"
class=
"diff-line-num new_line qa-new-diff-line"
class=
"diff-line-num new_line qa-new-diff-line"
/>
/>
<td
:class=
"line.type"
class=
"line_content"
v-html=
"line.rich_text"
></td>
<td
:class=
"[
line.type,
{
hll: isHighlighted,
},
]"
class="line_content"
v-html="line.rich_text"
>
</td>
</tr>
</tr>
</
template
>
</
template
>
app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
浏览文件 @
44a0121a
<
script
>
<
script
>
import
{
mapActions
}
from
'
vuex
'
;
import
{
mapActions
,
mapState
}
from
'
vuex
'
;
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
DiffTableCell
from
'
./diff_table_cell.vue
'
;
import
DiffTableCell
from
'
./diff_table_cell.vue
'
;
import
{
import
{
...
@@ -43,6 +43,15 @@ export default {
...
@@ -43,6 +43,15 @@ export default {
};
};
},
},
computed
:
{
computed
:
{
...
mapState
({
isHighlighted
(
state
)
{
const
lineCode
=
(
this
.
line
.
left
&&
this
.
line
.
left
.
line_code
)
||
(
this
.
line
.
right
&&
this
.
line
.
right
.
line_code
);
return
lineCode
?
lineCode
===
state
.
diffs
.
highlightedRow
:
false
;
},
}),
isContextLine
()
{
isContextLine
()
{
return
this
.
line
.
left
&&
this
.
line
.
left
.
type
===
CONTEXT_LINE_TYPE
;
return
this
.
line
.
left
&&
this
.
line
.
left
.
type
===
CONTEXT_LINE_TYPE
;
},
},
...
@@ -57,7 +66,14 @@ export default {
...
@@ -57,7 +66,14 @@ export default {
return
OLD_NO_NEW_LINE_TYPE
;
return
OLD_NO_NEW_LINE_TYPE
;
}
}
return
this
.
line
.
left
?
this
.
line
.
left
.
type
:
EMPTY_CELL_TYPE
;
const
lineTypeClass
=
this
.
line
.
left
?
this
.
line
.
left
.
type
:
EMPTY_CELL_TYPE
;
return
[
lineTypeClass
,
{
hll
:
this
.
isHighlighted
,
},
];
},
},
},
},
created
()
{
created
()
{
...
@@ -114,6 +130,7 @@ export default {
...
@@ -114,6 +130,7 @@ export default {
:line-type=
"oldLineType"
:line-type=
"oldLineType"
:is-bottom=
"isBottom"
:is-bottom=
"isBottom"
:is-hover=
"isLeftHover"
:is-hover=
"isLeftHover"
:is-highlighted=
"isHighlighted"
:show-comment-button=
"true"
:show-comment-button=
"true"
:diff-view-type=
"parallelDiffViewType"
:diff-view-type=
"parallelDiffViewType"
line-position=
"left"
line-position=
"left"
...
@@ -139,6 +156,7 @@ export default {
...
@@ -139,6 +156,7 @@ export default {
:line-type=
"newLineType"
:line-type=
"newLineType"
:is-bottom=
"isBottom"
:is-bottom=
"isBottom"
:is-hover=
"isRightHover"
:is-hover=
"isRightHover"
:is-highlighted=
"isHighlighted"
:show-comment-button=
"true"
:show-comment-button=
"true"
:diff-view-type=
"parallelDiffViewType"
:diff-view-type=
"parallelDiffViewType"
line-position=
"right"
line-position=
"right"
...
@@ -146,7 +164,12 @@ export default {
...
@@ -146,7 +164,12 @@ export default {
/>
/>
<td
<td
:id=
"line.right.line_code"
:id=
"line.right.line_code"
:class=
"line.right.type"
:class=
"[
line.right.type,
{
hll: isHighlighted,
},
]"
class="line_content parallel right-side"
class="line_content parallel right-side"
@mousedown.native="handleParallelLineMouseDown"
@mousedown.native="handleParallelLineMouseDown"
v-html="line.right.rich_text"
v-html="line.right.rich_text"
...
...
app/assets/javascripts/diffs/store/actions.js
浏览文件 @
44a0121a
...
@@ -33,6 +33,10 @@ export const fetchDiffFiles = ({ state, commit }) => {
...
@@ -33,6 +33,10 @@ export const fetchDiffFiles = ({ state, commit }) => {
.
then
(
handleLocationHash
);
.
then
(
handleLocationHash
);
};
};
export
const
setHighlightedRow
=
({
commit
},
lineCode
)
=>
{
commit
(
types
.
SET_HIGHLIGHTED_ROW
,
lineCode
);
};
// This is adding line discussions to the actual lines in the diff tree
// This is adding line discussions to the actual lines in the diff tree
// once for parallel and once for inline mode
// once for parallel and once for inline mode
export
const
assignDiscussionsToDiff
=
(
export
const
assignDiscussionsToDiff
=
(
...
@@ -127,7 +131,7 @@ export const loadMoreLines = ({ commit }, options) => {
...
@@ -127,7 +131,7 @@ export const loadMoreLines = ({ commit }, options) => {
export
const
scrollToLineIfNeededInline
=
(
_
,
line
)
=>
{
export
const
scrollToLineIfNeededInline
=
(
_
,
line
)
=>
{
const
hash
=
getLocationHash
();
const
hash
=
getLocationHash
();
if
(
hash
&&
line
.
line
C
ode
===
hash
)
{
if
(
hash
&&
line
.
line
_c
ode
===
hash
)
{
handleLocationHash
();
handleLocationHash
();
}
}
};
};
...
@@ -137,7 +141,7 @@ export const scrollToLineIfNeededParallel = (_, line) => {
...
@@ -137,7 +141,7 @@ export const scrollToLineIfNeededParallel = (_, line) => {
if
(
if
(
hash
&&
hash
&&
((
line
.
left
&&
line
.
left
.
line
Code
===
hash
)
||
(
line
.
right
&&
line
.
right
.
lineC
ode
===
hash
))
((
line
.
left
&&
line
.
left
.
line
_code
===
hash
)
||
(
line
.
right
&&
line
.
right
.
line_c
ode
===
hash
))
)
{
)
{
handleLocationHash
();
handleLocationHash
();
}
}
...
...
app/assets/javascripts/diffs/store/modules/diff_state.js
浏览文件 @
44a0121a
...
@@ -26,4 +26,5 @@ export default () => ({
...
@@ -26,4 +26,5 @@ export default () => ({
currentDiffFileId
:
''
,
currentDiffFileId
:
''
,
projectPath
:
''
,
projectPath
:
''
,
commentForms
:
[],
commentForms
:
[],
highlightedRow
:
null
,
});
});
app/assets/javascripts/diffs/store/mutation_types.js
浏览文件 @
44a0121a
...
@@ -17,3 +17,4 @@ export const UPDATE_CURRENT_DIFF_FILE_ID = 'UPDATE_CURRENT_DIFF_FILE_ID';
...
@@ -17,3 +17,4 @@ export const UPDATE_CURRENT_DIFF_FILE_ID = 'UPDATE_CURRENT_DIFF_FILE_ID';
export
const
OPEN_DIFF_FILE_COMMENT_FORM
=
'
OPEN_DIFF_FILE_COMMENT_FORM
'
;
export
const
OPEN_DIFF_FILE_COMMENT_FORM
=
'
OPEN_DIFF_FILE_COMMENT_FORM
'
;
export
const
UPDATE_DIFF_FILE_COMMENT_FORM
=
'
UPDATE_DIFF_FILE_COMMENT_FORM
'
;
export
const
UPDATE_DIFF_FILE_COMMENT_FORM
=
'
UPDATE_DIFF_FILE_COMMENT_FORM
'
;
export
const
CLOSE_DIFF_FILE_COMMENT_FORM
=
'
CLOSE_DIFF_FILE_COMMENT_FORM
'
;
export
const
CLOSE_DIFF_FILE_COMMENT_FORM
=
'
CLOSE_DIFF_FILE_COMMENT_FORM
'
;
export
const
SET_HIGHLIGHTED_ROW
=
'
SET_HIGHLIGHTED_ROW
'
;
app/assets/javascripts/diffs/store/mutations.js
浏览文件 @
44a0121a
...
@@ -241,4 +241,7 @@ export default {
...
@@ -241,4 +241,7 @@ export default {
[
types
.
CLOSE_DIFF_FILE_COMMENT_FORM
](
state
,
fileHash
)
{
[
types
.
CLOSE_DIFF_FILE_COMMENT_FORM
](
state
,
fileHash
)
{
state
.
commentForms
=
state
.
commentForms
.
filter
(
form
=>
form
.
fileHash
!==
fileHash
);
state
.
commentForms
=
state
.
commentForms
.
filter
(
form
=>
form
.
fileHash
!==
fileHash
);
},
},
[
types
.
SET_HIGHLIGHTED_ROW
](
state
,
lineCode
)
{
state
.
highlightedRow
=
lineCode
;
},
};
};
changelogs/unreleased/48496-merge-request-refactor-does-not-highlight-selected-line.yml
0 → 100644
浏览文件 @
44a0121a
---
title
:
When user clicks linenumber in MR changes, highlight that line
merge_request
:
author
:
type
:
fixed
spec/javascripts/diffs/components/app_spec.js
浏览文件 @
44a0121a
...
@@ -13,6 +13,8 @@ describe('diffs/components/app', () => {
...
@@ -13,6 +13,8 @@ describe('diffs/components/app', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
// setup globals (needed for component to mount :/)
// setup globals (needed for component to mount :/)
window
.
mrTabs
=
jasmine
.
createSpyObj
(
'
mrTabs
'
,
[
'
resetViewContainer
'
]);
window
.
mrTabs
=
jasmine
.
createSpyObj
(
'
mrTabs
'
,
[
'
resetViewContainer
'
]);
window
.
mrTabs
.
expandViewContainer
=
jasmine
.
createSpy
();
window
.
location
.
hash
=
'
ABC_123
'
;
// setup component
// setup component
const
store
=
createDiffsStore
();
const
store
=
createDiffsStore
();
...
@@ -39,4 +41,15 @@ describe('diffs/components/app', () => {
...
@@ -39,4 +41,15 @@ describe('diffs/components/app', () => {
it
(
'
does not show commit info
'
,
()
=>
{
it
(
'
does not show commit info
'
,
()
=>
{
expect
(
vm
.
$el
).
not
.
toContainElement
(
'
.blob-commit-info
'
);
expect
(
vm
.
$el
).
not
.
toContainElement
(
'
.blob-commit-info
'
);
});
});
it
(
'
sets highlighted row if hash exists in location object
'
,
done
=>
{
vm
.
$props
.
shouldShow
=
true
;
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$store
.
state
.
diffs
.
highlightedRow
).
toBe
(
'
ABC_123
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
spec/javascripts/diffs/components/diff_table_cell_spec.js
0 → 100644
浏览文件 @
44a0121a
import
Vue
from
'
vue
'
;
import
store
from
'
~/mr_notes/stores
'
;
import
DiffTableCell
from
'
~/diffs/components/diff_table_cell.vue
'
;
import
{
createComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
diffFileMockData
from
'
../mock_data/diff_file
'
;
describe
(
'
DiffTableCell
'
,
()
=>
{
const
createComponent
=
options
=>
createComponentWithStore
(
Vue
.
extend
(
DiffTableCell
),
store
,
{
line
:
diffFileMockData
.
highlighted_diff_lines
[
0
],
fileHash
:
diffFileMockData
.
file_hash
,
contextLinesPath
:
'
contextLinesPath
'
,
...
options
,
}).
$mount
();
it
(
'
does not highlight row when isHighlighted prop is false
'
,
done
=>
{
const
vm
=
createComponent
({
isHighlighted
:
false
});
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
classList
).
not
.
toContain
(
'
hll
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
highlights row when isHighlighted prop is true
'
,
done
=>
{
const
vm
=
createComponent
({
isHighlighted
:
true
});
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
classList
).
toContain
(
'
hll
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
spec/javascripts/diffs/components/inline_diff_table_row_spec.js
0 → 100644
浏览文件 @
44a0121a
import
Vue
from
'
vue
'
;
import
store
from
'
~/mr_notes/stores
'
;
import
InlineDiffTableRow
from
'
~/diffs/components/inline_diff_table_row.vue
'
;
import
{
createComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
diffFileMockData
from
'
../mock_data/diff_file
'
;
describe
(
'
InlineDiffTableRow
'
,
()
=>
{
let
vm
;
const
thisLine
=
diffFileMockData
.
highlighted_diff_lines
[
0
];
beforeEach
(()
=>
{
vm
=
createComponentWithStore
(
Vue
.
extend
(
InlineDiffTableRow
),
store
,
{
line
:
thisLine
,
fileHash
:
diffFileMockData
.
file_hash
,
contextLinesPath
:
'
contextLinesPath
'
,
isHighlighted
:
false
,
}).
$mount
();
});
it
(
'
does not add hll class to line content when line does not match highlighted row
'
,
done
=>
{
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.line_content
'
).
classList
).
not
.
toContain
(
'
hll
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
adds hll class to lineContent when line is the highlighted row
'
,
done
=>
{
vm
.
$nextTick
()
.
then
(()
=>
{
vm
.
$store
.
state
.
diffs
.
highlightedRow
=
thisLine
.
line_code
;
return
vm
.
$nextTick
();
})
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.line_content
'
).
classList
).
toContain
(
'
hll
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
spec/javascripts/diffs/components/parallel_diff_table_row_spec.js
0 → 100644
浏览文件 @
44a0121a
import
Vue
from
'
vue
'
;
import
{
createStore
}
from
'
~/mr_notes/stores
'
;
import
ParallelDiffTableRow
from
'
~/diffs/components/parallel_diff_table_row.vue
'
;
import
{
createComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
diffFileMockData
from
'
../mock_data/diff_file
'
;
describe
(
'
ParallelDiffTableRow
'
,
()
=>
{
describe
(
'
when one side is empty
'
,
()
=>
{
let
vm
;
const
thisLine
=
diffFileMockData
.
parallel_diff_lines
[
0
];
const
rightLine
=
diffFileMockData
.
parallel_diff_lines
[
0
].
right
;
beforeEach
(()
=>
{
vm
=
createComponentWithStore
(
Vue
.
extend
(
ParallelDiffTableRow
),
createStore
(),
{
line
:
thisLine
,
fileHash
:
diffFileMockData
.
file_hash
,
contextLinesPath
:
'
contextLinesPath
'
,
isHighlighted
:
false
,
}).
$mount
();
});
it
(
'
does not highlight non empty line content when line does not match highlighted row
'
,
done
=>
{
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.line_content.right-side
'
).
classList
).
not
.
toContain
(
'
hll
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
highlights nonempty line content when line is the highlighted row
'
,
done
=>
{
vm
.
$nextTick
()
.
then
(()
=>
{
vm
.
$store
.
state
.
diffs
.
highlightedRow
=
rightLine
.
line_code
;
return
vm
.
$nextTick
();
})
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.line_content.right-side
'
).
classList
).
toContain
(
'
hll
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
when both sides have content
'
,
()
=>
{
let
vm
;
const
thisLine
=
diffFileMockData
.
parallel_diff_lines
[
2
];
const
rightLine
=
diffFileMockData
.
parallel_diff_lines
[
2
].
right
;
beforeEach
(()
=>
{
vm
=
createComponentWithStore
(
Vue
.
extend
(
ParallelDiffTableRow
),
createStore
(),
{
line
:
thisLine
,
fileHash
:
diffFileMockData
.
file_hash
,
contextLinesPath
:
'
contextLinesPath
'
,
isHighlighted
:
false
,
}).
$mount
();
});
it
(
'
does not highlight either line when line does not match highlighted row
'
,
done
=>
{
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.line_content.right-side
'
).
classList
).
not
.
toContain
(
'
hll
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.line_content.left-side
'
).
classList
).
not
.
toContain
(
'
hll
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
adds hll class to lineContent when line is the highlighted row
'
,
done
=>
{
vm
.
$nextTick
()
.
then
(()
=>
{
vm
.
$store
.
state
.
diffs
.
highlightedRow
=
rightLine
.
line_code
;
return
vm
.
$nextTick
();
})
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.line_content.right-side
'
).
classList
).
toContain
(
'
hll
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.line_content.left-side
'
).
classList
).
toContain
(
'
hll
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
spec/javascripts/diffs/store/actions_spec.js
浏览文件 @
44a0121a
...
@@ -22,6 +22,7 @@ import actions, {
...
@@ -22,6 +22,7 @@ import actions, {
expandAllFiles
,
expandAllFiles
,
toggleFileDiscussions
,
toggleFileDiscussions
,
saveDiffDiscussion
,
saveDiffDiscussion
,
setHighlightedRow
,
toggleTreeOpen
,
toggleTreeOpen
,
scrollToFile
,
scrollToFile
,
toggleShowTreeList
,
toggleShowTreeList
,
...
@@ -92,6 +93,14 @@ describe('DiffsStoreActions', () => {
...
@@ -92,6 +93,14 @@ describe('DiffsStoreActions', () => {
});
});
});
});
describe
(
'
setHighlightedRow
'
,
()
=>
{
it
(
'
should set lineHash and fileHash of highlightedRow
'
,
()
=>
{
testAction
(
setHighlightedRow
,
'
ABC_123
'
,
{},
[
{
type
:
types
.
SET_HIGHLIGHTED_ROW
,
payload
:
'
ABC_123
'
},
]);
});
});
describe
(
'
assignDiscussionsToDiff
'
,
()
=>
{
describe
(
'
assignDiscussionsToDiff
'
,
()
=>
{
it
(
'
should merge discussions into diffs
'
,
done
=>
{
it
(
'
should merge discussions into diffs
'
,
done
=>
{
const
state
=
{
const
state
=
{
...
@@ -469,7 +478,7 @@ describe('DiffsStoreActions', () => {
...
@@ -469,7 +478,7 @@ describe('DiffsStoreActions', () => {
describe
(
'
scrollToLineIfNeededInline
'
,
()
=>
{
describe
(
'
scrollToLineIfNeededInline
'
,
()
=>
{
const
lineMock
=
{
const
lineMock
=
{
line
C
ode
:
'
ABC_123
'
,
line
_c
ode
:
'
ABC_123
'
,
};
};
it
(
'
should not call handleLocationHash when there is not hash
'
,
()
=>
{
it
(
'
should not call handleLocationHash when there is not hash
'
,
()
=>
{
...
@@ -520,7 +529,7 @@ describe('DiffsStoreActions', () => {
...
@@ -520,7 +529,7 @@ describe('DiffsStoreActions', () => {
const
lineMock
=
{
const
lineMock
=
{
left
:
null
,
left
:
null
,
right
:
{
right
:
{
line
C
ode
:
'
ABC_123
'
,
line
_c
ode
:
'
ABC_123
'
,
},
},
};
};
...
...
spec/javascripts/diffs/store/mutations_spec.js
浏览文件 @
44a0121a
...
@@ -360,6 +360,16 @@ describe('DiffsStoreMutations', () => {
...
@@ -360,6 +360,16 @@ describe('DiffsStoreMutations', () => {
});
});
});
});
describe
(
'
Set highlighted row
'
,
()
=>
{
it
(
'
sets highlighted row
'
,
()
=>
{
const
state
=
createState
();
mutations
[
types
.
SET_HIGHLIGHTED_ROW
](
state
,
'
ABC_123
'
);
expect
(
state
.
highlightedRow
).
toBe
(
'
ABC_123
'
);
});
});
describe
(
'
TOGGLE_LINE_HAS_FORM
'
,
()
=>
{
describe
(
'
TOGGLE_LINE_HAS_FORM
'
,
()
=>
{
it
(
'
sets hasForm on lines
'
,
()
=>
{
it
(
'
sets hasForm on lines
'
,
()
=>
{
const
file
=
{
const
file
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录