Commit 49c39a7e authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Update QA selectors and remove old tests

Removes the older haml spec tests, these
will be replaced with vuejs tests.
parent 17606b5d
...@@ -76,16 +76,11 @@ export default { ...@@ -76,16 +76,11 @@ export default {
:default-text="$options.i18n.dropdownTitle" :default-text="$options.i18n.dropdownTitle"
:data="parentGroups" :data="parentGroups"
:empty-namespace-title="$options.i18n.emptyNamespaceTitle" :empty-namespace-title="$options.i18n.emptyNamespaceTitle"
:include-headers="false"
include-empty-namespace include-empty-namespace
include-headers
@select="handleSelected" @select="handleSelected"
/> />
<input <input type="hidden" name="new_parent_group_id" :value="selectedId" />
id="new_parent_group_id"
type="hidden"
name="new_parent_group_id"
:value="selectedId"
/>
</gl-form-group> </gl-form-group>
<gl-alert v-if="isPaidGroup" class="gl-mb-5"> <gl-alert v-if="isPaidGroup" class="gl-mb-5">
<gl-sprintf :message="$options.i18n.paidGroupMessage"> <gl-sprintf :message="$options.i18n.paidGroupMessage">
......
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
} from '@gitlab/ui'; } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
export const EMPTY_NAMESPACE_ID = -1
export const i18n = { export const i18n = {
DEFAULT_TEXT: __('Select a new namespace'), DEFAULT_TEXT: __('Select a new namespace'),
DEFAULT_EMPTY_NAMESPACE_TEXT: __('No namespace'), DEFAULT_EMPTY_NAMESPACE_TEXT: __('No namespace'),
...@@ -45,7 +46,7 @@ export default { ...@@ -45,7 +46,7 @@ export default {
includeHeaders: { includeHeaders: {
type: Boolean, type: Boolean,
required: false, required: false,
default: false, default: true,
}, },
emptyNamespaceTitle: { emptyNamespaceTitle: {
type: String, type: String,
...@@ -95,7 +96,7 @@ export default { ...@@ -95,7 +96,7 @@ export default {
this.$emit('select', item); this.$emit('select', item);
}, },
handleSelectEmptyNamespace() { handleSelectEmptyNamespace() {
this.handleSelect({ id: -1, humanName: this.emptyNamespace }); this.handleSelect({ id: EMPTY_NAMESPACE_ID, humanName: this.emptyNamespace });
}, },
}, },
i18n, i18n,
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'groups/settings/_transfer.html.haml' do
describe 'render' do
let(:group) { create(:group) }
it 'enables the Select parent group dropdown and does not show an alert for a group' do
render 'groups/settings/transfer', group: group
expect(rendered).to have_button 'Select parent group'
expect(rendered).not_to have_button 'Select parent group', disabled: true
expect(rendered).not_to have_text "This group can't be transfered because it is linked to a subscription."
end
it 'disables the Select parent group dropdown and shows an alert for a group with a paid gitlab.com plan', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
render 'groups/settings/transfer', group: group
expect(rendered).to have_button 'Select parent group', disabled: true
expect(rendered).to have_text "This group can't be transfered because it is linked to a subscription."
end
it 'enables the Select parent group dropdown and does not show an alert for a subgroup', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
subgroup = create(:group, parent: group)
render 'groups/settings/transfer', group: subgroup
expect(rendered).to have_button 'Select parent group'
expect(rendered).not_to have_button 'Select parent group', disabled: true
expect(rendered).not_to have_text "This group can't be transfered because it is linked to a subscription."
end
end
end
...@@ -17289,9 +17289,6 @@ msgstr "" ...@@ -17289,9 +17289,6 @@ msgstr ""
msgid "GroupSettings|Overrides user notification preferences for all members of the group, subgroups, and projects." msgid "GroupSettings|Overrides user notification preferences for all members of the group, subgroups, and projects."
msgstr "" msgstr ""
msgid "GroupSettings|Parent Group"
msgstr ""
msgid "GroupSettings|Pipeline settings was updated for the group" msgid "GroupSettings|Pipeline settings was updated for the group"
msgstr "" msgstr ""
...@@ -17319,9 +17316,6 @@ msgstr "" ...@@ -17319,9 +17316,6 @@ msgstr ""
msgid "GroupSettings|Projects will be permanently deleted after a %{waiting_period}-day delay. This delay can be %{link_start}customized by an admin%{link_end} in instance settings. Inherited by subgroups." msgid "GroupSettings|Projects will be permanently deleted after a %{waiting_period}-day delay. This delay can be %{link_start}customized by an admin%{link_end} in instance settings. Inherited by subgroups."
msgstr "" msgstr ""
msgid "GroupSettings|Search groups"
msgstr ""
msgid "GroupSettings|Select a project with the %{code_start}.gitlab/insights.yml%{code_end} file" msgid "GroupSettings|Select a project with the %{code_start}.gitlab/insights.yml%{code_end} file"
msgstr "" msgstr ""
...@@ -17352,6 +17346,9 @@ msgstr "" ...@@ -17352,6 +17346,9 @@ 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 transfered 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 ""
...@@ -24210,6 +24207,9 @@ msgstr "" ...@@ -24210,6 +24207,9 @@ msgstr ""
msgid "No milestones to show" msgid "No milestones to show"
msgstr "" msgstr ""
msgid "No namespace"
msgstr ""
msgid "No other labels with such name or description" msgid "No other labels with such name or description"
msgstr "" msgstr ""
...@@ -36629,9 +36629,6 @@ msgstr "" ...@@ -36629,9 +36629,6 @@ 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 ""
...@@ -40861,6 +40858,9 @@ msgstr "" ...@@ -40861,6 +40858,9 @@ msgstr ""
msgid "You are going to remove the fork relationship from %{project_full_name}. Are you ABSOLUTELY sure?" msgid "You are going to remove the fork relationship from %{project_full_name}. Are you ABSOLUTELY sure?"
msgstr "" msgstr ""
msgid "You are going to transfer %{group_name} to another namespace. Are you ABSOLUTELY sure?"
msgstr ""
msgid "You are going to transfer %{project_full_name} to another namespace. Are you ABSOLUTELY sure?" msgid "You are going to transfer %{project_full_name} to another namespace. Are you ABSOLUTELY sure?"
msgstr "" msgstr ""
......
...@@ -7,6 +7,7 @@ module QA ...@@ -7,6 +7,7 @@ module QA
class General < QA::Page::Base class General < QA::Page::Base
include ::QA::Page::Settings::Common include ::QA::Page::Settings::Common
include Page::Component::VisibilitySetting include Page::Component::VisibilitySetting
include Page::Component::ConfirmModal
view 'app/views/groups/edit.html.haml' do view 'app/views/groups/edit.html.haml' do
element :permission_lfs_2fa_content element :permission_lfs_2fa_content
...@@ -39,7 +40,6 @@ module QA ...@@ -39,7 +40,6 @@ module QA
end end
view 'app/views/groups/settings/_transfer.html.haml' do view 'app/views/groups/settings/_transfer.html.haml' do
element :select_group_dropdown
element :transfer_group_button element :transfer_group_button
end end
...@@ -48,6 +48,10 @@ module QA ...@@ -48,6 +48,10 @@ module QA
element :dropdown_list_content element :dropdown_list_content
end end
view 'app/assets/javascripts/groups/components/transfer_group_form.vue' do
element :select_group_dropdown
end
def set_group_name(name) def set_group_name(name)
find_element(:group_name_field).send_keys([:command, 'a'], :backspace) find_element(:group_name_field).send_keys([:command, 'a'], :backspace)
find_element(:group_name_field).set name find_element(:group_name_field).set name
...@@ -122,6 +126,9 @@ module QA ...@@ -122,6 +126,9 @@ module QA
end end
click_element :transfer_group_button click_element :transfer_group_button
fill_confirmation_text(target_group)
confirm_transfer
end end
end end
end end
......
...@@ -2,6 +2,7 @@ import { GlDropdown, GlDropdownItem, GlDropdownSectionHeader } from '@gitlab/ui' ...@@ -2,6 +2,7 @@ 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, {
i18n, i18n,
EMPTY_NAMESPACE_ID,
} from '~/vue_shared/components/namespace_select/namespace_select.vue'; } from '~/vue_shared/components/namespace_select/namespace_select.vue';
import { user, group, namespaces } from './mock_data'; import { user, group, namespaces } from './mock_data';
...@@ -36,6 +37,12 @@ describe('Namespace Select', () => { ...@@ -36,6 +37,12 @@ describe('Namespace Select', () => {
expect(findDropdown().exists()).toBe(true); expect(findDropdown().exists()).toBe(true);
}); });
it('can override the default text', () => {
const textOverride = 'Select an option';
wrapper = createComponent({ defaultText: textOverride });
expect(selectedDropdownItemText()).toBe(textOverride);
});
it('renders each dropdown item', () => { it('renders each dropdown item', () => {
const items = findDropdownItems().wrappers; const items = findDropdownItems().wrappers;
expect(items).toHaveLength(flatNamespaces().length); expect(items).toHaveLength(flatNamespaces().length);
...@@ -57,6 +64,11 @@ describe('Namespace Select', () => { ...@@ -57,6 +64,11 @@ describe('Namespace Select', () => {
expect(wrappersText(headers)).toEqual([i18n.GROUPS, i18n.USERS]); expect(wrappersText(headers)).toEqual([i18n.GROUPS, i18n.USERS]);
}); });
it('can hide the group / user headers', () => {
wrapper = createComponent({ includeHeaders: false });
expect(findSectionHeaders()).toHaveLength(0);
});
it('sets the dropdown to full width', () => { it('sets the dropdown to full width', () => {
expect(findDropdownAttributes('block')).toBeUndefined(); expect(findDropdownAttributes('block')).toBeUndefined();
...@@ -83,4 +95,29 @@ describe('Namespace Select', () => { ...@@ -83,4 +95,29 @@ describe('Namespace Select', () => {
expect(wrapper.emitted('select')).toEqual([args]); expect(wrapper.emitted('select')).toEqual([args]);
}); });
}); });
describe('with an empty namespace option', () => {
const emptyNamespaceTitle = 'No namespace selected';
beforeEach(() => {
wrapper = createComponent({
includeEmptyNamespace: true,
emptyNamespaceTitle,
});
return wrapper.vm.$nextTick();
});
it('includes the empty namespace', () => {
const first = findDropdownItems().at(0);
expect(first.text()).toBe(emptyNamespaceTitle);
});
it('emits the `select` event when a namespace is selected', () => {
findDropdownItems().at(0).vm.$emit('click');
expect(wrapper.emitted('select')).toEqual([
[{ id: EMPTY_NAMESPACE_ID, humanName: emptyNamespaceTitle }],
]);
});
});
}); });
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'groups/settings/_transfer.html.haml' do
describe 'render' do
it 'enables the Select parent group dropdown and does not show an alert for a group' do
group = build(:group)
render 'groups/settings/transfer', group: group
expect(rendered).to have_button 'Select parent group'
expect(rendered).not_to have_button 'Select parent group', disabled: true
expect(rendered).not_to have_text "This group can't be transfered because it is linked to a subscription."
end
end
end
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