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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
720a0bdb
Commit
720a0bdb
authored
Aug 14, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up karma tests
parent
3168b2d9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
48 deletions
+41
-48
app/assets/javascripts/repo/components/repo_commit_section.vue
...ssets/javascripts/repo/components/repo_commit_section.vue
+4
-4
spec/javascripts/repo/components/repo_commit_section_spec.js
spec/javascripts/repo/components/repo_commit_section_spec.js
+30
-27
spec/javascripts/repo/components/repo_edit_button_spec.js
spec/javascripts/repo/components/repo_edit_button_spec.js
+7
-9
spec/javascripts/repo/components/repo_file_buttons_spec.js
spec/javascripts/repo/components/repo_file_buttons_spec.js
+0
-8
No files found.
app/assets/javascripts/repo/components/repo_commit_section.vue
View file @
720a0bdb
...
@@ -10,7 +10,6 @@ const RepoCommitSection = {
...
@@ -10,7 +10,6 @@ const RepoCommitSection = {
mixins
:
[
RepoMixin
],
mixins
:
[
RepoMixin
],
computed
:
{
computed
:
{
showCommitable
()
{
showCommitable
()
{
return
this
.
isCommitable
&&
this
.
changedFiles
.
length
;
return
this
.
isCommitable
&&
this
.
changedFiles
.
length
;
},
},
...
@@ -73,9 +72,9 @@ export default RepoCommitSection;
...
@@ -73,9 +72,9 @@ export default RepoCommitSection;
</label>
</label>
<div
class=
"col-md-6"
>
<div
class=
"col-md-6"
>
<ul
class=
"list-unstyled changed-files"
>
<ul
class=
"list-unstyled changed-files"
>
<li
v-for=
"
file in branchPaths"
:key=
"file.id
"
>
<li
v-for=
"
branchPath in branchPaths"
:key=
"branchPath
"
>
<span
class=
"help-block"
>
<span
class=
"help-block"
>
{{
file
}}
{{
branchPath
}}
</span>
</span>
</li>
</li>
</ul>
</ul>
...
@@ -110,9 +109,10 @@ export default RepoCommitSection;
...
@@ -110,9 +109,10 @@ export default RepoCommitSection;
</div>
</div>
<div
class=
"col-md-offset-4 col-md-6"
>
<div
class=
"col-md-offset-4 col-md-6"
>
<button
<button
ref=
"submitCommit"
type=
"submit"
type=
"submit"
:disabled=
"cantCommitYet"
:disabled=
"cantCommitYet"
class=
"btn btn-success
submit-commit
"
>
class=
"btn btn-success"
>
<i
<i
v-if=
"submitCommitsLoading"
v-if=
"submitCommitsLoading"
class=
"fa fa-spinner fa-spin"
class=
"fa fa-spinner fa-spin"
...
...
spec/javascripts/repo/components/repo_commit_section_spec.js
View file @
720a0bdb
...
@@ -7,51 +7,52 @@ import Api from '~/api';
...
@@ -7,51 +7,52 @@ import Api from '~/api';
describe
(
'
RepoCommitSection
'
,
()
=>
{
describe
(
'
RepoCommitSection
'
,
()
=>
{
const
branch
=
'
master
'
;
const
branch
=
'
master
'
;
const
projectUrl
=
'
projectUrl
'
;
const
projectUrl
=
'
projectUrl
'
;
const
open
edFiles
=
[{
const
chang
edFiles
=
[{
id
:
0
,
id
:
0
,
changed
:
true
,
changed
:
true
,
url
:
`/namespace/
${
projectUrl
}
/blob/
${
branch
}
/dir/file0.ext`
,
url
:
`/namespace/
${
projectUrl
}
/blob/
${
branch
}
/dir/file0.ext`
,
path
:
'
dir/file0.ext
'
,
newContent
:
'
a
'
,
newContent
:
'
a
'
,
},
{
},
{
id
:
1
,
id
:
1
,
changed
:
true
,
changed
:
true
,
url
:
`/namespace/
${
projectUrl
}
/blob/
${
branch
}
/dir/file1.ext`
,
url
:
`/namespace/
${
projectUrl
}
/blob/
${
branch
}
/dir/file1.ext`
,
path
:
'
dir/file1.ext
'
,
newContent
:
'
b
'
,
newContent
:
'
b
'
,
},
{
}];
const
openedFiles
=
changedFiles
.
concat
([{
id
:
2
,
id
:
2
,
url
:
`/namespace/
${
projectUrl
}
/blob/
${
branch
}
/dir/file2.ext`
,
url
:
`/namespace/
${
projectUrl
}
/blob/
${
branch
}
/dir/file2.ext`
,
path
:
'
dir/file2.ext
'
,
changed
:
false
,
changed
:
false
,
}];
}]
)
;
RepoStore
.
projectUrl
=
projectUrl
;
RepoStore
.
projectUrl
=
projectUrl
;
function
createComponent
()
{
function
createComponent
(
el
)
{
const
RepoCommitSection
=
Vue
.
extend
(
repoCommitSection
);
const
RepoCommitSection
=
Vue
.
extend
(
repoCommitSection
);
return
new
RepoCommitSection
().
$mount
();
return
new
RepoCommitSection
().
$mount
(
el
);
}
}
it
(
'
renders a commit section
'
,
()
=>
{
it
(
'
renders a commit section
'
,
()
=>
{
RepoStore
.
isCommitable
=
true
;
RepoStore
.
isCommitable
=
true
;
RepoStore
.
currentBranch
=
branch
;
RepoStore
.
targetBranch
=
branch
;
RepoStore
.
targetBranch
=
branch
;
RepoStore
.
openedFiles
=
openedFiles
;
RepoStore
.
openedFiles
=
openedFiles
;
spyOn
(
RepoHelper
,
'
getBranch
'
).
and
.
returnValue
(
branch
);
const
vm
=
createComponent
();
const
vm
=
createComponent
();
const
changedFiles
=
[...
vm
.
$el
.
querySelectorAll
(
'
.changed-files > li
'
)];
const
changedFile
Element
s
=
[...
vm
.
$el
.
querySelectorAll
(
'
.changed-files > li
'
)];
const
commitMessage
=
vm
.
$el
.
querySelector
(
'
#commit-message
'
);
const
commitMessage
=
vm
.
$el
.
querySelector
(
'
#commit-message
'
);
const
submitCommit
=
vm
.
$
el
.
querySelector
(
'
.submit-commit
'
)
;
const
submitCommit
=
vm
.
$
refs
.
submitCommit
;
const
targetBranch
=
vm
.
$el
.
querySelector
(
'
.target-branch
'
);
const
targetBranch
=
vm
.
$el
.
querySelector
(
'
.target-branch
'
);
expect
(
vm
.
$el
.
querySelector
(
'
:scope > form
'
)).
toBeTruthy
();
expect
(
vm
.
$el
.
querySelector
(
'
:scope > form
'
)).
toBeTruthy
();
expect
(
vm
.
$el
.
querySelector
(
'
.staged-files
'
).
textContent
).
toEqual
(
'
Staged files (2)
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.staged-files
'
).
textContent
.
trim
()
).
toEqual
(
'
Staged files (2)
'
);
expect
(
changedFiles
.
length
).
toEqual
(
2
);
expect
(
changedFile
Element
s
.
length
).
toEqual
(
2
);
changedFiles
.
forEach
((
changedFile
,
i
)
=>
{
changedFileElements
.
forEach
((
changedFile
,
i
)
=>
{
const
filePath
=
RepoHelper
.
getFilePathFromFullPath
(
openedFiles
[
i
].
url
,
branch
);
expect
(
changedFile
.
textContent
.
trim
()).
toEqual
(
changedFiles
[
i
].
path
);
expect
(
changedFile
.
textContent
).
toEqual
(
filePath
);
});
});
expect
(
commitMessage
.
tagName
).
toEqual
(
'
TEXTAREA
'
);
expect
(
commitMessage
.
tagName
).
toEqual
(
'
TEXTAREA
'
);
...
@@ -59,9 +60,9 @@ describe('RepoCommitSection', () => {
...
@@ -59,9 +60,9 @@ describe('RepoCommitSection', () => {
expect
(
submitCommit
.
type
).
toEqual
(
'
submit
'
);
expect
(
submitCommit
.
type
).
toEqual
(
'
submit
'
);
expect
(
submitCommit
.
disabled
).
toBeTruthy
();
expect
(
submitCommit
.
disabled
).
toBeTruthy
();
expect
(
submitCommit
.
querySelector
(
'
.fa-spinner.fa-spin
'
)).
toBeFalsy
();
expect
(
submitCommit
.
querySelector
(
'
.fa-spinner.fa-spin
'
)).
toBeFalsy
();
expect
(
vm
.
$el
.
querySelector
(
'
.commit-summary
'
).
textContent
).
toEqual
(
'
Commit 2 files
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.commit-summary
'
).
textContent
.
trim
()
).
toEqual
(
'
Commit 2 files
'
);
expect
(
targetBranch
.
querySelector
(
'
:scope > label
'
).
textContent
).
toEqual
(
'
Target branch
'
);
expect
(
targetBranch
.
querySelector
(
'
:scope > label
'
).
textContent
.
trim
()
).
toEqual
(
'
Target branch
'
);
expect
(
targetBranch
.
querySelector
(
'
.help-block
'
).
textContent
).
toEqual
(
branch
);
expect
(
targetBranch
.
querySelector
(
'
.help-block
'
).
textContent
.
trim
()
).
toEqual
(
branch
);
});
});
it
(
'
does not render if not isCommitable
'
,
()
=>
{
it
(
'
does not render if not isCommitable
'
,
()
=>
{
...
@@ -89,14 +90,20 @@ describe('RepoCommitSection', () => {
...
@@ -89,14 +90,20 @@ describe('RepoCommitSection', () => {
const
projectId
=
'
projectId
'
;
const
projectId
=
'
projectId
'
;
const
commitMessage
=
'
commitMessage
'
;
const
commitMessage
=
'
commitMessage
'
;
RepoStore
.
isCommitable
=
true
;
RepoStore
.
isCommitable
=
true
;
RepoStore
.
currentBranch
=
branch
;
RepoStore
.
targetBranch
=
branch
;
RepoStore
.
openedFiles
=
openedFiles
;
RepoStore
.
openedFiles
=
openedFiles
;
RepoStore
.
projectId
=
projectId
;
RepoStore
.
projectId
=
projectId
;
spyOn
(
RepoHelper
,
'
getBranch
'
).
and
.
returnValue
(
branch
);
// We need to append to body to get form `submit` events working
// Otherwise we run into, "Form submission canceled because the form is not connected"
// See https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-algorithm
const
el
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
el
);
const
vm
=
createComponent
();
const
vm
=
createComponent
(
el
);
const
commitMessageEl
=
vm
.
$el
.
querySelector
(
'
#commit-message
'
);
const
commitMessageEl
=
vm
.
$el
.
querySelector
(
'
#commit-message
'
);
const
submitCommit
=
vm
.
$
el
.
querySelector
(
'
.submit-commit
'
)
;
const
submitCommit
=
vm
.
$
refs
.
submitCommit
;
vm
.
commitMessage
=
commitMessage
;
vm
.
commitMessage
=
commitMessage
;
...
@@ -124,10 +131,8 @@ describe('RepoCommitSection', () => {
...
@@ -124,10 +131,8 @@ describe('RepoCommitSection', () => {
expect
(
actions
[
1
].
action
).
toEqual
(
'
update
'
);
expect
(
actions
[
1
].
action
).
toEqual
(
'
update
'
);
expect
(
actions
[
0
].
content
).
toEqual
(
openedFiles
[
0
].
newContent
);
expect
(
actions
[
0
].
content
).
toEqual
(
openedFiles
[
0
].
newContent
);
expect
(
actions
[
1
].
content
).
toEqual
(
openedFiles
[
1
].
newContent
);
expect
(
actions
[
1
].
content
).
toEqual
(
openedFiles
[
1
].
newContent
);
expect
(
actions
[
0
].
file_path
)
expect
(
actions
[
0
].
file_path
).
toEqual
(
openedFiles
[
0
].
path
);
.
toEqual
(
RepoHelper
.
getFilePathFromFullPath
(
openedFiles
[
0
].
url
,
branch
));
expect
(
actions
[
1
].
file_path
).
toEqual
(
openedFiles
[
1
].
path
);
expect
(
actions
[
1
].
file_path
)
.
toEqual
(
RepoHelper
.
getFilePathFromFullPath
(
openedFiles
[
1
].
url
,
branch
));
done
();
done
();
});
});
...
@@ -140,7 +145,6 @@ describe('RepoCommitSection', () => {
...
@@ -140,7 +145,6 @@ describe('RepoCommitSection', () => {
const
vm
=
{
const
vm
=
{
submitCommitsLoading
:
true
,
submitCommitsLoading
:
true
,
changedFiles
:
new
Array
(
10
),
changedFiles
:
new
Array
(
10
),
openedFiles
:
new
Array
(
10
),
commitMessage
:
'
commitMessage
'
,
commitMessage
:
'
commitMessage
'
,
editMode
:
true
,
editMode
:
true
,
};
};
...
@@ -149,7 +153,6 @@ describe('RepoCommitSection', () => {
...
@@ -149,7 +153,6 @@ describe('RepoCommitSection', () => {
expect
(
vm
.
submitCommitsLoading
).
toEqual
(
false
);
expect
(
vm
.
submitCommitsLoading
).
toEqual
(
false
);
expect
(
vm
.
changedFiles
).
toEqual
([]);
expect
(
vm
.
changedFiles
).
toEqual
([]);
expect
(
vm
.
openedFiles
).
toEqual
([]);
expect
(
vm
.
commitMessage
).
toEqual
(
''
);
expect
(
vm
.
commitMessage
).
toEqual
(
''
);
expect
(
vm
.
editMode
).
toEqual
(
false
);
expect
(
vm
.
editMode
).
toEqual
(
false
);
});
});
...
...
spec/javascripts/repo/components/repo_edit_button_spec.js
View file @
720a0bdb
...
@@ -12,18 +12,20 @@ describe('RepoEditButton', () => {
...
@@ -12,18 +12,20 @@ describe('RepoEditButton', () => {
it
(
'
renders an edit button that toggles the view state
'
,
(
done
)
=>
{
it
(
'
renders an edit button that toggles the view state
'
,
(
done
)
=>
{
RepoStore
.
isCommitable
=
true
;
RepoStore
.
isCommitable
=
true
;
RepoStore
.
changedFiles
=
[];
RepoStore
.
changedFiles
=
[];
RepoStore
.
binary
=
false
;
RepoStore
.
openedFiles
=
[{},
{}];
const
vm
=
createComponent
();
const
vm
=
createComponent
();
expect
(
vm
.
$el
.
tagName
).
toEqual
(
'
BUTTON
'
);
expect
(
vm
.
$el
.
tagName
).
toEqual
(
'
BUTTON
'
);
expect
(
vm
.
$el
.
textContent
).
toMatch
(
'
Edit
'
);
expect
(
vm
.
$el
.
textContent
).
toMatch
(
'
Edit
'
);
spyOn
(
vm
,
'
editClicked
'
).
and
.
callThrough
();
spyOn
(
vm
,
'
editC
ancelC
licked
'
).
and
.
callThrough
();
vm
.
$el
.
click
();
vm
.
$el
.
click
();
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
editClicked
).
toHaveBeenCalled
();
expect
(
vm
.
editC
ancelC
licked
).
toHaveBeenCalled
();
expect
(
vm
.
$el
.
textContent
).
toMatch
(
'
Cancel edit
'
);
expect
(
vm
.
$el
.
textContent
).
toMatch
(
'
Cancel edit
'
);
done
();
done
();
});
});
...
@@ -38,14 +40,10 @@ describe('RepoEditButton', () => {
...
@@ -38,14 +40,10 @@ describe('RepoEditButton', () => {
});
});
describe
(
'
methods
'
,
()
=>
{
describe
(
'
methods
'
,
()
=>
{
describe
(
'
editClicked
'
,
()
=>
{
describe
(
'
editC
ancelC
licked
'
,
()
=>
{
it
(
'
sets dialog to open when there are changedFiles
'
,
()
=>
{
it
(
'
sets dialog to open when there are changedFiles
'
);
});
it
(
'
toggles editMode and calls toggleBlobView
'
);
it
(
'
toggles editMode and calls toggleBlobView
'
,
()
=>
{
});
});
});
});
});
});
});
spec/javascripts/repo/components/repo_file_buttons_spec.js
View file @
720a0bdb
...
@@ -71,12 +71,4 @@ describe('RepoFileButtons', () => {
...
@@ -71,12 +71,4 @@ describe('RepoFileButtons', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.preview
'
)).
toBeFalsy
();
expect
(
vm
.
$el
.
querySelector
(
'
.preview
'
)).
toBeFalsy
();
});
});
it
(
'
does not render if not isMini
'
,
()
=>
{
RepoStore
.
openedFiles
=
[];
const
vm
=
createComponent
();
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