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
133e66d2
Commit
133e66d2
authored
Oct 23, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spec fixes
parent
fe1871b5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
139 deletions
+146
-139
app/assets/javascripts/repo/components/new_dropdown/index.vue
...assets/javascripts/repo/components/new_dropdown/index.vue
+1
-1
spec/javascripts/repo/components/new_dropdown/index_spec.js
spec/javascripts/repo/components/new_dropdown/index_spec.js
+128
-0
spec/javascripts/repo/components/new_dropdown/modal_spec.js
spec/javascripts/repo/components/new_dropdown/modal_spec.js
+17
-137
spec/javascripts/repo/components/repo_file_buttons_spec.js
spec/javascripts/repo/components/repo_file_buttons_spec.js
+0
-1
No files found.
app/assets/javascripts/repo/components/new_dropdown/index.vue
View file @
133e66d2
<
script
>
<
script
>
import
RepoHelper
from
'
../../helpers/repo_helper
'
;
import
RepoStore
from
'
../../stores/repo_store
'
;
import
RepoStore
from
'
../../stores/repo_store
'
;
import
RepoHelper
from
'
../../helpers/repo_helper
'
;
import
eventHub
from
'
../../event_hub
'
;
import
eventHub
from
'
../../event_hub
'
;
import
newModal
from
'
./modal.vue
'
;
import
newModal
from
'
./modal.vue
'
;
...
...
spec/javascripts/repo/components/new_dropdown/index_spec.js
View file @
133e66d2
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
newDropdown
from
'
~/repo/components/new_dropdown/index.vue
'
;
import
newDropdown
from
'
~/repo/components/new_dropdown/index.vue
'
;
import
RepoStore
from
'
~/repo/stores/repo_store
'
;
import
RepoHelper
from
'
~/repo/helpers/repo_helper
'
;
import
eventHub
from
'
~/repo/event_hub
'
;
import
createComponent
from
'
../../../helpers/vue_mount_component_helper
'
;
import
createComponent
from
'
../../../helpers/vue_mount_component_helper
'
;
describe
(
'
new dropdown component
'
,
()
=>
{
describe
(
'
new dropdown component
'
,
()
=>
{
...
@@ -13,6 +16,10 @@ describe('new dropdown component', () => {
...
@@ -13,6 +16,10 @@ describe('new dropdown component', () => {
afterEach
(()
=>
{
afterEach
(()
=>
{
vm
.
$destroy
();
vm
.
$destroy
();
RepoStore
.
files
=
[];
RepoStore
.
openedFiles
=
[];
RepoStore
.
setViewToPreview
();
});
});
it
(
'
renders new file and new directory links
'
,
()
=>
{
it
(
'
renders new file and new directory links
'
,
()
=>
{
...
@@ -60,4 +67,125 @@ describe('new dropdown component', () => {
...
@@ -60,4 +67,125 @@ describe('new dropdown component', () => {
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
createEntryInStore
'
,
()
=>
{
[
'
tree
'
,
'
blob
'
].
forEach
((
type
)
=>
{
describe
(
type
,
()
=>
{
it
(
'
closes modal after creating file
'
,
()
=>
{
vm
.
openModal
=
true
;
eventHub
.
$emit
(
'
createNewEntry
'
,
'
testing
'
,
type
);
expect
(
vm
.
openModal
).
toBeFalsy
();
});
it
(
'
sets editMode to true
'
,
()
=>
{
eventHub
.
$emit
(
'
createNewEntry
'
,
'
testing
'
,
type
);
expect
(
RepoStore
.
editMode
).
toBeTruthy
();
});
it
(
'
toggles blob view
'
,
()
=>
{
eventHub
.
$emit
(
'
createNewEntry
'
,
'
testing
'
,
type
);
expect
(
RepoStore
.
isPreviewView
()).
toBeFalsy
();
});
it
(
'
adds file into activeFiles
'
,
()
=>
{
eventHub
.
$emit
(
'
createNewEntry
'
,
'
testing
'
,
type
);
expect
(
RepoStore
.
openedFiles
.
length
).
toBe
(
1
);
});
it
(
`creates
${
type
}
in the current stores path`
,
()
=>
{
RepoStore
.
path
=
'
testing
'
;
eventHub
.
$emit
(
'
createNewEntry
'
,
'
testing/app
'
,
type
);
expect
(
RepoStore
.
files
[
0
].
path
).
toBe
(
'
testing/app
'
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
app
'
);
if
(
type
===
'
tree
'
)
{
expect
(
RepoStore
.
files
[
0
].
files
.
length
).
toBe
(
1
);
}
RepoStore
.
path
=
''
;
});
});
});
describe
(
'
file
'
,
()
=>
{
it
(
'
creates new file
'
,
()
=>
{
eventHub
.
$emit
(
'
createNewEntry
'
,
'
testing
'
,
'
blob
'
);
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
testing
'
);
expect
(
RepoStore
.
files
[
0
].
type
).
toBe
(
'
blob
'
);
expect
(
RepoStore
.
files
[
0
].
tempFile
).
toBeTruthy
();
});
it
(
'
does not create temp file when file already exists
'
,
()
=>
{
RepoStore
.
files
.
push
(
RepoHelper
.
serializeRepoEntity
(
'
blob
'
,
{
name
:
'
testing
'
,
}));
eventHub
.
$emit
(
'
createNewEntry
'
,
'
testing
'
,
'
blob
'
);
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
testing
'
);
expect
(
RepoStore
.
files
[
0
].
type
).
toBe
(
'
blob
'
);
expect
(
RepoStore
.
files
[
0
].
tempFile
).
toBeUndefined
();
});
});
describe
(
'
tree
'
,
()
=>
{
it
(
'
creates new tree
'
,
()
=>
{
eventHub
.
$emit
(
'
createNewEntry
'
,
'
testing
'
,
'
tree
'
);
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
testing
'
);
expect
(
RepoStore
.
files
[
0
].
type
).
toBe
(
'
tree
'
);
expect
(
RepoStore
.
files
[
0
].
tempFile
).
toBeTruthy
();
expect
(
RepoStore
.
files
[
0
].
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
name
).
toBe
(
'
.gitkeep
'
);
});
it
(
'
creates multiple trees when entryName has slashes
'
,
()
=>
{
eventHub
.
$emit
(
'
createNewEntry
'
,
'
app/test
'
,
'
tree
'
);
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
app
'
);
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
name
).
toBe
(
'
test
'
);
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
files
[
0
].
name
).
toBe
(
'
.gitkeep
'
);
});
it
(
'
creates tree in existing tree
'
,
()
=>
{
RepoStore
.
files
.
push
(
RepoHelper
.
serializeRepoEntity
(
'
tree
'
,
{
name
:
'
app
'
,
}));
eventHub
.
$emit
(
'
createNewEntry
'
,
'
app/test
'
,
'
tree
'
);
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
app
'
);
expect
(
RepoStore
.
files
[
0
].
tempFile
).
toBeUndefined
();
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
tempFile
).
toBeTruthy
();
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
name
).
toBe
(
'
test
'
);
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
files
[
0
].
name
).
toBe
(
'
.gitkeep
'
);
});
it
(
'
does not create new tree when already exists
'
,
()
=>
{
RepoStore
.
files
.
push
(
RepoHelper
.
serializeRepoEntity
(
'
tree
'
,
{
name
:
'
app
'
,
}));
eventHub
.
$emit
(
'
createNewEntry
'
,
'
app
'
,
'
tree
'
);
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
app
'
);
expect
(
RepoStore
.
files
[
0
].
tempFile
).
toBeUndefined
();
expect
(
RepoStore
.
files
[
0
].
files
.
length
).
toBe
(
0
);
});
});
});
});
});
spec/javascripts/repo/components/new_dropdown/modal_spec.js
View file @
133e66d2
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
RepoStore
from
'
~/repo/stores/repo_store
'
;
import
RepoStore
from
'
~/repo/stores/repo_store
'
;
import
RepoHelper
from
'
~/repo/helpers/repo_helper
'
;
import
modal
from
'
~/repo/components/new_dropdown/modal.vue
'
;
import
modal
from
'
~/repo/components/new_dropdown/modal.vue
'
;
import
eventHub
from
'
~/repo/event_hub
'
;
import
createComponent
from
'
../../../helpers/vue_mount_component_helper
'
;
import
createComponent
from
'
../../../helpers/vue_mount_component_helper
'
;
describe
(
'
new file modal component
'
,
()
=>
{
describe
(
'
new file modal component
'
,
()
=>
{
...
@@ -21,6 +21,7 @@ describe('new file modal component', () => {
...
@@ -21,6 +21,7 @@ describe('new file modal component', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
createComponent
(
Component
,
{
vm
=
createComponent
(
Component
,
{
type
,
type
,
currentPath
:
RepoStore
.
path
,
});
});
});
});
...
@@ -41,156 +42,35 @@ describe('new file modal component', () => {
...
@@ -41,156 +42,35 @@ describe('new file modal component', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.label-light
'
).
textContent
.
trim
()).
toBe
(
`
${
title
}
name`
);
expect
(
vm
.
$el
.
querySelector
(
'
.label-light
'
).
textContent
.
trim
()).
toBe
(
`
${
title
}
name`
);
});
});
it
(
'
emits toggle event after creating file
'
,
()
=>
{
spyOn
(
vm
,
'
$emit
'
);
vm
.
entryName
=
'
testing
'
;
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
toggle
'
);
});
it
(
'
sets editMode to true
'
,
()
=>
{
vm
.
entryName
=
'
testing
'
;
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
expect
(
RepoStore
.
editMode
).
toBeTruthy
();
});
it
(
'
toggles blob view
'
,
()
=>
{
vm
.
entryName
=
'
testing
'
;
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
expect
(
RepoStore
.
isPreviewView
()).
toBeFalsy
();
});
it
(
'
adds file into activeFiles
'
,
()
=>
{
vm
.
entryName
=
'
testing
'
;
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
expect
(
RepoStore
.
openedFiles
.
length
).
toBe
(
1
);
});
it
(
`creates
${
type
}
in the current stores path`
,
()
=>
{
RepoStore
.
path
=
'
testing
'
;
vm
.
entryName
=
'
testing/app
'
;
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
expect
(
RepoStore
.
files
[
0
].
path
).
toBe
(
'
testing/app
'
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
app
'
);
if
(
type
===
'
tree
'
)
{
expect
(
RepoStore
.
files
[
0
].
files
.
length
).
toBe
(
1
);
}
RepoStore
.
path
=
''
;
});
});
});
});
});
describe
(
'
file
'
,
()
=>
{
it
(
'
focuses field on mount
'
,
()
=>
{
beforeEach
(()
=>
{
document
.
body
.
innerHTML
+=
'
<div class="js-test"></div>
'
;
vm
=
createComponent
(
Component
,
{
type
:
'
blob
'
,
});
});
it
(
'
creates new file
'
,
()
=>
{
vm
.
entryName
=
'
testing
'
;
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
testing
'
);
expect
(
RepoStore
.
files
[
0
].
type
).
toBe
(
'
blob
'
);
expect
(
RepoStore
.
files
[
0
].
tempFile
).
toBeTruthy
();
});
it
(
'
does not create temp file when file already exists
'
,
()
=>
{
vm
=
createComponent
(
Component
,
{
RepoStore
.
files
.
push
(
RepoHelper
.
serializeRepoEntity
(
'
blob
'
,
{
type
:
'
tree
'
,
name
:
'
testing
'
,
currentPath
:
RepoStore
.
path
,
})
);
},
'
.js-test
'
);
vm
.
entryName
=
'
testing
'
;
expect
(
document
.
activeElement
).
toBe
(
vm
.
$refs
.
fieldName
);
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
vm
.
$el
.
remove
();
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
testing
'
);
expect
(
RepoStore
.
files
[
0
].
type
).
toBe
(
'
blob
'
);
expect
(
RepoStore
.
files
[
0
].
tempFile
).
toBeUndefined
();
});
});
});
describe
(
'
tree
'
,
()
=>
{
describe
(
'
createEntryInStore
'
,
()
=>
{
beforeEach
(()
=>
{
it
(
'
emits createNewEntry event
'
,
()
=>
{
spyOn
(
eventHub
,
'
$emit
'
);
vm
=
createComponent
(
Component
,
{
vm
=
createComponent
(
Component
,
{
type
:
'
tree
'
,
type
:
'
tree
'
,
currentPath
:
RepoStore
.
path
,
});
});
});
it
(
'
creates new tree
'
,
()
=>
{
vm
.
entryName
=
'
testing
'
;
vm
.
entryName
=
'
testing
'
;
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
testing
'
);
expect
(
RepoStore
.
files
[
0
].
type
).
toBe
(
'
tree
'
);
expect
(
RepoStore
.
files
[
0
].
tempFile
).
toBeTruthy
();
expect
(
RepoStore
.
files
[
0
].
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
name
).
toBe
(
'
.gitkeep
'
);
});
it
(
'
creates multiple trees when entryName has slashes
'
,
()
=>
{
vm
.
createEntryInStore
();
vm
.
entryName
=
'
app/test
'
;
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
createNewEntry
'
,
'
testing
'
,
'
tree
'
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
app
'
);
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
name
).
toBe
(
'
test
'
);
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
files
[
0
].
name
).
toBe
(
'
.gitkeep
'
);
});
});
it
(
'
creates tree in existing tree
'
,
()
=>
{
RepoStore
.
files
.
push
(
RepoHelper
.
serializeRepoEntity
(
'
tree
'
,
{
name
:
'
app
'
,
}));
vm
.
entryName
=
'
app/test
'
;
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
app
'
);
expect
(
RepoStore
.
files
[
0
].
tempFile
).
toBeUndefined
();
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
tempFile
).
toBeTruthy
();
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
name
).
toBe
(
'
test
'
);
expect
(
RepoStore
.
files
[
0
].
files
[
0
].
files
[
0
].
name
).
toBe
(
'
.gitkeep
'
);
});
it
(
'
does not create new tree when already exists
'
,
()
=>
{
RepoStore
.
files
.
push
(
RepoHelper
.
serializeRepoEntity
(
'
tree
'
,
{
name
:
'
app
'
,
}));
vm
.
entryName
=
'
app
'
;
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
expect
(
RepoStore
.
files
.
length
).
toBe
(
1
);
expect
(
RepoStore
.
files
[
0
].
name
).
toBe
(
'
app
'
);
expect
(
RepoStore
.
files
[
0
].
tempFile
).
toBeUndefined
();
expect
(
RepoStore
.
files
[
0
].
files
.
length
).
toBe
(
0
);
});
});
it
(
'
focuses field on mount
'
,
()
=>
{
document
.
body
.
innerHTML
+=
'
<div class="js-test"></div>
'
;
vm
=
createComponent
(
Component
,
{
type
:
'
tree
'
,
},
'
.js-test
'
);
expect
(
document
.
activeElement
).
toBe
(
vm
.
$refs
.
fieldName
);
vm
.
$el
.
remove
();
});
});
});
});
spec/javascripts/repo/components/repo_file_buttons_spec.js
View file @
133e66d2
...
@@ -35,7 +35,6 @@ describe('RepoFileButtons', () => {
...
@@ -35,7 +35,6 @@ describe('RepoFileButtons', () => {
const
blame
=
vm
.
$el
.
querySelector
(
'
.blame
'
);
const
blame
=
vm
.
$el
.
querySelector
(
'
.blame
'
);
const
history
=
vm
.
$el
.
querySelector
(
'
.history
'
);
const
history
=
vm
.
$el
.
querySelector
(
'
.history
'
);
expect
(
vm
.
$el
.
id
).
toEqual
(
'
repo-file-buttons
'
);
expect
(
raw
.
href
).
toMatch
(
`/
${
activeFile
.
raw_path
}
`
);
expect
(
raw
.
href
).
toMatch
(
`/
${
activeFile
.
raw_path
}
`
);
expect
(
raw
.
textContent
.
trim
()).
toEqual
(
'
Raw
'
);
expect
(
raw
.
textContent
.
trim
()).
toEqual
(
'
Raw
'
);
expect
(
blame
.
href
).
toMatch
(
`/
${
activeFile
.
blame_path
}
`
);
expect
(
blame
.
href
).
toMatch
(
`/
${
activeFile
.
blame_path
}
`
);
...
...
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