Commit 9551fabd authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Hide empty namespace without a search match

Minor cleanup jest tests

Addresses some minor review comments with
the jest tests for the transfer group form.
parent 81482ff7
...@@ -41,7 +41,7 @@ export default () => { ...@@ -41,7 +41,7 @@ export default () => {
}, },
on: { on: {
confirm: () => { confirm: () => {
if (targetFormId) document.getElementById(targetFormId)?.submit(); document.getElementById(targetFormId)?.submit();
}, },
}, },
}); });
......
...@@ -83,6 +83,10 @@ export default { ...@@ -83,6 +83,10 @@ export default {
selectedNamespaceText() { selectedNamespaceText() {
return this.selectedNamespace?.humanName || this.defaultText; return this.selectedNamespace?.humanName || this.defaultText;
}, },
filteredEmptyNamespaceTitle() {
const { includeEmptyNamespace, emptyNamespaceTitle, searchTerm } = this;
return includeEmptyNamespace && emptyNamespaceTitle.toLowerCase().includes(searchTerm);
},
}, },
methods: { methods: {
handleSelect(item) { handleSelect(item) {
...@@ -101,7 +105,7 @@ export default { ...@@ -101,7 +105,7 @@ export default {
<template #header> <template #header>
<gl-search-box-by-type v-model.trim="searchTerm" /> <gl-search-box-by-type v-model.trim="searchTerm" />
</template> </template>
<div v-if="includeEmptyNamespace"> <div v-if="filteredEmptyNamespaceTitle">
<gl-dropdown-item <gl-dropdown-item
data-qa-selector="namespaces_list_item" data-qa-selector="namespaces_list_item"
@click="handleSelectEmptyNamespace()" @click="handleSelectEmptyNamespace()"
......
...@@ -17346,9 +17346,6 @@ msgstr "" ...@@ -17346,9 +17346,6 @@ msgstr ""
msgid "GroupSettings|There was a problem updating the pipeline settings: %{error_messages}." msgid "GroupSettings|There was a problem updating the pipeline settings: %{error_messages}."
msgstr "" msgstr ""
msgid "GroupSettings|This group can't be transferred because it is linked to a subscription. To transfer this group, %{linkStart}link the subscription%{linkEnd} with a different group."
msgstr ""
msgid "GroupSettings|This setting is applied on %{ancestor_group} and has been overridden on this subgroup." msgid "GroupSettings|This setting is applied on %{ancestor_group} and has been overridden on this subgroup."
msgstr "" msgstr ""
...@@ -36629,6 +36626,9 @@ msgstr "" ...@@ -36629,6 +36626,9 @@ msgstr ""
msgid "This group can't be removed because it is linked to a subscription. To remove this group, %{linkStart}link the subscription%{linkEnd} with a different group." msgid "This group can't be removed because it is linked to a subscription. To remove this group, %{linkStart}link the subscription%{linkEnd} with a different group."
msgstr "" msgstr ""
msgid "This group can't be transfered because it is linked to a subscription. To transfer this group, %{linkStart}link the subscription%{linkEnd} with a different group."
msgstr ""
msgid "This group cannot be invited to a project inside a group with enforced SSO" msgid "This group cannot be invited to a project inside a group with enforced SSO"
msgstr "" msgstr ""
......
import { GlAlert, GlSprintf } from '@gitlab/ui'; import { GlAlert, GlSprintf } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import Component, { i18n } from '~/groups/components/transfer_group_form.vue'; import Component from '~/groups/components/transfer_group_form.vue';
import ConfirmDanger from '~/vue_shared/components/confirm_danger/confirm_danger.vue'; import ConfirmDanger from '~/vue_shared/components/confirm_danger/confirm_danger.vue';
import NamespaceSelect from '~/vue_shared/components/namespace_select/namespace_select.vue'; import NamespaceSelect from '~/vue_shared/components/namespace_select/namespace_select.vue';
...@@ -43,14 +43,15 @@ describe('Transfer group form', () => { ...@@ -43,14 +43,15 @@ describe('Transfer group form', () => {
const findNamespaceSelect = () => wrapper.findComponent(NamespaceSelect); const findNamespaceSelect = () => wrapper.findComponent(NamespaceSelect);
const findHiddenInput = () => wrapper.find('[name="new_parent_group_id"]'); const findHiddenInput = () => wrapper.find('[name="new_parent_group_id"]');
beforeEach(() => {
wrapper = createComponent();
});
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
}); });
describe('default', () => {
beforeEach(() => {
wrapper = createComponent();
});
it('renders the namespace select component', () => { it('renders the namespace select component', () => {
expect(findNamespaceSelect().exists()).toBe(true); expect(findNamespaceSelect().exists()).toBe(true);
}); });
...@@ -87,10 +88,12 @@ describe('Transfer group form', () => { ...@@ -87,10 +88,12 @@ describe('Transfer group form', () => {
phrase: confirmationPhrase, phrase: confirmationPhrase,
}); });
}); });
});
describe('with a selected project', () => { describe('with a selected project', () => {
const [firstGroup] = groups; const [firstGroup] = groups;
beforeEach(() => { beforeEach(() => {
wrapper = createComponent();
findNamespaceSelect().vm.$emit('select', firstGroup); findNamespaceSelect().vm.$emit('select', firstGroup);
}); });
...@@ -117,14 +120,6 @@ describe('Transfer group form', () => { ...@@ -117,14 +120,6 @@ describe('Transfer group form', () => {
wrapper = createComponent({ isPaidGroup: true }); wrapper = createComponent({ isPaidGroup: true });
}); });
it('renders a warning alert with a link for additional information', () => {
expect(findAlert().text()).toMatchInterpolatedText(i18n.paidGroupMessage);
expect(findAlert().props()).toMatchObject({
dismissible: false,
variant: 'warning',
});
});
it('disables the transfer button', () => { it('disables the transfer button', () => {
expect(findConfirmDanger().props()).toMatchObject({ disabled: true }); expect(findConfirmDanger().props()).toMatchObject({ disabled: true });
}); });
......
import { nextTick } from 'vue';
import { GlDropdown, GlDropdownItem, GlDropdownSectionHeader } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlDropdownSectionHeader } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import NamespaceSelect, { import NamespaceSelect, {
...@@ -99,12 +100,12 @@ describe('Namespace Select', () => { ...@@ -99,12 +100,12 @@ describe('Namespace Select', () => {
describe('with an empty namespace option', () => { describe('with an empty namespace option', () => {
const emptyNamespaceTitle = 'No namespace selected'; const emptyNamespaceTitle = 'No namespace selected';
beforeEach(() => { beforeEach(async () => {
wrapper = createComponent({ wrapper = createComponent({
includeEmptyNamespace: true, includeEmptyNamespace: true,
emptyNamespaceTitle, emptyNamespaceTitle,
}); });
return wrapper.vm.$nextTick(); await nextTick();
}); });
it('includes the empty namespace', () => { it('includes the empty namespace', () => {
......
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