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
Jérome Perrin
gitlab-ce
Commits
eeb41af7
Commit
eeb41af7
authored
Apr 27, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
specs
parent
eb83edaf
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
160 additions
and
101 deletions
+160
-101
app/assets/javascripts/ide/components/commit_sidebar/form.vue
...assets/javascripts/ide/components/commit_sidebar/form.vue
+4
-4
app/assets/javascripts/ide/stores/mutations/file.js
app/assets/javascripts/ide/stores/mutations/file.js
+17
-28
spec/javascripts/ide/components/commit_sidebar/form_spec.js
spec/javascripts/ide/components/commit_sidebar/form_spec.js
+139
-0
spec/javascripts/ide/components/commit_sidebar/list_spec.js
spec/javascripts/ide/components/commit_sidebar/list_spec.js
+0
-12
spec/javascripts/ide/components/repo_commit_section_spec.js
spec/javascripts/ide/components/repo_commit_section_spec.js
+0
-57
No files found.
app/assets/javascripts/ide/components/commit_sidebar/form.vue
View file @
eeb41af7
...
@@ -53,16 +53,16 @@ export default {
...
@@ -53,16 +53,16 @@ export default {
},
},
beforeEnterTransition
()
{
beforeEnterTransition
()
{
const
elHeight
=
this
.
isCompact
const
elHeight
=
this
.
isCompact
?
this
.
$refs
.
formEl
.
offsetHeight
?
this
.
$refs
.
formEl
&&
this
.
$refs
.
formEl
.
offsetHeight
:
this
.
$refs
.
compactEl
.
offsetHeight
;
:
this
.
$refs
.
compactEl
&&
this
.
$refs
.
compactEl
.
offsetHeight
;
this
.
componentHeight
=
elHeight
+
32
;
this
.
componentHeight
=
elHeight
+
32
;
},
},
enterTransition
()
{
enterTransition
()
{
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
const
elHeight
=
this
.
isCompact
const
elHeight
=
this
.
isCompact
?
this
.
$refs
.
compactEl
.
offsetHeight
?
this
.
$refs
.
compactEl
&&
this
.
$refs
.
compactEl
.
offsetHeight
:
this
.
$refs
.
formEl
.
offsetHeight
;
:
this
.
$refs
.
formEl
&&
this
.
$refs
.
formEl
.
offsetHeight
;
this
.
componentHeight
=
elHeight
+
32
;
this
.
componentHeight
=
elHeight
+
32
;
});
});
...
...
app/assets/javascripts/ide/stores/mutations/file.js
View file @
eeb41af7
...
@@ -170,35 +170,24 @@ export default {
...
@@ -170,35 +170,24 @@ export default {
},
},
[
types
.
ADD_PENDING_TAB
](
state
,
{
file
,
keyPrefix
=
'
pending
'
})
{
[
types
.
ADD_PENDING_TAB
](
state
,
{
file
,
keyPrefix
=
'
pending
'
})
{
const
key
=
`
${
keyPrefix
}
-
${
file
.
key
}
`
;
const
key
=
`
${
keyPrefix
}
-
${
file
.
key
}
`
;
const
pendingTab
=
state
.
openFiles
.
find
(
f
=>
f
.
key
===
key
&&
f
.
pending
);
let
openFiles
=
state
.
openFiles
.
map
(
f
=>
Object
.
assign
(
f
,
{
active
:
false
,
opened
:
false
}));
if
(
!
pendingTab
)
{
Object
.
assign
(
state
,
{
const
openFile
=
openFiles
.
find
(
f
=>
f
.
path
===
file
.
path
);
entries
:
Object
.
assign
(
state
.
entries
,
{
[
file
.
path
]:
Object
.
assign
(
state
.
entries
[
file
.
path
],
{
openFiles
=
openFiles
.
concat
(
openFile
?
null
:
file
).
reduce
((
acc
,
f
)
=>
{
opened
:
false
,
if
(
!
f
)
return
acc
;
active
:
false
,
}),
if
(
f
.
path
===
file
.
path
)
{
}),
return
acc
.
concat
({
openFiles
:
[
...
f
,
{
content
:
file
.
content
,
...
file
,
active
:
true
,
key
,
pending
:
true
,
pending
:
true
,
opened
:
true
,
opened
:
true
,
key
,
active
:
true
,
},
],
});
});
}
return
acc
.
concat
(
f
);
},
[]);
}
else
{
openFiles
=
state
.
openFiles
.
map
(
f
=>
Object
.
assign
(
f
,
{
active
:
f
.
key
===
key
,
opened
:
f
.
key
===
key
}),
);
}
Object
.
assign
(
state
,
{
openFiles
});
},
},
[
types
.
REMOVE_PENDING_TAB
](
state
,
file
)
{
[
types
.
REMOVE_PENDING_TAB
](
state
,
file
)
{
Object
.
assign
(
state
,
{
Object
.
assign
(
state
,
{
...
...
spec/javascripts/ide/components/commit_sidebar/form_spec.js
0 → 100644
View file @
eeb41af7
import
Vue
from
'
vue
'
;
import
store
from
'
~/ide/stores
'
;
import
CommitForm
from
'
~/ide/components/commit_sidebar/form.vue
'
;
import
{
activityBarViews
}
from
'
~/ide/constants
'
;
import
{
createComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
getSetTimeoutPromise
from
'
spec/helpers/set_timeout_promise_helper
'
;
import
{
resetStore
}
from
'
../../helpers
'
;
describe
(
'
IDE commit form
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
CommitForm
);
let
vm
;
beforeEach
(()
=>
{
vm
=
createComponentWithStore
(
Component
,
store
).
$mount
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
resetStore
(
vm
.
$store
);
});
describe
(
'
compact
'
,
()
=>
{
it
(
'
renders commit button in compact mode
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.btn-primary
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.btn-primary
'
).
textContent
).
toContain
(
'
Commit
'
);
});
it
(
'
does not render form
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
form
'
)).
toBeNull
();
});
it
(
'
renders overview text
'
,
done
=>
{
vm
.
$store
.
state
.
changedFiles
.
push
(
'
test
'
);
vm
.
$store
.
state
.
stagedFiles
.
push
(
'
test
'
);
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
p
'
).
textContent
).
toContain
(
'
1 unstaged and 1 staged changes
'
);
done
();
});
});
it
(
'
shows form when clicking commit button
'
,
done
=>
{
vm
.
$el
.
querySelector
(
'
.btn-primary
'
).
click
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
form
'
)).
not
.
toBeNull
();
done
();
});
});
it
(
'
toggles activity bar vie when clicking commit button
'
,
done
=>
{
vm
.
$el
.
querySelector
(
'
.btn-primary
'
).
click
();
vm
.
$nextTick
(()
=>
{
expect
(
store
.
state
.
currentActivityView
).
toBe
(
activityBarViews
.
commit
);
done
();
});
});
});
describe
(
'
full
'
,
()
=>
{
beforeEach
(
done
=>
{
vm
.
isCompact
=
false
;
vm
.
$nextTick
(
done
);
});
it
(
'
updates commitMessage in store on input
'
,
done
=>
{
const
textarea
=
vm
.
$el
.
querySelector
(
'
textarea
'
);
textarea
.
value
=
'
testing commit message
'
;
textarea
.
dispatchEvent
(
new
Event
(
'
input
'
));
getSetTimeoutPromise
()
.
then
(()
=>
{
expect
(
vm
.
$store
.
state
.
commit
.
commitMessage
).
toBe
(
'
testing commit message
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
updating currentActivityView not to commit view sets compact mode
'
,
done
=>
{
store
.
state
.
currentActivityView
=
'
a
'
;
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
isCompact
).
toBe
(
true
);
done
();
});
});
describe
(
'
discard draft button
'
,
()
=>
{
it
(
'
hidden when commitMessage is empty
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.btn-default
'
).
textContent
).
toContain
(
'
Collapse
'
);
});
it
(
'
resets commitMessage when clicking discard button
'
,
done
=>
{
vm
.
$store
.
state
.
commit
.
commitMessage
=
'
testing commit message
'
;
getSetTimeoutPromise
()
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.btn-default
'
).
click
();
})
.
then
(
Vue
.
nextTick
)
.
then
(()
=>
{
expect
(
vm
.
$store
.
state
.
commit
.
commitMessage
).
not
.
toBe
(
'
testing commit message
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
when submitting
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
vm
,
'
commitChanges
'
);
vm
.
$store
.
state
.
stagedFiles
.
push
(
'
test
'
);
});
it
(
'
calls commitChanges
'
,
done
=>
{
vm
.
$store
.
state
.
commit
.
commitMessage
=
'
testing commit message
'
;
getSetTimeoutPromise
()
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
click
();
})
.
then
(
Vue
.
nextTick
)
.
then
(()
=>
{
expect
(
vm
.
commitChanges
).
toHaveBeenCalled
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
spec/javascripts/ide/components/commit_sidebar/list_spec.js
View file @
eeb41af7
...
@@ -49,16 +49,4 @@ describe('Multi-file editor commit sidebar list', () => {
...
@@ -49,16 +49,4 @@ describe('Multi-file editor commit sidebar list', () => {
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
No changes
'
);
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
No changes
'
);
});
});
});
});
describe
(
'
action button
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
vm
,
'
stageAllChanges
'
);
});
it
(
'
calls store action when clicked
'
,
()
=>
{
vm
.
$el
.
querySelector
(
'
.ide-staged-action-btn
'
).
click
();
expect
(
vm
.
stageAllChanges
).
toHaveBeenCalled
();
});
});
});
});
spec/javascripts/ide/components/repo_commit_section_spec.js
View file @
eeb41af7
...
@@ -182,61 +182,4 @@ describe('RepoCommitSection', () => {
...
@@ -182,61 +182,4 @@ describe('RepoCommitSection', () => {
done
();
done
();
});
});
});
});
it
(
'
updates commitMessage in store on input
'
,
done
=>
{
const
textarea
=
vm
.
$el
.
querySelector
(
'
textarea
'
);
textarea
.
value
=
'
testing commit message
'
;
textarea
.
dispatchEvent
(
new
Event
(
'
input
'
));
getSetTimeoutPromise
()
.
then
(()
=>
{
expect
(
vm
.
$store
.
state
.
commit
.
commitMessage
).
toBe
(
'
testing commit message
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
describe
(
'
discard draft button
'
,
()
=>
{
it
(
'
hidden when commitMessage is empty
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.multi-file-commit-form .btn-default
'
)).
toBeNull
();
});
it
(
'
resets commitMessage when clicking discard button
'
,
done
=>
{
vm
.
$store
.
state
.
commit
.
commitMessage
=
'
testing commit message
'
;
getSetTimeoutPromise
()
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.multi-file-commit-form .btn-default
'
).
click
();
})
.
then
(
Vue
.
nextTick
)
.
then
(()
=>
{
expect
(
vm
.
$store
.
state
.
commit
.
commitMessage
).
not
.
toBe
(
'
testing commit message
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
when submitting
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
vm
,
'
commitChanges
'
);
});
it
(
'
calls commitChanges
'
,
done
=>
{
vm
.
$store
.
state
.
commit
.
commitMessage
=
'
testing commit message
'
;
getSetTimeoutPromise
()
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.multi-file-commit-form .btn-success
'
).
click
();
})
.
then
(
Vue
.
nextTick
)
.
then
(()
=>
{
expect
(
vm
.
commitChanges
).
toHaveBeenCalled
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
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