Commit f7b6dce6 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Update affected specs

Updates the confirm danger jest tests and
the user changes project visibility rspec
tests
parent db85f723
...@@ -2,6 +2,15 @@ import Vue from 'vue'; ...@@ -2,6 +2,15 @@ import Vue from 'vue';
import { parseBoolean } from './lib/utils/common_utils'; import { parseBoolean } from './lib/utils/common_utils';
import ConfirmDanger from './vue_shared/components/confirm_danger/confirm_danger.vue'; import ConfirmDanger from './vue_shared/components/confirm_danger/confirm_danger.vue';
const omitEmptyProperties = (fields) => {
return Object.entries(fields).reduce((acc, [key, value]) => {
if (value) {
return { ...acc, [key]: value };
}
return acc;
}, {});
};
export default () => { export default () => {
const el = document.querySelector('.js-confirm-danger'); const el = document.querySelector('.js-confirm-danger');
if (!el) return null; if (!el) return null;
...@@ -12,7 +21,9 @@ export default () => { ...@@ -12,7 +21,9 @@ export default () => {
buttonText, buttonText,
buttonClass = '', buttonClass = '',
buttonTestid = null, buttonTestid = null,
buttonVariant = null,
confirmDangerMessage, confirmDangerMessage,
confirmButtonText = null,
disabled = false, disabled = false,
additionalInformation, additionalInformation,
htmlConfirmationMessage, htmlConfirmationMessage,
...@@ -20,17 +31,19 @@ export default () => { ...@@ -20,17 +31,19 @@ export default () => {
return new Vue({ return new Vue({
el, el,
provide: { provide: omitEmptyProperties({
htmlConfirmationMessage, htmlConfirmationMessage,
confirmDangerMessage, confirmDangerMessage,
additionalInformation, additionalInformation,
}, confirmButtonText,
}),
render: (createElement) => render: (createElement) =>
createElement(ConfirmDanger, { createElement(ConfirmDanger, {
props: { props: {
phrase, phrase,
buttonText, buttonText,
buttonClass, buttonClass,
buttonVariant,
buttonTestid, buttonTestid,
disabled: parseBoolean(disabled), disabled: parseBoolean(disabled),
}, },
......
...@@ -36,6 +36,11 @@ export default { ...@@ -36,6 +36,11 @@ export default {
required: false, required: false,
default: 'confirm-danger-button', default: 'confirm-danger-button',
}, },
buttonVariant: {
type: String,
required: false,
default: 'danger',
},
}, },
modalId: CONFIRM_DANGER_MODAL_ID, modalId: CONFIRM_DANGER_MODAL_ID,
}; };
...@@ -45,7 +50,7 @@ export default { ...@@ -45,7 +50,7 @@ export default {
<gl-button <gl-button
v-gl-modal="$options.modalId" v-gl-modal="$options.modalId"
:class="buttonClass" :class="buttonClass"
variant="danger" :variant="buttonVariant"
:disabled="disabled" :disabled="disabled"
:data-testid="buttonTestid" :data-testid="buttonTestid"
>{{ buttonText }}</gl-button >{{ buttonText }}</gl-button
......
...@@ -677,8 +677,9 @@ module ProjectsHelper ...@@ -677,8 +677,9 @@ module ProjectsHelper
remove_form_id: remove_form_id, remove_form_id: remove_form_id,
qa_selector: 'visibility_features_permissions_save_button', qa_selector: 'visibility_features_permissions_save_button',
button_text: _('Save changes'), button_text: _('Save changes'),
confirm_button_text: _('Reduce project visibility'),
button_testid: 'reduce-project-visibility-button', button_testid: 'reduce-project-visibility-button',
button_variant: 'confirm',
confirm_button_text: _('Reduce project visibility'),
confirm_danger_message: confirm_reduce_visibility_message(project), confirm_danger_message: confirm_reduce_visibility_message(project),
phrase: project.full_path, phrase: project.full_path,
additional_information: _('Note: current forks will keep their visibility level.'), additional_information: _('Note: current forks will keep their visibility level.'),
......
...@@ -24,7 +24,7 @@ RSpec.describe 'User changes public project visibility', :js do ...@@ -24,7 +24,7 @@ RSpec.describe 'User changes public project visibility', :js do
# binding.pry # binding.pry
find('.js-confirm-danger-input').send_keys(project.path_with_namespace) fill_in 'confirm_name_input', with: project.path_with_namespace
page.within '.modal' do page.within '.modal' do
click_button 'Reduce project visibility' click_button 'Reduce project visibility'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment