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
c3bee6f4
Commit
c3bee6f4
authored
Feb 15, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IDE commit module action specs
parent
4049cf75
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
475 additions
and
186 deletions
+475
-186
app/assets/javascripts/ide/stores/modules/commit/actions.js
app/assets/javascripts/ide/stores/modules/commit/actions.js
+1
-1
spec/javascripts/repo/stores/actions_spec.js
spec/javascripts/repo/stores/actions_spec.js
+0
-185
spec/javascripts/repo/stores/modules/commit/actions_spec.js
spec/javascripts/repo/stores/modules/commit/actions_spec.js
+408
-0
spec/javascripts/repo/stores/modules/commit/getters_spec.js
spec/javascripts/repo/stores/modules/commit/getters_spec.js
+66
-0
No files found.
app/assets/javascripts/ide/stores/modules/commit/actions.js
View file @
c3bee6f4
...
...
@@ -101,7 +101,7 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState }) =
commit
(
types
.
UPDATE_LOADING
,
true
);
getCommitStatus
.
then
(
branchChanged
=>
new
Promise
((
resolve
)
=>
{
return
getCommitStatus
.
then
(
branchChanged
=>
new
Promise
((
resolve
)
=>
{
if
(
branchChanged
)
{
// show the modal with a Bootstrap call
$
(
'
#ide-create-branch-modal
'
).
modal
(
'
show
'
);
...
...
spec/javascripts/repo/stores/actions_spec.js
View file @
c3bee6f4
import
Vue
from
'
vue
'
;
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
import
store
from
'
~/ide/stores
'
;
import
service
from
'
~/ide/services
'
;
import
{
resetStore
,
file
}
from
'
../helpers
'
;
describe
(
'
Multi-file store actions
'
,
()
=>
{
...
...
@@ -130,190 +129,6 @@ describe('Multi-file store actions', () => {
});
});
describe
(
'
checkCommitStatus
'
,
()
=>
{
beforeEach
(()
=>
{
store
.
state
.
currentProjectId
=
'
abcproject
'
;
store
.
state
.
currentBranchId
=
'
master
'
;
store
.
state
.
projects
.
abcproject
=
{
branches
:
{
master
:
{
workingReference
:
'
1
'
,
},
},
};
});
it
(
'
calls service
'
,
(
done
)
=>
{
spyOn
(
service
,
'
getBranchData
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
commit
:
{
id
:
'
123
'
},
},
}));
store
.
dispatch
(
'
checkCommitStatus
'
)
.
then
(()
=>
{
expect
(
service
.
getBranchData
).
toHaveBeenCalledWith
(
'
abcproject
'
,
'
master
'
);
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'
returns true if current ref does not equal returned ID
'
,
(
done
)
=>
{
spyOn
(
service
,
'
getBranchData
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
commit
:
{
id
:
'
123
'
},
},
}));
store
.
dispatch
(
'
checkCommitStatus
'
)
.
then
((
val
)
=>
{
expect
(
val
).
toBeTruthy
();
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'
returns false if current ref equals returned ID
'
,
(
done
)
=>
{
spyOn
(
service
,
'
getBranchData
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
commit
:
{
id
:
'
1
'
},
},
}));
store
.
dispatch
(
'
checkCommitStatus
'
)
.
then
((
val
)
=>
{
expect
(
val
).
toBeFalsy
();
done
();
})
.
catch
(
done
.
fail
);
});
});
describe
(
'
commitChanges
'
,
()
=>
{
let
payload
;
beforeEach
(()
=>
{
spyOn
(
window
,
'
scrollTo
'
);
document
.
body
.
innerHTML
+=
'
<div class="flash-container"></div>
'
;
store
.
state
.
currentProjectId
=
'
abcproject
'
;
store
.
state
.
currentBranchId
=
'
master
'
;
store
.
state
.
projects
.
abcproject
=
{
web_url
:
'
webUrl
'
,
branches
:
{
master
:
{
workingReference
:
'
1
'
,
},
},
};
payload
=
{
branch
:
'
master
'
,
};
});
afterEach
(()
=>
{
document
.
querySelector
(
'
.flash-container
'
).
remove
();
});
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
service
,
'
commit
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
id
:
'
123456
'
,
short_id
:
'
123
'
,
message
:
'
test message
'
,
committed_date
:
'
date
'
,
stats
:
{
additions
:
'
1
'
,
deletions
:
'
2
'
,
},
},
}));
});
it
(
'
calls service
'
,
(
done
)
=>
{
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
expect
(
service
.
commit
).
toHaveBeenCalledWith
(
'
abcproject
'
,
payload
);
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
sets last Commit Msg
'
,
(
done
)
=>
{
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
expect
(
store
.
state
.
lastCommitMsg
).
toBe
(
'
Your changes have been committed. Commit 123 with 1 additions, 2 deletions.
'
,
);
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
adds commit data to changed files
'
,
(
done
)
=>
{
const
changedFile
=
file
();
store
.
state
.
changedFiles
.
push
(
changedFile
);
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
expect
(
changedFile
.
lastCommit
.
message
).
toBe
(
'
test message
'
);
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
scrolls to top of page
'
,
(
done
)
=>
{
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
expect
(
window
.
scrollTo
).
toHaveBeenCalledWith
(
0
,
0
);
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
redirects to new merge request page
'
,
(
done
)
=>
{
spyOn
(
urlUtils
,
'
visitUrl
'
);
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
true
})
.
then
(()
=>
{
expect
(
urlUtils
.
visitUrl
).
toHaveBeenCalledWith
(
'
webUrl/merge_requests/new?merge_request%5Bsource_branch%5D=master
'
);
done
();
}).
catch
(
done
.
fail
);
});
});
describe
(
'
failed
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
service
,
'
commit
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
message
:
'
failed message
'
,
},
}));
});
it
(
'
shows failed message
'
,
(
done
)
=>
{
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
const
alert
=
document
.
querySelector
(
'
.flash-container
'
);
expect
(
alert
.
textContent
.
trim
()).
toBe
(
'
failed message
'
,
);
done
();
}).
catch
(
done
.
fail
);
});
});
});
describe
(
'
createTempEntry
'
,
()
=>
{
beforeEach
(()
=>
{
store
.
state
.
trees
[
'
abcproject/mybranch
'
]
=
{
...
...
spec/javascripts/repo/stores/modules/commit/actions_spec.js
0 → 100644
View file @
c3bee6f4
This diff is collapsed.
Click to expand it.
spec/javascripts/repo/stores/modules/commit/getters_spec.js
View file @
c3bee6f4
import
commitState
from
'
~/ide/stores/modules/commit/state
'
;
import
*
as
consts
from
'
~/ide/stores/modules/commit/constants
'
;
import
*
as
getters
from
'
~/ide/stores/modules/commit/getters
'
;
describe
(
'
IDE commit module getters
'
,
()
=>
{
...
...
@@ -29,7 +30,35 @@ describe('IDE commit module getters', () => {
});
describe
(
'
commitButtonDisabled
'
,
()
=>
{
const
localGetters
=
{
discardDraftButtonDisabled
:
false
,
};
const
rootState
=
{
changedFiles
:
[
'
a
'
],
};
it
(
'
returns false when discardDraftButtonDisabled is false & changedFiles is not empty
'
,
()
=>
{
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
)).
toBeFalsy
();
});
it
(
'
returns true when discardDraftButtonDisabled is false & changedFiles is empty
'
,
()
=>
{
rootState
.
changedFiles
.
length
=
0
;
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
)).
toBeTruthy
();
});
it
(
'
returns true when discardDraftButtonDisabled is true
'
,
()
=>
{
localGetters
.
discardDraftButtonDisabled
=
true
;
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
)).
toBeTruthy
();
});
it
(
'
returns true when discardDraftButtonDisabled is false & changedFiles is not empty
'
,
()
=>
{
localGetters
.
discardDraftButtonDisabled
=
false
;
rootState
.
changedFiles
.
length
=
0
;
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
)).
toBeTruthy
();
});
});
describe
(
'
newBranchName
'
,
()
=>
{
...
...
@@ -43,6 +72,43 @@ describe('IDE commit module getters', () => {
});
describe
(
'
branchName
'
,
()
=>
{
const
rootState
=
{
currentBranchId
:
'
master
'
,
};
const
localGetters
=
{
newBranchName
:
'
newBranchName
'
,
};
beforeEach
(()
=>
{
Object
.
assign
(
state
,
{
newBranchName
:
'
state-newBranchName
'
,
});
});
it
(
'
defualts to currentBranchId
'
,
()
=>
{
expect
(
getters
.
branchName
(
state
,
null
,
rootState
)).
toBe
(
'
master
'
);
});
[
'
COMMIT_TO_NEW_BRANCH
'
,
'
COMMIT_TO_NEW_BRANCH_MR
'
].
forEach
((
type
)
=>
{
describe
(
type
,
()
=>
{
beforeEach
(()
=>
{
Object
.
assign
(
state
,
{
commitAction
:
consts
[
type
],
});
});
it
(
'
uses newBranchName when not empty
'
,
()
=>
{
expect
(
getters
.
branchName
(
state
,
localGetters
,
rootState
)).
toBe
(
'
state-newBranchName
'
);
});
it
(
'
uses getters newBranchName when state newBranchName is empty
'
,
()
=>
{
Object
.
assign
(
state
,
{
newBranchName
:
''
,
});
expect
(
getters
.
branchName
(
state
,
localGetters
,
rootState
)).
toBe
(
'
newBranchName
'
);
});
});
});
});
});
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