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
fa65c340
Commit
fa65c340
authored
Oct 01, 2019
by
Winnie Hellmann
Committed by
Clement Ho
Oct 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display reCAPTCHA modal when making issue public
parent
287d0eaf
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
10 deletions
+118
-10
app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue
...ar/components/confidential/confidential_issue_sidebar.vue
+11
-2
app/assets/javascripts/vue_shared/components/recaptcha_modal.vue
...ets/javascripts/vue_shared/components/recaptcha_modal.vue
+4
-0
changelogs/unreleased/winh-confidential-issue-recaptcha.yml
changelogs/unreleased/winh-confidential-issue-recaptcha.yml
+5
-0
spec/frontend/sidebar/__snapshots__/confidential_issue_sidebar_spec.js.snap
...bar/__snapshots__/confidential_issue_sidebar_spec.js.snap
+8
-0
spec/frontend/sidebar/confidential_issue_sidebar_spec.js
spec/frontend/sidebar/confidential_issue_sidebar_spec.js
+90
-8
No files found.
app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue
View file @
fa65c340
...
@@ -5,6 +5,7 @@ import tooltip from '~/vue_shared/directives/tooltip';
...
@@ -5,6 +5,7 @@ import tooltip from '~/vue_shared/directives/tooltip';
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
eventHub
from
'
~/sidebar/event_hub
'
;
import
eventHub
from
'
~/sidebar/event_hub
'
;
import
editForm
from
'
./edit_form.vue
'
;
import
editForm
from
'
./edit_form.vue
'
;
import
recaptchaModalImplementor
from
'
~/vue_shared/mixins/recaptcha_modal_implementor
'
;
export
default
{
export
default
{
components
:
{
components
:
{
...
@@ -14,6 +15,7 @@ export default {
...
@@ -14,6 +15,7 @@ export default {
directives
:
{
directives
:
{
tooltip
,
tooltip
,
},
},
mixins
:
[
recaptchaModalImplementor
],
props
:
{
props
:
{
isConfidential
:
{
isConfidential
:
{
required
:
true
,
required
:
true
,
...
@@ -54,9 +56,14 @@ export default {
...
@@ -54,9 +56,14 @@ export default {
updateConfidentialAttribute
(
confidential
)
{
updateConfidentialAttribute
(
confidential
)
{
this
.
service
this
.
service
.
update
(
'
issue
'
,
{
confidential
})
.
update
(
'
issue
'
,
{
confidential
})
.
then
(({
data
})
=>
this
.
checkForSpam
(
data
))
.
then
(()
=>
window
.
location
.
reload
())
.
then
(()
=>
window
.
location
.
reload
())
.
catch
(()
=>
{
.
catch
(
error
=>
{
if
(
error
.
name
===
'
SpamError
'
)
{
this
.
openRecaptcha
();
}
else
{
Flash
(
__
(
'
Something went wrong trying to change the confidentiality of this issue
'
));
Flash
(
__
(
'
Something went wrong trying to change the confidentiality of this issue
'
));
}
});
});
},
},
},
},
...
@@ -112,5 +119,7 @@ export default {
...
@@ -112,5 +119,7 @@ export default {
{{
__
(
'
This issue is confidential
'
)
}}
{{
__
(
'
This issue is confidential
'
)
}}
</div>
</div>
</div>
</div>
<recaptcha-modal
v-if=
"showRecaptcha"
:html=
"recaptchaHTML"
@
close=
"closeRecaptcha"
/>
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/vue_shared/components/recaptcha_modal.vue
View file @
fa65c340
...
@@ -32,6 +32,10 @@ export default {
...
@@ -32,6 +32,10 @@ export default {
mounted
()
{
mounted
()
{
eventHub
.
$on
(
'
submit
'
,
this
.
submit
);
eventHub
.
$on
(
'
submit
'
,
this
.
submit
);
if
(
this
.
html
)
{
this
.
appendRecaptchaScript
();
}
},
},
beforeDestroy
()
{
beforeDestroy
()
{
...
...
changelogs/unreleased/winh-confidential-issue-recaptcha.yml
0 → 100644
View file @
fa65c340
---
title
:
Display reCAPTCHA modal when making issue public
merge_request
:
17553
author
:
type
:
fixed
spec/frontend/sidebar/__snapshots__/confidential_issue_sidebar_spec.js.snap
View file @
fa65c340
...
@@ -49,6 +49,8 @@ exports[`Confidential Issue Sidebar Block renders for isConfidential = false and
...
@@ -49,6 +49,8 @@ exports[`Confidential Issue Sidebar Block renders for isConfidential = false and
</div>
</div>
</div>
</div>
<!---->
</div>
</div>
`;
`;
...
@@ -111,6 +113,8 @@ exports[`Confidential Issue Sidebar Block renders for isConfidential = false and
...
@@ -111,6 +113,8 @@ exports[`Confidential Issue Sidebar Block renders for isConfidential = false and
</div>
</div>
</div>
</div>
<!---->
</div>
</div>
`;
`;
...
@@ -163,6 +167,8 @@ exports[`Confidential Issue Sidebar Block renders for isConfidential = true and
...
@@ -163,6 +167,8 @@ exports[`Confidential Issue Sidebar Block renders for isConfidential = true and
</div>
</div>
</div>
</div>
<!---->
</div>
</div>
`;
`;
...
@@ -225,5 +231,7 @@ exports[`Confidential Issue Sidebar Block renders for isConfidential = true and
...
@@ -225,5 +231,7 @@ exports[`Confidential Issue Sidebar Block renders for isConfidential = true and
</div>
</div>
</div>
</div>
<!---->
</div>
</div>
`;
`;
spec/frontend/sidebar/confidential_issue_sidebar_spec.js
View file @
fa65c340
...
@@ -2,15 +2,36 @@ import { shallowMount } from '@vue/test-utils';
...
@@ -2,15 +2,36 @@ import { shallowMount } from '@vue/test-utils';
import
ConfidentialIssueSidebar
from
'
~/sidebar/components/confidential/confidential_issue_sidebar.vue
'
;
import
ConfidentialIssueSidebar
from
'
~/sidebar/components/confidential/confidential_issue_sidebar.vue
'
;
import
{
mockTracking
,
triggerEvent
}
from
'
helpers/tracking_helper
'
;
import
{
mockTracking
,
triggerEvent
}
from
'
helpers/tracking_helper
'
;
import
EditForm
from
'
~/sidebar/components/confidential/edit_form.vue
'
;
import
EditForm
from
'
~/sidebar/components/confidential/edit_form.vue
'
;
import
SidebarService
from
'
~/sidebar/services/sidebar_service
'
;
import
createFlash
from
'
~/flash
'
;
import
RecaptchaModal
from
'
~/vue_shared/components/recaptcha_modal
'
;
jest
.
mock
(
'
~/flash
'
);
jest
.
mock
(
'
~/sidebar/services/sidebar_service
'
);
describe
(
'
Confidential Issue Sidebar Block
'
,
()
=>
{
describe
(
'
Confidential Issue Sidebar Block
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
const
createComponent
=
propsData
=>
{
const
findRecaptchaModal
=
()
=>
wrapper
.
find
(
RecaptchaModal
);
const
service
=
{
update
:
()
=>
Promise
.
resolve
(
true
),
const
triggerUpdateConfidentialAttribute
=
()
=>
{
wrapper
.
setData
({
edit
:
true
});
return
(
// wait for edit form to become visible
wrapper
.
vm
.
$nextTick
()
.
then
(()
=>
{
const
editForm
=
wrapper
.
find
(
EditForm
);
const
{
updateConfidentialAttribute
}
=
editForm
.
props
();
updateConfidentialAttribute
();
})
// wait for reCAPTCHA modal to render
.
then
(()
=>
wrapper
.
vm
.
$nextTick
())
);
};
};
const
createComponent
=
propsData
=>
{
const
service
=
new
SidebarService
();
wrapper
=
shallowMount
(
ConfidentialIssueSidebar
,
{
wrapper
=
shallowMount
(
ConfidentialIssueSidebar
,
{
propsData
:
{
propsData
:
{
service
,
service
,
...
@@ -20,6 +41,15 @@ describe('Confidential Issue Sidebar Block', () => {
...
@@ -20,6 +41,15 @@ describe('Confidential Issue Sidebar Block', () => {
});
});
};
};
beforeEach
(()
=>
{
jest
.
clearAllMocks
();
jest
.
spyOn
(
window
.
location
,
'
reload
'
).
mockImplementation
();
});
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
.
each
`
it
.
each
`
isConfidential | isEditable
isConfidential | isEditable
${
false
}
|
${
false
}
${
false
}
|
${
false
}
...
@@ -38,10 +68,6 @@ describe('Confidential Issue Sidebar Block', () => {
...
@@ -38,10 +68,6 @@ describe('Confidential Issue Sidebar Block', () => {
},
},
);
);
afterEach
(()
=>
{
wrapper
.
destroy
();
});
describe
(
'
if editable
'
,
()
=>
{
describe
(
'
if editable
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
({
createComponent
({
...
@@ -81,5 +107,61 @@ describe('Confidential Issue Sidebar Block', () => {
...
@@ -81,5 +107,61 @@ describe('Confidential Issue Sidebar Block', () => {
property
:
'
confidentiality
'
,
property
:
'
confidentiality
'
,
});
});
});
});
describe
(
'
for successful update
'
,
()
=>
{
beforeEach
(()
=>
{
SidebarService
.
prototype
.
update
.
mockResolvedValue
({
data
:
'
irrelevant
'
});
});
it
(
'
reloads the page
'
,
()
=>
triggerUpdateConfidentialAttribute
().
then
(()
=>
{
expect
(
window
.
location
.
reload
).
toHaveBeenCalled
();
}));
it
(
'
does not show an error message
'
,
()
=>
triggerUpdateConfidentialAttribute
().
then
(()
=>
{
expect
(
createFlash
).
not
.
toHaveBeenCalled
();
}));
});
describe
(
'
for update error
'
,
()
=>
{
beforeEach
(()
=>
{
SidebarService
.
prototype
.
update
.
mockRejectedValue
(
new
Error
(
'
updating failed!
'
));
});
it
(
'
does not reload the page
'
,
()
=>
triggerUpdateConfidentialAttribute
().
then
(()
=>
{
expect
(
window
.
location
.
reload
).
not
.
toHaveBeenCalled
();
}));
it
(
'
shows an error message
'
,
()
=>
triggerUpdateConfidentialAttribute
().
then
(()
=>
{
expect
(
createFlash
).
toHaveBeenCalled
();
}));
});
describe
(
'
for spam error
'
,
()
=>
{
beforeEach
(()
=>
{
SidebarService
.
prototype
.
update
.
mockRejectedValue
({
name
:
'
SpamError
'
});
});
it
(
'
does not reload the page
'
,
()
=>
triggerUpdateConfidentialAttribute
().
then
(()
=>
{
expect
(
window
.
location
.
reload
).
not
.
toHaveBeenCalled
();
}));
it
(
'
does not show an error message
'
,
()
=>
triggerUpdateConfidentialAttribute
().
then
(()
=>
{
expect
(
createFlash
).
not
.
toHaveBeenCalled
();
}));
it
(
'
shows a reCAPTCHA modal
'
,
()
=>
{
expect
(
findRecaptchaModal
().
exists
()).
toBe
(
false
);
return
triggerUpdateConfidentialAttribute
().
then
(()
=>
{
expect
(
findRecaptchaModal
().
exists
()).
toBe
(
true
);
});
});
});
});
});
});
});
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