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
Boxiang Sun
gitlab-ce
Commits
cf542f9e
Commit
cf542f9e
authored
Oct 26, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves issuable tests
Fixes missing dependencies
parent
8df62a3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
70 deletions
+37
-70
app/assets/javascripts/issuable_bulk_update_sidebar.js
app/assets/javascripts/issuable_bulk_update_sidebar.js
+4
-0
app/assets/javascripts/issuable_index.js
app/assets/javascripts/issuable_index.js
+0
-1
spec/javascripts/issuable_spec.js
spec/javascripts/issuable_spec.js
+33
-69
No files found.
app/assets/javascripts/issuable_bulk_update_sidebar.js
View file @
cf542f9e
...
@@ -5,6 +5,10 @@
...
@@ -5,6 +5,10 @@
/* global SubscriptionSelect */
/* global SubscriptionSelect */
import
IssuableBulkUpdateActions
from
'
./issuable_bulk_update_actions
'
;
import
IssuableBulkUpdateActions
from
'
./issuable_bulk_update_actions
'
;
import
'
./milestone_select
'
;
import
'
./issue_status_select
'
;
import
'
./subscription_select
'
;
import
'
./labels_select
'
;
const
HIDDEN_CLASS
=
'
hidden
'
;
const
HIDDEN_CLASS
=
'
hidden
'
;
const
DISABLED_CONTENT_CLASS
=
'
disabled-content
'
;
const
DISABLED_CONTENT_CLASS
=
'
disabled-content
'
;
...
...
app/assets/javascripts/issuable_index.js
View file @
cf542f9e
...
@@ -5,7 +5,6 @@ export default class IssuableIndex {
...
@@ -5,7 +5,6 @@ export default class IssuableIndex {
constructor
(
pagePrefix
)
{
constructor
(
pagePrefix
)
{
this
.
initBulkUpdate
(
pagePrefix
);
this
.
initBulkUpdate
(
pagePrefix
);
IssuableIndex
.
resetIncomingEmailToken
();
IssuableIndex
.
resetIncomingEmailToken
();
this
.
initLabelFilterRemove
();
}
}
initBulkUpdate
(
pagePrefix
)
{
initBulkUpdate
(
pagePrefix
)
{
const
userCanBulkUpdate
=
$
(
'
.issues-bulk-update
'
).
length
>
0
;
const
userCanBulkUpdate
=
$
(
'
.issues-bulk-update
'
).
length
>
0
;
...
...
spec/javascripts/issuable_spec.js
View file @
cf542f9e
/* global IssuableIndex */
import
IssuableIndex
from
'
~/issuable_index
'
;
import
'
~/lib/utils/url_utility
'
;
describe
(
'
Issuable
'
,
()
=>
{
import
'
~/issuable_index
'
;
let
Issuable
;
describe
(
'
initBulkUpdate
'
,
()
=>
{
(()
=>
{
it
(
'
should not set bulkUpdateSidebar
'
,
()
=>
{
const
BASE_URL
=
'
/user/project/issues?scope=all&state=closed
'
;
Issuable
=
new
IssuableIndex
(
'
issue_
'
);
const
DEFAULT_PARAMS
=
'
&utf8=%E2%9C%93
'
;
expect
(
Issuable
.
bulkUpdateSidebar
).
not
.
toBeDefined
();
function
updateForm
(
formValues
,
form
)
{
$
.
each
(
formValues
,
(
id
,
value
)
=>
{
$
(
`#
${
id
}
`
,
form
).
val
(
value
);
});
}
function
resetForm
(
form
)
{
$
(
'
input[name!="utf8"]
'
,
form
).
each
((
index
,
input
)
=>
{
input
.
setAttribute
(
'
value
'
,
''
);
});
});
}
describe
(
'
Issuable
'
,
()
=>
{
it
(
'
should set bulkUpdateSidebar
'
,
()
=>
{
preloadFixtures
(
'
static/issuable_filter.html.raw
'
);
const
element
=
document
.
createElement
(
'
div
'
);
element
.
classList
.
add
(
'
issues-bulk-update
'
);
document
.
body
.
appendChild
(
element
);
beforeEach
(()
=>
{
Issuable
=
new
IssuableIndex
(
'
issue_
'
);
loadFixtures
(
'
static/issuable_filter.html.raw
'
);
expect
(
Issuable
.
bulkUpdateSidebar
).
toBeDefined
();
IssuableIndex
.
init
();
});
it
(
'
should be defined
'
,
()
=>
{
expect
(
window
.
IssuableIndex
).
toBeDefined
();
});
});
});
describe
(
'
filtering
'
,
()
=>
{
describe
(
'
resetIncomingEmailToken
'
,
()
=>
{
let
$filtersForm
;
beforeEach
(()
=>
{
const
element
=
document
.
createElement
(
'
a
'
);
beforeEach
(()
=>
{
element
.
classList
.
add
(
'
incoming-email-token-reset
'
);
$filtersForm
=
$
(
'
.js-filter-form
'
);
element
.
setAttribute
(
'
href
'
,
'
foo
'
);
loadFixtures
(
'
static/issuable_filter.html.raw
'
);
document
.
body
.
appendChild
(
element
);
resetForm
(
$filtersForm
);
});
it
(
'
should contain only the default parameters
'
,
()
=>
{
spyOn
(
gl
.
utils
,
'
visitUrl
'
);
IssuableIndex
.
filterResults
(
$filtersForm
);
expect
(
gl
.
utils
.
visitUrl
).
toHaveBeenCalledWith
(
BASE_URL
+
DEFAULT_PARAMS
);
});
it
(
'
should filter for the phrase "broken"
'
,
()
=>
{
spyOn
(
gl
.
utils
,
'
visitUrl
'
);
updateForm
({
search
:
'
broken
'
},
$filtersForm
);
IssuableIndex
.
filterResults
(
$filtersForm
);
const
params
=
`
${
DEFAULT_PARAMS
}
&search=broken`
;
expect
(
gl
.
utils
.
visitUrl
).
toHaveBeenCalledWith
(
BASE_URL
+
params
);
});
it
(
'
should keep query parameters after modifying filter
'
,
()
=>
{
spyOn
(
gl
.
utils
,
'
visitUrl
'
);
// initial filter
const
input
=
document
.
createElement
(
'
input
'
);
updateForm
({
milestone_title
:
'
v1.0
'
},
$filtersForm
);
input
.
setAttribute
(
'
id
'
,
'
issue_email
'
);
document
.
body
.
appendChild
(
input
);
IssuableIndex
.
filterResults
(
$filtersForm
);
Issuable
=
new
IssuableIndex
(
'
issue_
'
);
let
params
=
`
${
DEFAULT_PARAMS
}
&milestone_title=v1.0`
;
});
expect
(
gl
.
utils
.
visitUrl
).
toHaveBeenCalledWith
(
BASE_URL
+
params
);
// update filter
it
(
'
should send request to reset email token
'
,
()
=>
{
updateForm
({
label_name
:
'
Frontend
'
},
$filtersForm
);
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callThrough
();
document
.
querySelector
(
'
.incoming-email-token-reset
'
).
click
();
IssuableIndex
.
filterResults
(
$filtersForm
);
expect
(
jQuery
.
ajax
).
toHaveBeenCalled
();
params
=
`
${
DEFAULT_PARAMS
}
&milestone_title=v1.0&label_name=Frontend`
;
expect
(
jQuery
.
ajax
.
calls
.
argsFor
(
0
)[
0
].
url
).
toEqual
(
'
foo
'
);
expect
(
gl
.
utils
.
visitUrl
).
toHaveBeenCalledWith
(
BASE_URL
+
params
);
});
});
});
});
});
})();
});
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