Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
b259c6e6
Commit
b259c6e6
authored
Jul 25, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add repo file buttons spec
parent
5e0f5f17
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
24 deletions
+80
-24
app/assets/javascripts/repo/repo_file_buttons.vue
app/assets/javascripts/repo/repo_file_buttons.vue
+11
-13
spec/javascripts/repo/repo_editor_spec.js
spec/javascripts/repo/repo_editor_spec.js
+2
-4
spec/javascripts/repo/repo_file_buttons_spec.js
spec/javascripts/repo/repo_file_buttons_spec.js
+67
-7
No files found.
app/assets/javascripts/repo/repo_file_buttons.vue
View file @
b259c6e6
...
...
@@ -11,7 +11,7 @@ const RepoFileButtons = {
computed
:
{
editableBorder
()
{
return
this
.
editMode
?
'
1px solid
#1F78D1
'
:
'
1px solid #f0f0f0
'
;
return
this
.
editMode
?
'
1px solid
rgb(31, 120, 209)
'
:
'
1px solid rgb(240,240,240)
'
;
},
canPreview
()
{
...
...
@@ -22,11 +22,11 @@ const RepoFileButtons = {
return
Helper
.
getRawURLFromBlobURL
(
this
.
activeFile
.
url
);
},
blameFileU
rl
()
{
blameFileU
RL
()
{
return
Helper
.
getBlameURLFromBlobURL
(
this
.
activeFile
.
url
);
},
historyFileU
rl
()
{
historyFileU
RL
()
{
return
Helper
.
getHistoryURLFromBlobURL
(
this
.
activeFile
.
url
);
},
},
...
...
@@ -41,21 +41,19 @@ export default RepoFileButtons;
<
template
>
<div
id=
"repo-file-buttons"
v-if=
"isMini"
:style=
"
{'border-bottom': editableBorder}">
<a
:href=
"rawFileURL"
target=
"_blank"
class=
"btn btn-default"
>
Raw
</a>
<a
:href=
"rawFileURL"
target=
"_blank"
class=
"btn btn-default
raw
"
>
Raw
</a>
<div
class=
"btn-group"
role=
"group"
aria-label=
"File actions"
>
<a
:href=
"blameFileU
rl"
class=
"btn btn-default
"
>
Blame
</a>
<a
:href=
"historyFileU
rl"
class=
"btn btn-default
"
>
History
</a>
<a
href=
"#"
class=
"btn btn-default"
>
Permalink
</a>
<a
href=
"#"
class=
"btn btn-default"
>
Lock
</a>
<a
:href=
"blameFileU
RL"
class=
"btn btn-default blame
"
>
Blame
</a>
<a
:href=
"historyFileU
RL"
class=
"btn btn-default history
"
>
History
</a>
<a
href=
"#"
class=
"btn btn-default
permalink
"
>
Permalink
</a>
<a
href=
"#"
class=
"btn btn-default
lock
"
>
Lock
</a>
</div>
<a
href=
"#"
v-if=
"canPreview"
@
click.prevent=
"rawPreviewToggle"
class=
"btn btn-default"
>
{{
activeFileLabel
}}
</a>
<a
href=
"#"
v-if=
"canPreview"
@
click.prevent=
"rawPreviewToggle"
class=
"btn btn-default preview"
>
{{
activeFileLabel
}}
</a>
<button
type=
"button"
class=
"btn btn-default"
data-target=
"#modal-upload-blob"
data-toggle=
"modal"
>
Replace
</button>
<button
type=
"button"
class=
"btn btn-default
replace
"
data-target=
"#modal-upload-blob"
data-toggle=
"modal"
>
Replace
</button>
<a
href=
"#"
class=
"btn btn-danger"
>
Delete
</a>
<a
href=
"#"
class=
"btn btn-danger
delete
"
>
Delete
</a>
</div>
</
template
>
spec/javascripts/repo/repo_editor_spec.js
View file @
b259c6e6
import
Vue
from
'
vue
'
;
import
repoEditor
from
'
~/repo/repo_editor.vue
'
;
f
describe
(
'
RepoEditor
'
,
()
=>
{
describe
(
'
RepoEditor
'
,
()
=>
{
const
RepoEditor
=
Vue
.
extend
(
repoEditor
);
function
createComponent
()
{
...
...
@@ -11,8 +11,6 @@ fdescribe('RepoEditor', () => {
it
(
'
renders an ide container
'
,
()
=>
{
const
vm
=
createComponent
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
getElementById
(
'
ide
'
)).
toBeTruthy
();
});
expect
(
vm
.
$el
.
id
).
toEqual
(
'
ide
'
);
});
});
spec/javascripts/repo/repo_file_buttons_spec.js
View file @
b259c6e6
import
Vue
from
'
vue
'
;
import
repoFileButtons
from
'
~/repo/repo_file_buttons.vue
'
;
import
RepoStore
from
'
~/repo/repo_store
'
;
fdescribe
(
'
RepoFileButtons
'
,
()
=>
{
const
RepoFileButtons
=
Vue
.
extend
(
repoFileButtons
);
describe
(
'
RepoFileButtons
'
,
()
=>
{
function
createComponent
()
{
const
RepoFileButtons
=
Vue
.
extend
(
repoFileButtons
);
return
new
RepoFileButtons
().
$mount
();
}
it
(
'
renders Raw, Blame, History, Permalink, Lock, Preview toggle, Replace and Delete
'
,
()
=>
{
const
activeFile
=
{
extension
:
'
md
'
,
url
:
'
url
'
,
};
const
activeFileLabel
=
'
activeFileLabel
'
;
RepoStore
.
openedFiles
=
new
Array
(
1
);
RepoStore
.
activeFile
=
activeFile
;
RepoStore
.
activeFileLabel
=
activeFileLabel
;
RepoStore
.
editMode
=
true
;
const
vm
=
createComponent
();
const
raw
=
vm
.
$el
.
querySelector
(
'
.raw
'
);
const
blame
=
vm
.
$el
.
querySelector
(
'
.blame
'
);
const
history
=
vm
.
$el
.
querySelector
(
'
.history
'
);
const
permalink
=
vm
.
$el
.
querySelector
(
'
.permalink
'
);
const
lock
=
vm
.
$el
.
querySelector
(
'
.lock
'
);
const
preview
=
vm
.
$el
.
querySelector
(
'
.preview
'
);
const
replace
=
vm
.
$el
.
querySelector
(
'
.replace
'
);
const
deleteBtn
=
vm
.
$el
.
querySelector
(
'
.delete
'
);
expect
(
vm
.
$el
.
id
).
toEqual
(
'
repo-file-buttons
'
);
expect
(
vm
.
$el
.
style
.
borderBottom
).
toEqual
(
'
1px solid rgb(31, 120, 209)
'
);
expect
(
raw
).
toBeTruthy
();
expect
(
raw
.
href
).
toMatch
(
`/
${
activeFile
.
url
}
`
);
expect
(
raw
.
textContent
).
toEqual
(
'
Raw
'
);
expect
(
blame
).
toBeTruthy
();
expect
(
blame
.
href
).
toMatch
(
`/
${
activeFile
.
url
}
`
);
expect
(
blame
.
textContent
).
toEqual
(
'
Blame
'
);
expect
(
history
).
toBeTruthy
();
expect
(
history
.
href
).
toMatch
(
`/
${
activeFile
.
url
}
`
);
expect
(
history
.
textContent
).
toEqual
(
'
History
'
);
expect
(
permalink
).
toBeTruthy
();
expect
(
permalink
.
textContent
).
toEqual
(
'
Permalink
'
);
expect
(
lock
).
toBeTruthy
();
expect
(
lock
.
textContent
).
toEqual
(
'
Lock
'
);
expect
(
preview
).
toBeTruthy
();
expect
(
preview
.
textContent
).
toEqual
(
activeFileLabel
);
expect
(
replace
).
toBeTruthy
();
expect
(
replace
.
dataset
.
target
).
toEqual
(
'
#modal-upload-blob
'
);
expect
(
replace
.
dataset
.
toggle
).
toEqual
(
'
modal
'
);
expect
(
replace
.
textContent
).
toEqual
(
'
Replace
'
);
expect
(
deleteBtn
).
toBeTruthy
();
expect
(
deleteBtn
.
textContent
).
toEqual
(
'
Delete
'
);
});
it
(
'
does not render preview toggle if not canPreview
'
,
()
=>
{
const
activeFile
=
{
extension
:
'
abcd
'
,
url
:
'
url
'
,
};
RepoStore
.
openedFiles
=
new
Array
(
1
);
RepoStore
.
activeFile
=
activeFile
;
const
vm
=
createComponent
();
expect
(
vm
.
$el
.
querySelector
(
'
.preview
'
)).
toBeFalsy
();
});
it
(
'
does not render if not isMini
'
,
()
=>
{
const
vm
=
createComponent
({});
RepoStore
.
openedFiles
=
[];
const
vm
=
createComponent
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
getElementById
(
'
ide
'
)).
toBeTruthy
();
});
expect
(
vm
.
$el
.
innerHTML
).
toBeFalsy
();
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment