Commit d6e1b58f authored by Anna Vovchenko's avatar Anna Vovchenko Committed by Enrique Alcántara

Split cluster creation page into two pages

We are changing the cluster creation page from the tabs to the
two separate pages -
new and connect. It should help with the planned deprecations removal.

Changelog: changed
parent 9f49af3c
......@@ -5,9 +5,9 @@ import { s__ } from '~/locale';
export default {
i18n: {
title: s__('ClusterIntegration|Enter the details for your Kubernetes cluster'),
title: s__('ClusterIntegration|Enter your Kubernetes cluster certificate details'),
information: s__(
'ClusterIntegration|Please enter access information for your Kubernetes cluster. If you need help, you can read our %{linkStart}documentation%{linkEnd} on Kubernetes',
'ClusterIntegration|Enter details about your cluster. %{linkStart}How do I use a certificate to connect to my cluster?%{linkEnd}',
),
},
components: {
......@@ -21,7 +21,7 @@ export default {
</script>
<template>
<div>
<div class="gl-pt-4">
<h4>{{ $options.i18n.title }}</h4>
<p>
<gl-sprintf :message="$options.i18n.information">
......
......@@ -13,7 +13,7 @@ export default {
GlSprintf,
GlAlert,
},
inject: ['emptyStateHelpText', 'clustersEmptyStateImage', 'newClusterPath'],
inject: ['emptyStateHelpText', 'clustersEmptyStateImage', 'addClusterPath'],
props: {
isChildComponent: {
default: false,
......@@ -57,7 +57,7 @@ export default {
category="primary"
variant="confirm"
:disabled="!canAddCluster"
:href="newClusterPath"
:href="addClusterPath"
>
{{ $options.i18n.buttonText }}
</gl-button>
......
......@@ -9,9 +9,9 @@ class Clusters::ClustersController < Clusters::BaseController
before_action :generate_gcp_authorize_url, only: [:new]
before_action :validate_gcp_token, only: [:new]
before_action :gcp_cluster, only: [:new]
before_action :user_cluster, only: [:new]
before_action :user_cluster, only: [:new, :connect]
before_action :authorize_read_cluster!, only: [:show, :index]
before_action :authorize_create_cluster!, only: [:new, :authorize_aws_role]
before_action :authorize_create_cluster!, only: [:new, :connect, :authorize_aws_role]
before_action :authorize_update_cluster!, only: [:update]
before_action :update_applications_status, only: [:cluster_status]
before_action :ensure_feature_enabled!, except: :index
......@@ -152,7 +152,7 @@ class Clusters::ClustersController < Clusters::BaseController
validate_gcp_token
gcp_cluster
render :new, locals: { active_tab: 'add' }
render :connect
end
end
......
# frozen_string_literal: true
module ClustersHelper
def create_new_cluster_label(provider: nil)
case provider
when 'aws'
s_('ClusterIntegration|Create new cluster on EKS')
when 'gcp'
s_('ClusterIntegration|Create new cluster on GKE')
else
s_('ClusterIntegration|Create new cluster')
end
end
def display_cluster_agents?(clusterable)
clusterable.is_a?(Project)
end
......@@ -27,8 +16,8 @@ module ClustersHelper
},
clusters_empty_state_image: image_path('illustrations/empty-state/empty-state-clusters.svg'),
empty_state_help_text: clusterable.empty_state_help_text,
new_cluster_path: clusterable.new_path(tab: 'create'),
add_cluster_path: clusterable.new_path(tab: 'add'),
new_cluster_path: clusterable.new_path,
add_cluster_path: clusterable.connect_path,
can_add_cluster: clusterable.can_add_cluster?.to_s,
can_admin_cluster: clusterable.can_admin_cluster?.to_s,
display_cluster_agents: display_cluster_agents?(clusterable).to_s,
......
......@@ -32,6 +32,10 @@ class ClusterablePresenter < Gitlab::View::Presenter::Delegated
new_polymorphic_path([clusterable, :cluster], options)
end
def connect_path
polymorphic_path([clusterable, :clusters], action: :connect)
end
def authorize_aws_role_path
polymorphic_path([clusterable, :clusters], action: :authorize_aws_role)
end
......
......@@ -38,6 +38,11 @@ class InstanceClusterablePresenter < ClusterablePresenter
admin_cluster_path(cluster, params)
end
override :connect_path
def connect_path
connect_admin_clusters_path
end
override :create_user_clusters_path
def create_user_clusters_path
create_user_admin_clusters_path
......
......@@ -22,12 +22,12 @@ class ProjectClusterablePresenter < ClusterablePresenter
override :sidebar_text
def sidebar_text
s_('ClusterIntegration|With a Kubernetes cluster associated to this project, you can use review apps, deploy your applications, run your pipelines, and much more in an easy way.')
s_('ClusterIntegration|Use GitLab to deploy to your cluster, run jobs, use review apps, and more.')
end
override :learn_more_link
def learn_more_link
ApplicationController.helpers.link_to(s_('ClusterIntegration|Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer')
ApplicationController.helpers.link_to(s_('ClusterIntegration|Learn more about Kubernetes.'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer')
end
def metrics_dashboard_path(cluster)
......
......@@ -2,5 +2,5 @@
- help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe
- help_link_end = '</a>'.html_safe
%p
= s_('ClusterIntegration|If you are setting up multiple clusters and are using Auto DevOps, %{help_link_start}read this first%{help_link_end}.').html_safe % { help_link_start: help_link_start % { url: autodevops_help_url }, help_link_end: help_link_end }
%p.gl-font-weight-bold
= s_('ClusterIntegration|Using AutoDevOps with multiple clusters? %{help_link_start}Read this first.%{help_link_end}').html_safe % { help_link_start: help_link_start % { url: autodevops_help_url }, help_link_end: help_link_end }
%h4.gl-mt-0
= s_('ClusterIntegration|Add a Kubernetes cluster integration')
%h3
= s_('ClusterIntegration|Connect a Kubernetes cluster')
%p
= clusterable.sidebar_text
%p
......
......@@ -3,10 +3,10 @@
- logo_path = local_assigns.fetch(:logo_path)
- label = local_assigns.fetch(:label)
- last = local_assigns.fetch(:last, false)
- classes = ["btn btn-light btn-outline flex-fill d-inline-flex flex-column justify-content-center align-items-center w-50 js-create-#{provider}-cluster-button"]
- conditional_classes = [('mr-3' unless last), ('active' if is_current_provider)]
- classes = ["btn btn-confirm gl-button btn-confirm-secondary gl-flex-direction-column gl-w-half js-create-#{provider}-cluster-button"]
- conditional_classes = [('gl-mr-5' unless last), ('active' if is_current_provider)]
= link_to clusterable.new_path(provider: provider), class: classes + conditional_classes do
.svg-content.p-2= image_tag logo_path, alt: label, class: 'gl-w-64 gl-h-64'
.svg-content.gl-p-3= image_tag logo_path, alt: label, class: 'gl-w-64 gl-h-64'
%span
= label
- gke_label = s_('ClusterIntegration|Google GKE')
- eks_label = s_('ClusterIntegration|Amazon EKS')
- create_cluster_label = s_('ClusterIntegration|Create cluster on')
.d-flex.flex-column.p-3
%h4.mb-3
- create_cluster_label = s_('ClusterIntegration|Where do you want to create a cluster?')
.gl-p-5
%h4.gl-mb-5
= create_cluster_label
.d-flex
.gl-display-flex
= render partial: 'clusters/clusters/cloud_providers/cloud_provider_button',
locals: { provider: 'aws', label: eks_label, logo_path: 'illustrations/logos/amazon_eks.svg' }
= render partial: 'clusters/clusters/cloud_providers/cloud_provider_button',
......
- @content_class = 'limit-container-width' unless fluid_layout
- add_to_breadcrumbs _('Kubernetes Clusters'), clusterable.index_path
- breadcrumb_title _('Connect a cluster')
- page_title _('Connect a Kubernetes Cluster')
.row.gl-mt-3
.col-md-3
= render 'sidebar'
.col-md-9
#js-cluster-new{ data: js_cluster_new }
= render 'clusters/clusters/user/form'
......@@ -67,20 +67,20 @@
label_class: 'label-bold' }
.form-text.text-muted
= s_('ClusterIntegration|Uses the Cloud Run, Istio, and HTTP Load Balancing addons for this cluster.')
= link_to _('More information'), help_page_path('user/project/clusters/add_gke_clusters.md', anchor: 'cloud-run-for-anthos'), target: '_blank', rel: 'noopener noreferrer'
= link_to _('Learn more.'), help_page_path('user/project/clusters/add_gke_clusters.md', anchor: 'cloud-run-for-anthos'), target: '_blank', rel: 'noopener noreferrer'
.form-group
= field.check_box :managed, { label: s_('ClusterIntegration|GitLab-managed cluster'),
label_class: 'label-bold' }
.form-text.text-muted
= s_('ClusterIntegration|Allow GitLab to manage namespaces and service accounts for this cluster.')
= link_to _('More information'), help_page_path('user/project/clusters/gitlab_managed_clusters.md'), target: '_blank', rel: 'noopener noreferrer'
= link_to _('Learn more.'), help_page_path('user/project/clusters/gitlab_managed_clusters.md'), target: '_blank', rel: 'noopener noreferrer'
.form-group
= field.check_box :namespace_per_environment, { label: s_('ClusterIntegration|Namespace per environment'), label_class: 'label-bold' }
.form-text.text-muted
= s_('ClusterIntegration|Deploy each environment to its own namespace. Otherwise, environments within a project share a project-wide namespace. Note that anyone who can trigger a deployment of a namespace can read its secrets. If modified, existing environments will use their current namespaces until the cluster cache is cleared.')
= link_to _('More information'), help_page_path('user/project/clusters/deploy_to_cluster.md', anchor: 'custom-namespace'), target: '_blank', rel: 'noopener noreferrer'
= link_to _('Learn more.'), help_page_path('user/project/clusters/deploy_to_cluster.md', anchor: 'custom-namespace'), target: '_blank', rel: 'noopener noreferrer'
.form-group.js-gke-cluster-creation-submit-container
= field.submit s_('ClusterIntegration|Create Kubernetes cluster'),
......
- breadcrumb_title _('Kubernetes')
- page_title _('Kubernetes Cluster')
- @content_class = 'limit-container-width' unless fluid_layout
- add_to_breadcrumbs _('Kubernetes Clusters'), clusterable.index_path
- breadcrumb_title _('Create a cluster')
- page_title _('Create a Kubernetes cluster')
- provider = params[:provider]
- active_tab = params[:tab] || local_assigns.fetch(:active_tab, 'create')
- is_active_tab_create = active_tab === 'create'
- is_active_tab_add = active_tab === 'add'
= render_gcp_signup_offer
......@@ -11,21 +10,8 @@
.col-md-3
= render 'sidebar'
.col-md-9
= gl_tabs_nav({ class: 'nav-justified' }) do
= gl_tab_link_to clusterable.new_path(tab: 'create'), { item_active: is_active_tab_create } do
%span= create_new_cluster_label(provider: params[:provider])
= gl_tab_link_to s_('ClusterIntegration|Connect existing cluster'), clusterable.new_path(tab: 'add'), { item_active: is_active_tab_add, qa_selector: 'add_existing_cluster_tab' }
= render 'clusters/clusters/cloud_providers/cloud_provider_selector'
.tab-content
- if is_active_tab_create
.tab-pane.active{ role: 'tabpanel' }
= render 'clusters/clusters/cloud_providers/cloud_provider_selector'
- if ['aws', 'gcp'].include?(provider)
.p-3.border-top
= render "clusters/clusters/#{provider}/new"
- if is_active_tab_add
.tab-pane.active.gl-p-5{ role: 'tabpanel' }
#js-cluster-new{ data: js_cluster_new }
= render 'clusters/clusters/user/form'
- if ['aws', 'gcp'].include?(provider)
.gl-p-5.gl-border-1.gl-border-t-solid.gl-border-gray-100
= render "clusters/clusters/#{provider}/new"
- more_info_link = link_to _('More information'), help_page_path('user/project/clusters/add_remove_clusters.md',
- more_info_link = link_to _('Learn more.'), help_page_path('user/project/clusters/add_remove_clusters.md',
anchor: 'add-existing-cluster'), target: '_blank', rel: 'noopener noreferrer'
- rbac_help_link = link_to _('More information'), help_page_path('user/project/clusters/add_remove_clusters.md',
- rbac_help_link = link_to _('Learn more.'), help_page_path('user/project/clusters/add_remove_clusters.md',
anchor: 'access-controls'), target: '_blank', rel: 'noopener noreferrer'
- api_url_help_text = s_('ClusterIntegration|The URL used to access the Kubernetes API.')
......@@ -47,13 +47,13 @@
label_class: 'label-bold' }
.form-text.text-muted
= s_('ClusterIntegration|Allow GitLab to manage namespaces and service accounts for this cluster.')
= link_to _('More information'), help_page_path('user/project/clusters/gitlab_managed_clusters.md'), target: '_blank', rel: 'noopener noreferrer'
= link_to _('Learn more.'), help_page_path('user/project/clusters/gitlab_managed_clusters.md'), target: '_blank', rel: 'noopener noreferrer'
.form-group
= field.check_box :namespace_per_environment, { label: s_('ClusterIntegration|Namespace per environment'), label_class: 'label-bold' }
.form-text.text-muted
= s_('ClusterIntegration|Deploy each environment to its own namespace. Otherwise, environments within a project share a project-wide namespace. Note that anyone who can trigger a deployment of a namespace can read its secrets. If modified, existing environments will use their current namespaces until the cluster cache is cleared.')
= link_to _('More information'), help_page_path('user/project/clusters/deploy_to_cluster.md', anchor: 'custom-namespace'), target: '_blank', rel: 'noopener noreferrer'
= link_to _('Learn more.'), help_page_path('user/project/clusters/deploy_to_cluster.md', anchor: 'custom-namespace'), target: '_blank', rel: 'noopener noreferrer'
= field.fields_for :platform_kubernetes, @user_cluster.platform_kubernetes do |platform_kubernetes_field|
- if @user_cluster.allow_user_defined_namespace?
......
......@@ -235,6 +235,7 @@ Rails.application.routes.draw do
concern :clusterable do
resources :clusters, only: [:index, :new, :show, :update, :destroy] do
collection do
get :connect
post :create_user
post :create_gcp
post :create_aws
......
......@@ -76,17 +76,18 @@ to deploy this project to.
![Project landing page](img/guide_project_landing_page_v12_10.png)
1. On the **Add a Kubernetes cluster integration** page, select the **Create new cluster** tab,
then select **Google GKE**.
1. On the **Kubernetes clusters** page, select the **Create a new cluster** option from the **Actions** dropdown menu.
1. On the **Connect a Kubernetes cluster** page, select **Google GKE**.
1. Connect with your Google account, and select **Allow** to allow access to your
Google account. (This authorization request is only displayed the first time
you connect GitLab with your Google account.)
After authorizing access, the **Add a Kubernetes cluster integration** page
After authorizing access, the **Connect a Kubernetes cluster** page
is displayed.
1. In the **Enter the details for your Kubernetes cluster** section, provide
1. In the **Enter your Kubernetes cluster certificate details** section, provide
details about your cluster:
- **Kubernetes cluster name**
......
......@@ -69,8 +69,8 @@ To add a Kubernetes cluster to your project, group, or instance:
1. Project's **{cloud-gear}** **Infrastructure > Kubernetes clusters** page, for a project-level cluster.
1. Group's **{cloud-gear}** **Kubernetes** page, for a group-level cluster.
1. **Menu > Admin > Kubernetes** page, for an instance-level cluster.
1. Click **Add Kubernetes cluster**.
1. Click the **Add existing cluster** tab and fill in the details:
1. On the **Kubernetes clusters** page, select the **Connect with a certificate** option from the **Actions** dropdown menu.
1. On the **Connect a cluster** page, fill in the details:
1. **Kubernetes cluster name** (required) - The name you wish to give the cluster.
1. **Environment scope** (required) - The
[associated environment](multiple_kubernetes_clusters.md#setting-the-environment-scope) to this cluster.
......
......@@ -7960,9 +7960,6 @@ msgstr ""
msgid "ClusterIntegration|Add Kubernetes cluster"
msgstr ""
msgid "ClusterIntegration|Add a Kubernetes cluster integration"
msgstr ""
msgid "ClusterIntegration|Adding a Kubernetes cluster to your group will automatically share the cluster across all your projects. Use review apps, deploy your applications, and easily run your pipelines for all projects using the same cluster."
msgstr ""
......@@ -8071,7 +8068,7 @@ msgstr ""
msgid "ClusterIntegration|Clusters are utilized by selecting the nearest ancestor with a matching environment scope. For example, project clusters will override group clusters. %{linkStart}More information%{linkEnd}"
msgstr ""
msgid "ClusterIntegration|Connect existing cluster"
msgid "ClusterIntegration|Connect a Kubernetes cluster"
msgstr ""
msgid "ClusterIntegration|Connect with a certificate"
......@@ -8119,18 +8116,6 @@ msgstr ""
msgid "ClusterIntegration|Create Kubernetes cluster"
msgstr ""
msgid "ClusterIntegration|Create cluster on"
msgstr ""
msgid "ClusterIntegration|Create new cluster"
msgstr ""
msgid "ClusterIntegration|Create new cluster on EKS"
msgstr ""
msgid "ClusterIntegration|Create new cluster on GKE"
msgstr ""
msgid "ClusterIntegration|Creating Kubernetes cluster"
msgstr ""
......@@ -8164,6 +8149,9 @@ msgstr ""
msgid "ClusterIntegration|Enable this setting if using role-based access control (RBAC)."
msgstr ""
msgid "ClusterIntegration|Enter details about your cluster. %{linkStart}How do I use a certificate to connect to my cluster?%{linkEnd}"
msgstr ""
msgid "ClusterIntegration|Enter new Service Token"
msgstr ""
......@@ -8173,6 +8161,9 @@ msgstr ""
msgid "ClusterIntegration|Enter the details for your Kubernetes cluster"
msgstr ""
msgid "ClusterIntegration|Enter your Kubernetes cluster certificate details"
msgstr ""
msgid "ClusterIntegration|Environment scope"
msgstr ""
......@@ -8236,9 +8227,6 @@ msgstr ""
msgid "ClusterIntegration|HTTP Error"
msgstr ""
msgid "ClusterIntegration|If you are setting up multiple clusters and are using Auto DevOps, %{help_link_start}read this first%{help_link_end}."
msgstr ""
msgid "ClusterIntegration|If you do not wish to delete all associated GitLab resources, you can simply remove the integration."
msgstr ""
......@@ -8284,7 +8272,7 @@ msgstr ""
msgid "ClusterIntegration|Learn more about %{help_link_start}zones%{help_link_end}."
msgstr ""
msgid "ClusterIntegration|Learn more about Kubernetes"
msgid "ClusterIntegration|Learn more about Kubernetes."
msgstr ""
msgid "ClusterIntegration|Learn more about group Kubernetes clusters"
......@@ -8377,9 +8365,6 @@ msgstr ""
msgid "ClusterIntegration|Number of nodes must be a numerical value."
msgstr ""
msgid "ClusterIntegration|Please enter access information for your Kubernetes cluster. If you need help, you can read our %{linkStart}documentation%{linkEnd} on Kubernetes"
msgstr ""
msgid "ClusterIntegration|Please make sure that your Google account meets the following requirements:"
msgstr ""
......@@ -8629,12 +8614,18 @@ msgstr ""
msgid "ClusterIntegration|Unknown Error"
msgstr ""
msgid "ClusterIntegration|Use GitLab to deploy to your cluster, run jobs, use review apps, and more."
msgstr ""
msgid "ClusterIntegration|Use the %{linkStart}GitLab Agent%{linkEnd} to safely connect your Kubernetes clusters to GitLab. You can deploy your applications, run your pipelines, use Review Apps, and much more."
msgstr ""
msgid "ClusterIntegration|Uses the Cloud Run, Istio, and HTTP Load Balancing addons for this cluster."
msgstr ""
msgid "ClusterIntegration|Using AutoDevOps with multiple clusters? %{help_link_start}Read this first.%{help_link_end}"
msgstr ""
msgid "ClusterIntegration|VPC"
msgstr ""
......@@ -8647,7 +8638,7 @@ msgstr ""
msgid "ClusterIntegration|We were unable to fetch any projects. Ensure that you have a project on %{docsLinkStart}Google Cloud Platform%{docsLinkEnd}."
msgstr ""
msgid "ClusterIntegration|With a Kubernetes cluster associated to this project, you can use review apps, deploy your applications, run your pipelines, and much more in an easy way."
msgid "ClusterIntegration|Where do you want to create a cluster?"
msgstr ""
msgid "ClusterIntegration|You are about to remove your cluster integration and all GitLab-created resources associated with this cluster."
......@@ -9351,6 +9342,12 @@ msgstr ""
msgid "Connect"
msgstr ""
msgid "Connect a Kubernetes Cluster"
msgstr ""
msgid "Connect a cluster"
msgstr ""
msgid "Connect all repositories"
msgstr ""
......@@ -10185,9 +10182,15 @@ msgstr ""
msgid "Create a GitLab account first, and then connect it to your %{label} account."
msgstr ""
msgid "Create a Kubernetes cluster"
msgstr ""
msgid "Create a Mattermost team for this group"
msgstr ""
msgid "Create a cluster"
msgstr ""
msgid "Create a group"
msgstr ""
......
# frozen_string_literal: true
module QA
module Page
module Project
module Infrastructure
module Kubernetes
class Add < Page::Base
view 'app/views/clusters/clusters/new.html.haml' do
element :add_existing_cluster_tab
end
def add_existing_cluster
page.find('.gl-tab-nav-item', text: 'Connect existing cluster').click
end
end
end
end
end
end
end
......@@ -26,9 +26,6 @@ module QA
Page::Project::Infrastructure::Kubernetes::Index.perform(
&:connect_existing_cluster)
Page::Project::Infrastructure::Kubernetes::Add.perform(
&:add_existing_cluster)
Page::Project::Infrastructure::Kubernetes::AddExisting.perform do |cluster_page|
cluster_page.set_cluster_name(@cluster.cluster_name)
cluster_page.set_api_url(@cluster.api_url)
......
......@@ -8,13 +8,15 @@ RSpec.describe 'Instance-level AWS EKS Cluster', :js do
before do
sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
stub_application_setting(eks_integration_enabled: true)
end
context 'when user does not have a cluster and visits group clusters page' do
before do
visit admin_clusters_path
click_link 'Connect with a certificate'
click_button 'Actions'
click_link 'Create a new cluster'
end
context 'when user creates a cluster on AWS EKS' do
......@@ -23,7 +25,7 @@ RSpec.describe 'Instance-level AWS EKS Cluster', :js do
end
it 'user sees a form to create an EKS cluster' do
expect(page).to have_content('Create new cluster on EKS')
expect(page).to have_content('Authenticate with Amazon Web Services')
end
end
end
......
......@@ -13,13 +13,15 @@ RSpec.describe 'Group AWS EKS Cluster', :js do
allow(Groups::ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 }
allow_any_instance_of(Clusters::Kubernetes::CreateOrUpdateNamespaceService).to receive(:execute)
allow_any_instance_of(Clusters::Cluster).to receive(:retrieve_connection_status).and_return(:connected)
stub_application_setting(eks_integration_enabled: true)
end
context 'when user does not have a cluster and visits group clusters page' do
before do
visit group_clusters_path(group)
click_link 'Connect with a certificate'
click_button 'Actions'
click_link 'Create a new cluster'
end
context 'when user creates a cluster on AWS EKS' do
......@@ -28,7 +30,7 @@ RSpec.describe 'Group AWS EKS Cluster', :js do
end
it 'user sees a form to create an EKS cluster' do
expect(page).to have_content('Create new cluster on EKS')
expect(page).to have_content('Authenticate with Amazon Web Services')
end
end
end
......
......@@ -26,7 +26,6 @@ RSpec.describe 'User Cluster', :js do
visit group_clusters_path(group)
click_link 'Connect with a certificate'
click_link 'Connect existing cluster'
end
context 'when user filled form with valid parameters' do
......
......@@ -19,8 +19,8 @@ RSpec.describe 'AWS EKS Cluster', :js do
before do
visit project_clusters_path(project)
click_link 'Certificate'
click_link 'Connect with a certificate'
click_button(class: 'dropdown-toggle-split')
click_link 'Create a new cluster'
end
context 'when user creates a cluster on AWS EKS' do
......@@ -28,10 +28,6 @@ RSpec.describe 'AWS EKS Cluster', :js do
click_link 'Amazon EKS'
end
it 'user sees a form to create an EKS cluster' do
expect(page).to have_content('Create new cluster on EKS')
end
it 'highlights Amazon EKS logo' do
expect(page).to have_css('.js-create-aws-cluster-button.active')
end
......
......@@ -33,9 +33,7 @@ RSpec.describe 'Gcp Cluster', :js do
before do
visit project_clusters_path(project)
click_link 'Certificate'
click_link 'Connect with a certificate'
click_link 'Create new cluster'
visit_create_cluster_page
click_link 'Google GKE'
end
......@@ -136,7 +134,6 @@ RSpec.describe 'Gcp Cluster', :js do
before do
visit project_clusters_path(project)
click_link 'Certificate'
click_button(class: 'dropdown-toggle-split')
click_link 'Connect with a certificate'
end
......@@ -166,7 +163,6 @@ RSpec.describe 'Gcp Cluster', :js do
context 'when user has not dismissed GCP signup offer' do
before do
visit project_clusters_path(project)
click_link 'Certificate'
end
it 'user sees offer on cluster index page' do
......@@ -174,7 +170,7 @@ RSpec.describe 'Gcp Cluster', :js do
end
it 'user sees offer on cluster create page' do
click_link 'Connect with a certificate'
visit_create_cluster_page
expect(page).to have_css('.gcp-signup-offer')
end
......@@ -192,7 +188,7 @@ RSpec.describe 'Gcp Cluster', :js do
find('.gcp-signup-offer .js-close').click
wait_for_requests
click_link 'Connect with a certificate'
visit_create_cluster_page
expect(page).not_to have_css('.gcp-signup-offer')
end
......@@ -221,4 +217,9 @@ RSpec.describe 'Gcp Cluster', :js do
expect(page).not_to have_css('.gcp-signup-offer')
end
end
def visit_create_cluster_page
click_button(class: 'dropdown-toggle-split')
click_link 'Create a new cluster'
end
end
......@@ -27,7 +27,6 @@ RSpec.describe 'User Cluster', :js do
click_link 'Certificate'
click_link 'Connect with a certificate'
click_link 'Connect existing cluster'
end
context 'when user filled form with valid parameters' do
......
......@@ -34,17 +34,12 @@ RSpec.describe 'Clusters', :js do
before do
create(:cluster, :provided_by_user, name: 'default-cluster', environment_scope: '*', projects: [project])
visit project_clusters_path(project)
click_link 'Certificate'
click_button(class: 'dropdown-toggle-split')
end
it 'user sees an add cluster button' do
expect(page).to have_content('Connect with a certificate')
end
context 'when user filled form with environment scope' do
before do
click_link 'Connect with a certificate'
visit_connect_cluster_page
fill_in 'cluster_name', with: 'staging-cluster'
fill_in 'cluster_environment_scope', with: 'staging/*'
click_button 'Add Kubernetes cluster'
......@@ -72,7 +67,8 @@ RSpec.describe 'Clusters', :js do
context 'when user updates duplicated environment scope' do
before do
click_link 'Connect with a certificate'
visit_connect_cluster_page
fill_in 'cluster_name', with: 'staging-cluster'
fill_in 'cluster_environment_scope', with: '*'
fill_in 'cluster_platform_kubernetes_attributes_api_url', with: 'https://0.0.0.0'
......@@ -115,8 +111,7 @@ RSpec.describe 'Clusters', :js do
context 'when user filled form with environment scope' do
before do
click_button(class: 'dropdown-toggle-split')
click_link 'Create a new cluster'
visit_create_cluster_page
click_link 'Google GKE'
sleep 2 # wait for ajax
......@@ -160,8 +155,7 @@ RSpec.describe 'Clusters', :js do
context 'when user updates duplicated environment scope' do
before do
click_button(class: 'dropdown-toggle-split')
click_link 'Create a new cluster'
visit_create_cluster_page
click_link 'Google GKE'
sleep 2 # wait for ajax
......@@ -212,11 +206,7 @@ RSpec.describe 'Clusters', :js do
context 'user visits create cluster page' do
before do
visit project_clusters_path(project)
click_link 'Certificate'
click_link 'Connect with a certificate'
click_link 'Create new cluster'
visit_create_cluster_page
end
it 'user sees a link to create a GKE cluster' do
......@@ -227,4 +217,16 @@ RSpec.describe 'Clusters', :js do
expect(page).to have_link('Amazon EKS')
end
end
def visit_create_cluster_page
visit project_clusters_path(project)
click_button(class: 'dropdown-toggle-split')
click_link 'Create a new cluster'
end
def visit_connect_cluster_page
click_button(class: 'dropdown-toggle-split')
click_link 'Connect with a certificate'
end
end
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`NewCluster renders the cluster component correctly 1`] = `
"<div>
<h4>Enter the details for your Kubernetes cluster</h4>
<p>Please enter access information for your Kubernetes cluster. If you need help, you can read our <b-link-stub href=\\"/some/help/path\\" target=\\"_blank\\" event=\\"click\\" routertag=\\"a\\" class=\\"gl-link\\">documentation</b-link-stub> on Kubernetes</p>
"<div class=\\"gl-pt-4\\">
<h4>Enter your Kubernetes cluster certificate details</h4>
<p>Enter details about your cluster. <b-link-stub href=\\"/some/help/path\\" target=\\"_blank\\" event=\\"click\\" routertag=\\"a\\" class=\\"gl-link\\">How do I use a certificate to connect to my cluster?</b-link-stub>
</p>
</div>"
`;
......@@ -31,9 +31,7 @@ describe('NewCluster', () => {
});
it('renders the correct information text', () => {
expect(findDescription().text()).toContain(
'Please enter access information for your Kubernetes cluster.',
);
expect(findDescription().text()).toContain('Enter details about your cluster.');
});
it('renders a valid help link set by the backend', () => {
......
......@@ -4,7 +4,7 @@ import ClustersEmptyState from '~/clusters_list/components/clusters_empty_state.
import ClusterStore from '~/clusters_list/store';
const clustersEmptyStateImage = 'path/to/svg';
const newClusterPath = '/path/to/connect/cluster';
const addClusterPath = '/path/to/connect/cluster';
const emptyStateHelpText = 'empty state text';
describe('ClustersEmptyStateComponent', () => {
......@@ -12,7 +12,7 @@ describe('ClustersEmptyStateComponent', () => {
const defaultProvideData = {
clustersEmptyStateImage,
newClusterPath,
addClusterPath,
};
const findButton = () => wrapper.findComponent(GlButton);
......
......@@ -23,7 +23,7 @@ describe('Clusters', () => {
const totalClustersNumber = 6;
const clustersEmptyStateImage = 'path/to/svg';
const emptyStateHelpText = null;
const newClusterPath = '/path/to/new/cluster';
const addClusterPath = '/path/to/new/cluster';
const entryData = {
endpoint,
......@@ -36,7 +36,7 @@ describe('Clusters', () => {
const provideData = {
clustersEmptyStateImage,
emptyStateHelpText,
newClusterPath,
addClusterPath,
};
const findLoader = () => wrapper.findComponent(GlLoadingIcon);
......
......@@ -31,34 +31,6 @@ RSpec.describe ClustersHelper do
end
end
describe '#create_new_cluster_label' do
subject { helper.create_new_cluster_label(provider: provider) }
context 'GCP provider' do
let(:provider) { 'gcp' }
it { is_expected.to eq('Create new cluster on GKE') }
end
context 'AWS provider' do
let(:provider) { 'aws' }
it { is_expected.to eq('Create new cluster on EKS') }
end
context 'other provider' do
let(:provider) { 'other' }
it { is_expected.to eq('Create new cluster') }
end
context 'no provider' do
let(:provider) { nil }
it { is_expected.to eq('Create new cluster') }
end
end
describe '#js_clusters_list_data' do
let_it_be(:current_user) { create(:user) }
let_it_be(:project) { build(:project) }
......@@ -89,11 +61,11 @@ RSpec.describe ClustersHelper do
end
it 'displays create cluster using certificate path' do
expect(subject[:new_cluster_path]).to eq("#{project_path(project)}/-/clusters/new?tab=create")
expect(subject[:new_cluster_path]).to eq("#{project_path(project)}/-/clusters/new")
end
it 'displays add cluster using certificate path' do
expect(subject[:add_cluster_path]).to eq("#{project_path(project)}/-/clusters/new?tab=add")
expect(subject[:add_cluster_path]).to eq("#{project_path(project)}/-/clusters/connect")
end
context 'user has no permissions to create a cluster' do
......
......@@ -43,6 +43,12 @@ RSpec.describe GroupClusterablePresenter do
it { is_expected.to eq(new_group_cluster_path(group)) }
end
describe '#connect_path' do
subject { presenter.connect_path }
it { is_expected.to eq(connect_group_clusters_path(group)) }
end
describe '#authorize_aws_role_path' do
subject { presenter.authorize_aws_role_path }
......
......@@ -15,6 +15,12 @@ RSpec.describe InstanceClusterablePresenter do
it { is_expected.to eq(create_aws_admin_clusters_path) }
end
describe '#connect_path' do
subject { described_class.new(instance).connect_path }
it { is_expected.to eq(connect_admin_clusters_path) }
end
describe '#authorize_aws_role_path' do
subject { described_class.new(instance).authorize_aws_role_path }
......
......@@ -43,6 +43,12 @@ RSpec.describe ProjectClusterablePresenter do
it { is_expected.to eq(new_project_cluster_path(project)) }
end
describe '#connect_path' do
subject { presenter.connect_path }
it { is_expected.to eq(connect_project_clusters_path(project)) }
end
describe '#authorize_aws_role_path' do
subject { presenter.authorize_aws_role_path }
......
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