BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0f895147
Unverified
Commit
0f895147
authored
Jan 31, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed issue_spec transient failure
parent
a3356bce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
32 deletions
+27
-32
issue_spec.js
spec/javascripts/issue_spec.js
+27
-32
No files found.
spec/javascripts/issue_spec.js
View file @
0f895147
...
@@ -92,21 +92,6 @@ describe('Issue', function() {
...
@@ -92,21 +92,6 @@ describe('Issue', function() {
const
action
=
isIssueInitiallyOpen
?
'close'
:
'reopen'
;
const
action
=
isIssueInitiallyOpen
?
'close'
:
'reopen'
;
let
mock
;
let
mock
;
function
ajaxSpy
(
req
)
{
if
(
req
.
url
===
this
.
$triggeredButton
.
attr
(
'href'
))
{
expect
(
req
.
type
).
toBe
(
'PUT'
);
expectNewBranchButtonState
(
true
,
false
);
return
this
.
issueStateDeferred
;
}
else
if
(
req
.
url
===
Issue
.
createMrDropdownWrap
.
dataset
.
canCreatePath
)
{
expect
(
req
.
type
).
toBe
(
'GET'
);
expectNewBranchButtonState
(
true
,
false
);
return
this
.
canCreateBranchDeferred
;
}
expect
(
req
.
url
).
toBe
(
'unexpected'
);
return
null
;
}
function
mockCloseButtonResponseSuccess
(
url
,
response
)
{
function
mockCloseButtonResponseSuccess
(
url
,
response
)
{
mock
.
onPut
(
url
).
reply
(()
=>
{
mock
.
onPut
(
url
).
reply
(()
=>
{
expectNewBranchButtonState
(
true
,
false
);
expectNewBranchButtonState
(
true
,
false
);
...
@@ -119,6 +104,12 @@ describe('Issue', function() {
...
@@ -119,6 +104,12 @@ describe('Issue', function() {
mock
.
onPut
(
url
).
networkError
();
mock
.
onPut
(
url
).
networkError
();
}
}
function
mockCanCreateBranch
(
canCreateBranch
)
{
mock
.
onGet
(
/
(
.*
)\/
can_create_branch$/
).
reply
(
200
,
{
can_create_branch
:
canCreateBranch
,
});
}
beforeEach
(
function
()
{
beforeEach
(
function
()
{
if
(
isIssueInitiallyOpen
)
{
if
(
isIssueInitiallyOpen
)
{
loadFixtures
(
'issues/open-issue.html.raw'
);
loadFixtures
(
'issues/open-issue.html.raw'
);
...
@@ -126,6 +117,11 @@ describe('Issue', function() {
...
@@ -126,6 +117,11 @@ describe('Issue', function() {
loadFixtures
(
'issues/closed-issue.html.raw'
);
loadFixtures
(
'issues/closed-issue.html.raw'
);
}
}
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
/
(
.*
)\/
related_branches$/
).
reply
(
200
,
{});
mock
.
onGet
(
/
(
.*
)\/
referenced_merge_requests$/
).
reply
(
200
,
{});
findElements
(
isIssueInitiallyOpen
);
findElements
(
isIssueInitiallyOpen
);
this
.
issue
=
new
Issue
();
this
.
issue
=
new
Issue
();
expectIssueState
(
isIssueInitiallyOpen
);
expectIssueState
(
isIssueInitiallyOpen
);
...
@@ -135,27 +131,21 @@ describe('Issue', function() {
...
@@ -135,27 +131,21 @@ describe('Issue', function() {
this
.
$projectIssuesCounter
=
$
(
'.issue_counter'
).
first
();
this
.
$projectIssuesCounter
=
$
(
'.issue_counter'
).
first
();
this
.
$projectIssuesCounter
.
text
(
'1,001'
);
this
.
$projectIssuesCounter
.
text
(
'1,001'
);
this
.
issueStateDeferred
=
new
jQuery
.
Deferred
();
spyOn
(
axios
,
'get'
).
and
.
callThrough
();
this
.
canCreateBranchDeferred
=
new
jQuery
.
Deferred
();
mock
=
new
MockAdapter
(
axios
);
spyOn
(
jQuery
,
'ajax'
).
and
.
callFake
(
ajaxSpy
.
bind
(
this
));
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
mock
.
restore
();
mock
.
restore
();
$
(
'div.flash-alert'
).
remove
();
});
});
it
(
`
${
action
}
s the issue`
,
function
(
done
)
{
it
(
`
${
action
}
s the issue`
,
function
(
done
)
{
mockCloseButtonResponseSuccess
(
this
.
$triggeredButton
.
attr
(
'href'
),
{
mockCloseButtonResponseSuccess
(
this
.
$triggeredButton
.
attr
(
'href'
),
{
id
:
34
id
:
34
});
});
mockCanCreateBranch
(
!
isIssueInitiallyOpen
);
this
.
$triggeredButton
.
trigger
(
'click'
);
this
.
$triggeredButton
.
trigger
(
'click'
);
this
.
canCreateBranchDeferred
.
resolve
({
can_create_branch
:
!
isIssueInitiallyOpen
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expectIssueState
(
!
isIssueInitiallyOpen
);
expectIssueState
(
!
isIssueInitiallyOpen
);
...
@@ -171,10 +161,9 @@ describe('Issue', function() {
...
@@ -171,10 +161,9 @@ describe('Issue', function() {
mockCloseButtonResponseSuccess
(
this
.
$triggeredButton
.
attr
(
'href'
),
{
mockCloseButtonResponseSuccess
(
this
.
$triggeredButton
.
attr
(
'href'
),
{
saved
:
false
saved
:
false
});
});
mockCanCreateBranch
(
isIssueInitiallyOpen
);
this
.
$triggeredButton
.
trigger
(
'click'
);
this
.
$triggeredButton
.
trigger
(
'click'
);
this
.
canCreateBranchDeferred
.
resolve
({
can_create_branch
:
isIssueInitiallyOpen
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expectIssueState
(
isIssueInitiallyOpen
);
expectIssueState
(
isIssueInitiallyOpen
);
...
@@ -189,10 +178,9 @@ describe('Issue', function() {
...
@@ -189,10 +178,9 @@ describe('Issue', function() {
it
(
`fails to
${
action
}
the issue if HTTP error occurs`
,
function
(
done
)
{
it
(
`fails to
${
action
}
the issue if HTTP error occurs`
,
function
(
done
)
{
mockCloseButtonResponseError
(
this
.
$triggeredButton
.
attr
(
'href'
));
mockCloseButtonResponseError
(
this
.
$triggeredButton
.
attr
(
'href'
));
mockCanCreateBranch
(
isIssueInitiallyOpen
);
this
.
$triggeredButton
.
trigger
(
'click'
);
this
.
$triggeredButton
.
trigger
(
'click'
);
this
.
canCreateBranchDeferred
.
resolve
({
can_create_branch
:
isIssueInitiallyOpen
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expectIssueState
(
isIssueInitiallyOpen
);
expectIssueState
(
isIssueInitiallyOpen
);
...
@@ -207,18 +195,25 @@ describe('Issue', function() {
...
@@ -207,18 +195,25 @@ describe('Issue', function() {
it
(
'disables the new branch button if Ajax call fails'
,
function
()
{
it
(
'disables the new branch button if Ajax call fails'
,
function
()
{
mockCloseButtonResponseError
(
this
.
$triggeredButton
.
attr
(
'href'
));
mockCloseButtonResponseError
(
this
.
$triggeredButton
.
attr
(
'href'
));
mock
.
onGet
(
/
(
.*
)\/
can_create_branch$/
).
networkError
();
this
.
$triggeredButton
.
trigger
(
'click'
);
this
.
$triggeredButton
.
trigger
(
'click'
);
this
.
canCreateBranchDeferred
.
reject
();
expectNewBranchButtonState
(
false
,
false
);
expectNewBranchButtonState
(
false
,
false
);
});
});
it
(
'does not trigger Ajax call if new branch button is missing'
,
function
()
{
it
(
'does not trigger Ajax call if new branch button is missing'
,
function
(
done
)
{
mockCloseButtonResponseError
(
this
.
$triggeredButton
.
attr
(
'href'
));
mockCloseButtonResponseError
(
this
.
$triggeredButton
.
attr
(
'href'
));
Issue
.
$btnNewBranch
=
$
();
Issue
.
$btnNewBranch
=
$
();
this
.
canCreateBranchDeferred
=
null
;
this
.
canCreateBranchDeferred
=
null
;
this
.
$triggeredButton
.
trigger
(
'click'
);
this
.
$triggeredButton
.
trigger
(
'click'
);
setTimeout
(()
=>
{
expect
(
axios
.
get
).
not
.
toHaveBeenCalled
();
done
();
});
});
});
});
});
});
});
...
...
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