Skip to content
Snippets Groups Projects
Commit 72cf6b93 authored by Ross Byrne's avatar Ross Byrne Committed by Doug Stull
Browse files

Remove namespace select after group create fails during trial creation

Changelog: changed
EE: true
parent 4e0125b2
No related branches found
No related tags found
1 merge request!121158Remove namespace select after group create fails during trial creation
......@@ -32,6 +32,11 @@ export default {
required: false,
default: null,
},
hideNamespaceSelector: {
type: Boolean,
required: false,
default: false,
},
},
data() {
return {
......@@ -40,6 +45,9 @@ export default {
};
},
computed: {
showNamespaceSelector() {
return this.anyTrialEligibleNamespaces && !this.hideNamespaceSelector;
},
showNewGroupNameField() {
return !this.anyTrialEligibleNamespaces || this.selectedGroup === CREATE_GROUP_OPTION_VALUE;
},
......@@ -50,7 +58,7 @@ export default {
<template>
<div>
<listbox-input
v-if="anyTrialEligibleNamespaces"
v-if="showNamespaceSelector"
v-model="selectedGroup"
name="namespace_id"
label-for="namespace_id"
......
......@@ -12,7 +12,12 @@ export const initNamespaceSelector = () => {
}
const items = JSON.parse(el.dataset.items);
const { anyTrialEligibleNamespaces, newGroupName, initialValue } = el.dataset;
const {
anyTrialEligibleNamespaces,
newGroupName,
initialValue,
hideNamespaceSelector,
} = el.dataset;
return new Vue({
el,
......@@ -23,6 +28,7 @@ export const initNamespaceSelector = () => {
newGroupName,
initialValue,
items,
hideNamespaceSelector: parseBoolean(hideNamespaceSelector),
},
}),
});
......
......@@ -46,8 +46,15 @@ def create
elsif result.reason == :lead_failed
@create_errors = result.errors.to_sentence
render :new
elsif result.reason == :namespace_create_failed
# namespace creation failed
@create_errors = result.errors.to_sentence
@hide_namespace_selector = true
params[:namespace_id] = result.payload[:namespace_id]
render :select_namespace_form
else
# namespace creation or trial failed
# trial failed
@create_errors = result.errors.to_sentence
params[:namespace_id] = result.payload[:namespace_id]
......
......@@ -16,7 +16,7 @@
= form_tag trials_path(**glm_params, step: GitlabSubscriptions::Trials::CreateService::TRIAL), method: :post, class: 'js-saas-trial-group', data: { testid: 'trial-form' } do
.js-namespace-selector{ data: { any_trial_eligible_namespaces: any_trial_eligible_namespaces?.to_s, new_group_name: params[:new_group_name],
items: namespace_options_for_listbox.to_json, initial_value: params[:namespace_id] } }
items: namespace_options_for_listbox.to_json, initial_value: params[:namespace_id], hide_namespace_selector: @hide_namespace_selector.to_s } }
- if should_ask_company_question?
.form-group
= label_tag :trial_entity, _('Who will be using GitLab?')
......
......@@ -88,16 +88,6 @@
select_from_listbox 'Create group', from: 'Please select a group'
wait_for_requests
# namespace invalid check
fill_in_trial_selection_form_for_new_group(name: '_invalid group name_')
click_button 'Start your free trial'
# We really shouldn't be showing the selector at this point.
# issue: https://gitlab.com/gitlab-org/gitlab/-/issues/405125
expect_to_be_on_namespace_selection
expect_to_have_namespace_creation_errors
# success
fill_in_trial_selection_form_for_new_group
......@@ -107,8 +97,8 @@
end
end
context 'when selecting to create a new group initially and then using selected group instead' do
it 'fills out form, submits and lands on the group page' do
context 'when selecting to create a new group with an invalid group name' do
it 'fills out form, submits and is presented with error then fills out valid name' do
sign_in(user)
visit new_trial_path
......@@ -127,17 +117,14 @@
click_button 'Start your free trial'
# We really shouldn't be showing the selector at this point.
# issue: https://gitlab.com/gitlab-org/gitlab/-/issues/405125
expect_to_be_on_namespace_selection
expect_to_have_namespace_creation_errors
# success when choosing an existing namespace instead
fill_in_trial_selection_form(from: 'Create group')
# success when choosing a valid name instead
fill_in_trial_selection_form_for_new_group(name: 'valid')
submit_trial_selection_form
submit_new_group_trial_selection_form(extra_params: new_group_attrs(path: 'valid', name: 'valid'))
expect_to_be_on_group_page
expect_to_be_on_group_page(path: 'valid')
end
end
......
......@@ -23,7 +23,7 @@
# required field check
message = page.find_field('new_group_name').native.attribute('validationMessage')
expect(message).to eq('Please fill out this field.')
expect(message).to match(/Please fill [a-z]+ this field./)
# namespace invalid check
fill_in_trial_form_for_new_group(name: '_invalid group name_')
......
......@@ -36,6 +36,12 @@ describe('NamespaceSelector', () => {
expect(findListboxInput().exists()).toBe(false);
});
it('is hidden if hideNamespaceSelector is true', () => {
createComponent({ hideNamespaceSelector: true });
expect(findListboxInput().exists()).toBe(false);
});
});
describe('"New group name" input', () => {
......
......@@ -29,6 +29,7 @@ def expect_to_have_namespace_creation_errors(group_name: '_invalid group name_')
end
within('[data-testid="trial-form"]') do
expect(page).not_to have_content('This subscription is for')
expect(page.find_field('new_group_name').value).to eq(group_name)
end
end
......@@ -145,12 +146,12 @@ def existing_group_attrs
{ namespace: group.slice(:id, :name, :path, :kind, :trial_ends_on) }
end
def new_group_attrs(path: 'gitlab')
def new_group_attrs(path: 'gitlab', name: 'gitlab')
{
namespace: {
id: anything,
path: path,
name: 'gitlab',
name: name,
kind: 'group',
trial_ends_on: nil
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment