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
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
Hide 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 {
this
.
dataType
=
options
.
dataType
;
this
.
fieldName
=
options
.
fieldName
;
this
.
onSuccess
=
options
.
onSuccess
||
(()
=>
{});
this
.
onError
=
function
showFlash
(
respons
e
)
{
this
.
onError
=
function
showFlash
(
e
)
{
let
errorMessages
=
''
;
if
(
response
.
responseJSON
)
{
errorMessages
=
response
.
responseJSON
.
errors
.
join
(
'
'
);
if
(
e
.
response
.
data
&&
typeof
e
.
response
.
data
===
'
object
'
)
{
errorMessages
=
e
.
response
.
data
.
errors
.
join
(
'
'
);
}
return
new
Flash
(
errorMessages
||
'
Update failed
'
,
'
alert
'
);
...
...
@@ -42,6 +42,6 @@ export default class TaskList {
return
axios
.
patch
(
$target
.
data
(
'
update-url
'
)
||
$
(
'
form.js-issuable-update
'
).
attr
(
'
action
'
),
patchData
)
.
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 */
import
_
from
'
underscore
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Sidebar
from
'
~/right_sidebar
'
;
import
timeoutPromise
from
'
./helpers/set_timeout_promise_helper
'
;
describe
(
'
Issuable right sidebar collapsed todo toggle
'
,
()
=>
{
const
fixtureName
=
'
issues/open-issue.html.raw
'
;
const
jsonFixtureName
=
'
todos/todos.json
'
;
let
mock
;
preloadFixtures
(
fixtureName
);
preloadFixtures
(
jsonFixtureName
);
...
...
@@ -19,19 +23,26 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
document
.
querySelector
(
'
.js-right-sidebar
'
)
.
classList
.
toggle
(
'
right-sidebar-collapsed
'
);
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
((
res
)
=>
{
const
d
=
$
.
Deferred
();
mock
=
new
MockAdapter
(
axios
);
mock
.
onPost
(
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/issues-project/todos`
).
reply
(()
=>
{
const
response
=
_
.
clone
(
todoData
);
if
(
res
.
type
===
'
DELETE
'
)
{
delete
response
.
delete_path
;
}
return
[
200
,
response
];
});
d
.
resolve
(
response
);
return
d
.
promise
();
mock
.
onDelete
(
/
(
.*
)\/
dashboard
\/
todos
\/\d
+$/
).
reply
(()
=>
{
const
response
=
_
.
clone
(
todoData
);
delete
response
.
delete_path
;
return
[
200
,
response
];
});
});
afterEach
(()
=>
{
mock
.
restore
();
});
it
(
'
shows add todo button
'
,
()
=>
{
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
),
...
...
@@ -52,71 +63,101 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
).
toBe
(
'
Add todo
'
);
});
it
(
'
toggle todo state
'
,
()
=>
{
it
(
'
toggle todo state
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
).
not
.
toBeNull
();
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
).
not
.
toBeNull
();
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .fa-check-square
'
),
).
not
.
toBeNull
();
});
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .fa-check-square
'
),
).
not
.
toBeNull
();
it
(
'
toggle todo state of expanded todo toggle
'
,
()
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
expect
(
document
.
querySelector
(
'
.issuable-sidebar-header .js-issuable-todo
'
).
textContent
.
trim
(),
).
toBe
(
'
Mark done
'
);
done
();
});
});
it
(
'
toggle
s todo button tooltip
'
,
(
)
=>
{
it
(
'
toggle
todo state of expanded todo toggle
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
data-original-title
'
),
).
toBe
(
'
Mark done
'
);
});
it
(
'
marks todo as done
'
,
()
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
.issuable-sidebar-header .js-issuable-todo
'
).
textContent
.
trim
(),
).
toBe
(
'
Mark done
'
);
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
).
not
.
toBeNull
(
);
done
();
});
}
);
it
(
'
toggles todo button tooltip
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
).
toBeNull
();
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
data-original-title
'
),
).
toBe
(
'
Mark done
'
);
expect
(
document
.
querySelector
(
'
.issuable-sidebar-header .js-issuable-todo
'
).
textContent
.
trim
(),
).
toBe
(
'
Add todo
'
);
done
();
});
});
it
(
'
updates aria-label to mark done
'
,
(
)
=>
{
it
(
'
marks todo as done
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
).
toBe
(
'
Mark done
'
);
timeoutPromise
()
.
then
(()
=>
{
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
).
not
.
toBeNull
();
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
})
.
then
(
timeoutPromise
)
.
then
(()
=>
{
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon .todo-undone
'
),
).
toBeNull
();
expect
(
document
.
querySelector
(
'
.issuable-sidebar-header .js-issuable-todo
'
).
textContent
.
trim
(),
).
toBe
(
'
Add todo
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
updates aria-label to
add todo
'
,
(
)
=>
{
it
(
'
updates aria-label to
mark done
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
).
toBe
(
'
Mark done
'
);
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
).
toBe
(
'
Mark done
'
);
done
();
});
});
it
(
'
updates aria-label to add todo
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
).
toBe
(
'
Add todo
'
);
timeoutPromise
()
.
then
(()
=>
{
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
).
toBe
(
'
Mark done
'
);
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
click
();
})
.
then
(
timeoutPromise
)
.
then
(()
=>
{
expect
(
document
.
querySelector
(
'
.js-issuable-todo.sidebar-collapsed-icon
'
).
getAttribute
(
'
aria-label
'
),
).
toBe
(
'
Add todo
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
spec/javascripts/issue_spec.js
View file @
00415806
...
...
@@ -70,23 +70,6 @@ describe('Issue', function() {
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
)
=>
{
describe
(
`with
${
isIssueInitiallyOpen
?
'
open
'
:
'
closed
'
}
issue`
,
function
()
{
const
action
=
isIssueInitiallyOpen
?
'
close
'
:
'
reopen
'
;
...
...
spec/javascripts/merge_request_spec.js
View file @
00415806
/* eslint-disable space-before-function-paren, no-return-assign */
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
MergeRequest
from
'
~/merge_request
'
;
import
CloseReopenReportToggle
from
'
~/close_reopen_report_toggle
'
;
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
)
=>
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
((
req
)
=>
{
expect
(
req
.
type
).
toBe
(
'
PATCH
'
);
expect
(
req
.
url
).
toBe
(
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/merge-requests-project/merge_requests/1.json`
);
expect
(
req
.
data
.
merge_request
.
description
).
not
.
toBe
(
null
);
spyOn
(
axios
,
'
patch
'
).
and
.
callFake
((
url
,
data
)
=>
{
expect
(
url
).
toBe
(
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/merge-requests-project/merge_requests/1.json`
);
expect
(
data
.
merge_request
.
description
).
not
.
toBe
(
null
);
done
();
return
Promise
.
resolve
({
data
:
{}
});
});
$
(
'
.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';
expect
(
$
(
'
.js-task-list-field.original-task-list
'
).
val
()).
toBe
(
'
- [x] Task List Item
'
);
});
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
(
'
http://test.host/frontend-fixtures/merge-requests-project/merge_requests/1.json
'
);
return
expect
(
req
.
data
.
note
).
not
.
toBe
(
null
);
it
(
'
submits an ajax request on tasklist:changed
'
,
function
(
done
)
{
spyOn
(
axios
,
'
patch
'
).
and
.
callFake
((
url
,
data
)
=>
{
expect
(
url
).
toBe
(
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/merge-requests-project/merge_requests/1.json`
);
expect
(
data
.
note
.
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';
$toggle
=
$aside
.
find
(
'
.js-sidebar-toggle
'
);
return
$labelsIcon
=
$aside
.
find
(
'
.sidebar-collapsed-icon
'
);
});
afterEach
(()
=>
{
mock
.
restore
();
});
it
(
'
should expand/collapse the sidebar when arrow is clicked
'
,
function
()
{
assertSidebarState
(
'
expanded
'
);
$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