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
Léo-Paul Géneau
gitlab-ce
Commits
00415806
Commit
00415806
authored
Feb 02, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed failing karma specs caused by TaskList
parent
8d83e517
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
80 deletions
+113
-80
app/assets/javascripts/task_list.js
app/assets/javascripts/task_list.js
+4
-4
spec/javascripts/collapsed_sidebar_todo_spec.js
spec/javascripts/collapsed_sidebar_todo_spec.js
+90
-49
spec/javascripts/issue_spec.js
spec/javascripts/issue_spec.js
+0
-17
spec/javascripts/merge_request_spec.js
spec/javascripts/merge_request_spec.js
+6
-4
spec/javascripts/notes_spec.js
spec/javascripts/notes_spec.js
+8
-6
spec/javascripts/right_sidebar_spec.js
spec/javascripts/right_sidebar_spec.js
+5
-0
No files found.
app/assets/javascripts/task_list.js
View file @
00415806
...
@@ -8,11 +8,11 @@ export default class TaskList {
...
@@ -8,11 +8,11 @@ export default class TaskList {
this
.
dataType
=
options
.
dataType
;
this
.
dataType
=
options
.
dataType
;
this
.
fieldName
=
options
.
fieldName
;
this
.
fieldName
=
options
.
fieldName
;
this
.
onSuccess
=
options
.
onSuccess
||
(()
=>
{});
this
.
onSuccess
=
options
.
onSuccess
||
(()
=>
{});
this
.
onError
=
function
showFlash
(
respons
e
)
{
this
.
onError
=
function
showFlash
(
e
)
{
let
errorMessages
=
''
;
let
errorMessages
=
''
;
if
(
response
.
responseJSON
)
{
if
(
e
.
response
.
data
&&
typeof
e
.
response
.
data
===
'
object
'
)
{
errorMessages
=
response
.
responseJSON
.
errors
.
join
(
'
'
);
errorMessages
=
e
.
response
.
data
.
errors
.
join
(
'
'
);
}
}
return
new
Flash
(
errorMessages
||
'
Update failed
'
,
'
alert
'
);
return
new
Flash
(
errorMessages
||
'
Update failed
'
,
'
alert
'
);
...
@@ -42,6 +42,6 @@ export default class TaskList {
...
@@ -42,6 +42,6 @@ export default class TaskList {
return
axios
.
patch
(
$target
.
data
(
'
update-url
'
)
||
$
(
'
form.js-issuable-update
'
).
attr
(
'
action
'
),
patchData
)
return
axios
.
patch
(
$target
.
data
(
'
update-url
'
)
||
$
(
'
form.js-issuable-update
'
).
attr
(
'
action
'
),
patchData
)
.
then
(({
data
})
=>
this
.
onSuccess
(
data
))
.
then
(({
data
})
=>
this
.
onSuccess
(
data
))
.
catch
(
()
=>
this
.
onError
(
));
.
catch
(
err
=>
this
.
onError
(
err
));
}
}
}
}
spec/javascripts/collapsed_sidebar_todo_spec.js
View file @
00415806
/* eslint-disable no-new */
/* eslint-disable no-new */
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Sidebar
from
'
~/right_sidebar
'
;
import
Sidebar
from
'
~/right_sidebar
'
;
import
timeoutPromise
from
'
./helpers/set_timeout_promise_helper
'
;
describe
(
'
Issuable right sidebar collapsed todo toggle
'
,
()
=>
{
describe
(
'
Issuable right sidebar collapsed todo toggle
'
,
()
=>
{
const
fixtureName
=
'
issues/open-issue.html.raw
'
;
const
fixtureName
=
'
issues/open-issue.html.raw
'
;
const
jsonFixtureName
=
'
todos/todos.json
'
;
const
jsonFixtureName
=
'
todos/todos.json
'
;
let
mock
;
preloadFixtures
(
fixtureName
);
preloadFixtures
(
fixtureName
);
preloadFixtures
(
jsonFixtureName
);
preloadFixtures
(
jsonFixtureName
);
...
@@ -19,19 +23,26 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
...
@@ -19,19 +23,26 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
document
.
querySelector
(
'
.js-right-sidebar
'
)
document
.
querySelector
(
'
.js-right-sidebar
'
)
.
classList
.
toggle
(
'
right-sidebar-collapsed
'
);
.
classList
.
toggle
(
'
right-sidebar-collapsed
'
);
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
((
res
)
=>
{
mock
=
new
MockAdapter
(
axios
);
const
d
=
$
.
Deferred
();
mock
.
onPost
(
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/issues-project/todos`
).
reply
(()
=>
{
const
response
=
_
.
clone
(
todoData
);
const
response
=
_
.
clone
(
todoData
);
if
(
res
.
type
===
'
DELETE
'
)
{
return
[
200
,
response
];
});
mock
.
onDelete
(
/
(
.*
)\/
dashboard
\/
todos
\/\d
+$/
).
reply
(()
=>
{
const
response
=
_
.
clone
(
todoData
);
delete
response
.
delete_path
;
delete
response
.
delete_path
;
}
d
.
resolve
(
response
);
return
[
200
,
response
];
return
d
.
promise
();
});
});
});
});
afterEach
(()
=>
{
mock
.
restore
();
});
it
(
'
shows add todo button
'
,
()
=>
{
it
(
'
shows add todo button
'
,
()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
),
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
),
...
@@ -52,9 +63,10 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
...
@@ -52,9 +63,10 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
).
toBe
(
'
Add todo
'
);
).
toBe
(
'
Add todo
'
);
});
});
it
(
'
toggle todo state
'
,
()
=>
{
it
(
'
toggle todo state
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
setTimeout
(()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
).
not
.
toBeNull
();
).
not
.
toBeNull
();
...
@@ -62,33 +74,48 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
...
@@ -62,33 +74,48 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
expect
(
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .fa-check-square
'
),
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .fa-check-square
'
),
).
not
.
toBeNull
();
).
not
.
toBeNull
();
done
();
});
});
});
it
(
'
toggle todo state of expanded todo toggle
'
,
()
=>
{
it
(
'
toggle todo state of expanded todo toggle
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
setTimeout
(()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.issuable-sidebar-header .js-issuable-todo
'
).
textContent
.
trim
(),
document
.
querySelector
(
'
.issuable-sidebar-header .js-issuable-todo
'
).
textContent
.
trim
(),
).
toBe
(
'
Mark done
'
);
).
toBe
(
'
Mark done
'
);
done
();
});
});
});
it
(
'
toggles todo button tooltip
'
,
()
=>
{
it
(
'
toggles todo button tooltip
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
setTimeout
(()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
data-original-title
'
),
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
data-original-title
'
),
).
toBe
(
'
Mark done
'
);
).
toBe
(
'
Mark done
'
);
done
();
});
});
});
it
(
'
marks todo as done
'
,
()
=>
{
it
(
'
marks todo as done
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
timeoutPromise
()
.
then
(()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
).
not
.
toBeNull
();
).
not
.
toBeNull
();
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
})
.
then
(
timeoutPromise
)
.
then
(()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
).
toBeNull
();
).
toBeNull
();
...
@@ -96,27 +123,41 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
...
@@ -96,27 +123,41 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
expect
(
expect
(
document
.
querySelector
(
'
.issuable-sidebar-header .js-issuable-todo
'
).
textContent
.
trim
(),
document
.
querySelector
(
'
.issuable-sidebar-header .js-issuable-todo
'
).
textContent
.
trim
(),
).
toBe
(
'
Add todo
'
);
).
toBe
(
'
Add todo
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
updates aria-label to mark done
'
,
()
=>
{
it
(
'
updates aria-label to mark done
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
setTimeout
(()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
).
toBe
(
'
Mark done
'
);
).
toBe
(
'
Mark done
'
);
done
();
});
});
});
it
(
'
updates aria-label to add todo
'
,
()
=>
{
it
(
'
updates aria-label to add todo
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
timeoutPromise
()
.
then
(()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
).
toBe
(
'
Mark done
'
);
).
toBe
(
'
Mark done
'
);
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
})
.
then
(
timeoutPromise
)
.
then
(()
=>
{
expect
(
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
).
toBe
(
'
Add todo
'
);
).
toBe
(
'
Add todo
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
spec/javascripts/issue_spec.js
View file @
00415806
...
@@ -70,23 +70,6 @@ describe('Issue', function() {
...
@@ -70,23 +70,6 @@ describe('Issue', function() {
expect
(
$btn
).
toHaveText
(
isIssueInitiallyOpen
?
'
Close issue
'
:
'
Reopen issue
'
);
expect
(
$btn
).
toHaveText
(
isIssueInitiallyOpen
?
'
Close issue
'
:
'
Reopen issue
'
);
}
}
describe
(
'
task lists
'
,
function
()
{
beforeEach
(
function
()
{
loadFixtures
(
'
issues/issue-with-task-list.html.raw
'
);
this
.
issue
=
new
Issue
();
});
it
(
'
submits an ajax request on tasklist:changed
'
,
function
()
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
expect
(
req
.
type
).
toBe
(
'
PATCH
'
);
expect
(
req
.
url
).
toBe
(
gl
.
TEST_HOST
+
'
/frontend-fixtures/issues-project/issues/1.json
'
);
// eslint-disable-line prefer-template
expect
(
req
.
data
.
issue
.
description
).
not
.
toBe
(
null
);
});
$
(
'
.js-task-list-field
'
).
trigger
(
'
tasklist:changed
'
);
});
});
[
true
,
false
].
forEach
((
isIssueInitiallyOpen
)
=>
{
[
true
,
false
].
forEach
((
isIssueInitiallyOpen
)
=>
{
describe
(
`with
${
isIssueInitiallyOpen
?
'
open
'
:
'
closed
'
}
issue`
,
function
()
{
describe
(
`with
${
isIssueInitiallyOpen
?
'
open
'
:
'
closed
'
}
issue`
,
function
()
{
const
action
=
isIssueInitiallyOpen
?
'
close
'
:
'
reopen
'
;
const
action
=
isIssueInitiallyOpen
?
'
close
'
:
'
reopen
'
;
...
...
spec/javascripts/merge_request_spec.js
View file @
00415806
/* eslint-disable space-before-function-paren, no-return-assign */
/* eslint-disable space-before-function-paren, no-return-assign */
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
MergeRequest
from
'
~/merge_request
'
;
import
MergeRequest
from
'
~/merge_request
'
;
import
CloseReopenReportToggle
from
'
~/close_reopen_report_toggle
'
;
import
CloseReopenReportToggle
from
'
~/close_reopen_report_toggle
'
;
import
IssuablesHelper
from
'
~/helpers/issuables_helper
'
;
import
IssuablesHelper
from
'
~/helpers/issuables_helper
'
;
...
@@ -21,11 +22,12 @@ import IssuablesHelper from '~/helpers/issuables_helper';
...
@@ -21,11 +22,12 @@ import IssuablesHelper from '~/helpers/issuables_helper';
});
});
it
(
'
submits an ajax request on tasklist:changed
'
,
(
done
)
=>
{
it
(
'
submits an ajax request on tasklist:changed
'
,
(
done
)
=>
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
((
req
)
=>
{
spyOn
(
axios
,
'
patch
'
).
and
.
callFake
((
url
,
data
)
=>
{
expect
(
req
.
type
).
toBe
(
'
PATCH
'
);
expect
(
url
).
toBe
(
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/merge-requests-project/merge_requests/1.json`
);
expect
(
req
.
url
).
toBe
(
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/merge-requests-project/merge_requests/1.json`
);
expect
(
data
.
merge_request
.
description
).
not
.
toBe
(
null
);
expect
(
req
.
data
.
merge_request
.
description
).
not
.
toBe
(
null
);
done
();
done
();
return
Promise
.
resolve
({
data
:
{}
});
});
});
$
(
'
.js-task-list-field
'
).
trigger
(
'
tasklist:changed
'
);
$
(
'
.js-task-list-field
'
).
trigger
(
'
tasklist:changed
'
);
...
...
spec/javascripts/notes_spec.js
View file @
00415806
...
@@ -65,14 +65,16 @@ import timeoutPromise from './helpers/set_timeout_promise_helper';
...
@@ -65,14 +65,16 @@ import timeoutPromise from './helpers/set_timeout_promise_helper';
expect
(
$
(
'
.js-task-list-field.original-task-list
'
).
val
()).
toBe
(
'
- [x] Task List Item
'
);
expect
(
$
(
'
.js-task-list-field.original-task-list
'
).
val
()).
toBe
(
'
- [x] Task List Item
'
);
});
});
it
(
'
submits an ajax request on tasklist:changed
'
,
function
()
{
it
(
'
submits an ajax request on tasklist:changed
'
,
function
(
done
)
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
spyOn
(
axios
,
'
patch
'
).
and
.
callFake
((
url
,
data
)
=>
{
expect
(
req
.
type
).
toBe
(
'
PATCH
'
);
expect
(
url
).
toBe
(
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/merge-requests-project/merge_requests/1.json`
);
expect
(
req
.
url
).
toBe
(
'
http://test.host/frontend-fixtures/merge-requests-project/merge_requests/1.json
'
);
expect
(
data
.
note
.
note
).
not
.
toBe
(
null
);
return
expect
(
req
.
data
.
note
).
not
.
toBe
(
null
);
done
();
return
Promise
.
resolve
({
data
:
{}
});
});
});
$
(
'
.js-task-list-
field.js-note-text
'
).
trigger
(
'
tasklist:changed
'
);
$
(
'
.js-task-list-
container
'
).
trigger
(
'
tasklist:changed
'
);
});
});
});
});
...
...
spec/javascripts/right_sidebar_spec.js
View file @
00415806
...
@@ -49,6 +49,11 @@ import Sidebar from '~/right_sidebar';
...
@@ -49,6 +49,11 @@ import Sidebar from '~/right_sidebar';
$toggle
=
$aside
.
find
(
'
.js-sidebar-toggle
'
);
$toggle
=
$aside
.
find
(
'
.js-sidebar-toggle
'
);
return
$labelsIcon
=
$aside
.
find
(
'
.sidebar-collapsed-icon
'
);
return
$labelsIcon
=
$aside
.
find
(
'
.sidebar-collapsed-icon
'
);
});
});
afterEach
(()
=>
{
mock
.
restore
();
});
it
(
'
should expand/collapse the sidebar when arrow is clicked
'
,
function
()
{
it
(
'
should expand/collapse the sidebar when arrow is clicked
'
,
function
()
{
assertSidebarState
(
'
expanded
'
);
assertSidebarState
(
'
expanded
'
);
$toggle
.
click
();
$toggle
.
click
();
...
...
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