Commit 21b49639 authored by Enrique Alcantara's avatar Enrique Alcantara

Update cluster info page feature tests

Update selectors and test assertions of the
cluster info page feature specs to reflect the
new tabs structure.
parent 8eb0cf62
......@@ -4,6 +4,8 @@
%section.settings.no-animate{ class: ('expanded' if expanded) }
.settings-header
%h4= s_('ClusterIntegration|Provider details')
%button.btn.js-settings-toggle{ type: 'button' }
= expanded ? _('Collapse') : _('Expand')
%p= s_('ClusterIntegration|See and edit the details for your Kubernetes cluster')
.settings-content
= render 'provider_details_form', cluster: @cluster, platform: @cluster.platform_kubernetes, update_cluster_url_path: clusterable.cluster_path(@cluster)
= form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster, html: { class: 'cluster_integration_form' } do |field|
= form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster, html: { class: 'js-cluster-integration-form' } do |field|
= form_errors(@cluster)
.form-group
.d-flex.align-items-center
......
......@@ -22,15 +22,20 @@ describe 'Cluster Health board', :js, :use_clean_rails_memory_store_caching, :si
it 'shows cluster board section within the page' do
visit cluster_path
expect(page).to have_text('Cluster health')
expect(page).to have_css('#cluster-health')
expect(page).to have_text('Health')
click_link 'Health'
expect(page).to have_css('.cluster-health-graphs')
end
context 'no prometheus installed' do
it 'shows install prometheus message' do
visit cluster_path
expect(page).to have_text('you must first install Prometheus below')
click_link 'Health'
expect(page).to have_text('you must first install Prometheus in the Applications tab')
end
end
......@@ -47,6 +52,9 @@ describe 'Cluster Health board', :js, :use_clean_rails_memory_store_caching, :si
it 'shows container and waiting for data message' do
visit cluster_path
click_link 'Health'
wait_for_requests
expect(page).to have_css('.prometheus-graphs')
......@@ -61,6 +69,9 @@ describe 'Cluster Health board', :js, :use_clean_rails_memory_store_caching, :si
it 'renders charts' do
visit cluster_path
click_link 'Health'
wait_for_requests
expect(page).to have_css('.prometheus-graphs')
......
......@@ -52,7 +52,7 @@ describe 'EE Clusters', :js do
before do
click_link 'default-cluster'
fill_in 'cluster_environment_scope', with: 'production/*'
within '.cluster_integration_form' do
within '.js-cluster-integration-form' do
click_button 'Save changes'
end
end
......@@ -135,7 +135,7 @@ describe 'EE Clusters', :js do
end
it 'user sees a cluster details page' do
expect(page).to have_content('Enable or disable GitLab\'s connection to your Kubernetes cluster.')
expect(page).to have_content('GitLab Integration')
expect(page.find_field('cluster[environment_scope]').value).to eq('staging/*')
end
end
......@@ -144,7 +144,7 @@ describe 'EE Clusters', :js do
before do
click_link 'default-cluster'
fill_in 'cluster_environment_scope', with: 'production/*'
within ".cluster_integration_form" do
within ".js-cluster-integration-form" do
click_button 'Save changes'
end
end
......
......@@ -25,8 +25,8 @@ describe 'clusters/clusters/show' do
it 'displays the Cluster health section' do
render
expect(rendered).to have_selector('#cluster-health')
expect(rendered).to have_content('Cluster health')
expect(rendered).to have_selector('#cluster-health-tab')
expect(rendered).to have_content('Health')
end
end
......
......@@ -9,9 +9,13 @@ module QA
module Show
def self.prepended(page)
page.module_eval do
view 'ee/app/views/projects/clusters/_prometheus_graphs.html.haml' do
view 'ee/app/views/clusters/clusters/_health.html.haml' do
element :cluster_health_section
end
view 'ee/app/views/clusters/clusters/_health_tab.html.haml' do
element :health, required: true
end
end
end
......@@ -21,10 +25,9 @@ module QA
end
end
def has_cluster_health_title?
within_cluster_health_section do
has_text?('Cluster health')
end
def open_health
has_element?(:health, wait: 30)
click_element :health
end
def has_cluster_health_graphs?
......
......@@ -10,17 +10,35 @@ module QA
element :ingress_ip_address, 'id="ingress-endpoint"' # rubocop:disable QA/ElementWithPattern
end
view 'app/views/clusters/clusters/_form.html.haml' do
view 'app/views/clusters/clusters/_gitlab_integration_form.html.haml' do
element :integration_status_toggle, required: true
element :base_domain_field, required: true
element :save_changes_button, required: true
end
view 'app/views/clusters/clusters/_details_tab.html.haml' do
element :details, required: true
end
view 'app/views/clusters/clusters/_applications_tab.html.haml' do
element :applications, required: true
end
view 'app/assets/javascripts/clusters/components/application_row.vue' do
element :install_button
element :uninstall_button
end
def open_details
has_element?(:details, wait: 30)
click_element :details
end
def open_applications
has_element?(:applications, wait: 30)
click_element :applications
end
def install!(application_name)
within_element(application_name) do
has_element?(:install_button, application: application_name, wait: 30)
......
......@@ -38,6 +38,9 @@ module QA
# We must wait a few seconds for permissions to be set up correctly for new cluster
sleep 10
# Open applications tab
show.open_applications
# Helm must be installed before everything else
show.install!(:helm)
show.await_installed(:helm)
......@@ -52,6 +55,8 @@ module QA
if @install_ingress
populate(:ingress_ip)
show.open_details
show.set_domain("#{ingress_ip}.nip.io")
show.save_domain
end
......
......@@ -42,7 +42,7 @@ module QA
def verify_cluster_health_graphs
Page::Project::Operations::Kubernetes::Show.perform do |cluster|
cluster.refresh
expect(cluster).to have_cluster_health_title
cluster.open_health
cluster.wait_for_cluster_health
end
......
......@@ -17,7 +17,7 @@ describe 'Clusterable > Show page' do
it 'allow the user to set domain' do
visit cluster_path
within '#cluster-integration' do
within '.js-cluster-integration-form' do
fill_in('cluster_base_domain', with: 'test.com')
click_on 'Save changes'
end
......@@ -34,7 +34,7 @@ describe 'Clusterable > Show page' do
end
it 'shows help text with the domain as an alternative to custom domain' do
within '#cluster-integration' do
within '.js-cluster-integration-form' do
expect(find(cluster_ingress_help_text_selector)).not_to match_css(hide_modifier_selector)
end
end
......@@ -44,7 +44,7 @@ describe 'Clusterable > Show page' do
it 'alternative to custom domain is not shown' do
visit cluster_path
within '#cluster-integration' do
within '.js-cluster-integration-form' do
expect(find(cluster_ingress_help_text_selector)).to match_css(hide_modifier_selector)
end
end
......@@ -63,7 +63,7 @@ describe 'Clusterable > Show page' do
end
it 'is not able to edit the name, API url, CA certificate nor token' do
within('#js-cluster-details') do
within('.js-provider-details') do
cluster_name_field = find('.cluster-name')
api_url_field = find('#cluster_platform_kubernetes_attributes_api_url')
ca_certificate_field = find('#cluster_platform_kubernetes_attributes_ca_cert')
......@@ -77,6 +77,8 @@ describe 'Clusterable > Show page' do
end
it 'displays GKE information' do
click_link 'Advanced Settings'
within('#advanced-settings-section') do
expect(page).to have_content('Google Kubernetes Engine')
expect(page).to have_content('Manage your Kubernetes cluster by visiting')
......@@ -91,7 +93,7 @@ describe 'Clusterable > Show page' do
end
it 'is able to edit the name, API url, CA certificate and token' do
within('#js-cluster-details') do
within('.js-provider-details') do
cluster_name_field = find('#cluster_name')
api_url_field = find('#cluster_platform_kubernetes_attributes_api_url')
ca_certificate_field = find('#cluster_platform_kubernetes_attributes_ca_cert')
......@@ -105,6 +107,8 @@ describe 'Clusterable > Show page' do
end
it 'does not display GKE information' do
click_link 'Advanced Settings'
within('#advanced-settings-section') do
expect(page).not_to have_content('Google Kubernetes Engine')
expect(page).not_to have_content('Manage your Kubernetes cluster by visiting')
......
......@@ -17,6 +17,12 @@ shared_examples "installing applications on a cluster" do
context 'when cluster is created' do
let(:cluster) { create(:cluster, :provided_by_gcp, *cluster_factory_args) }
before do
page.within('.js-edit-cluster-form') do
click_link 'Applications'
end
end
it 'user can install applications' do
wait_for_requests
......@@ -29,6 +35,7 @@ shared_examples "installing applications on a cluster" do
context 'when user installs Helm' do
before do
allow(ClusterInstallAppWorker).to receive(:perform_async)
wait_for_requests
page.within('.js-cluster-application-row-helm') do
page.find(:css, '.js-cluster-application-install-button').click
......
......@@ -34,7 +34,7 @@ describe 'User Cluster', :js do
it 'user sees a cluster details page' do
subject
expect(page).to have_content('Kubernetes cluster integration')
expect(page).to have_content('GitLab Integration')
expect(page.find_field('cluster[name]').value).to eq('dev-cluster')
expect(page.find_field('cluster[platform_kubernetes_attributes][api_url]').value)
.to have_content('http://example.com')
......@@ -93,7 +93,7 @@ describe 'User Cluster', :js do
context 'when user disables the cluster' do
before do
page.find(:css, '.js-cluster-enable-toggle-area .js-project-feature-toggle').click
page.within('#cluster-integration') { click_button 'Save changes' }
page.within('.js-cluster-integration-form') { click_button 'Save changes' }
end
it 'user sees the successful message' do
......@@ -105,7 +105,7 @@ describe 'User Cluster', :js do
before do
fill_in 'cluster_name', with: 'my-dev-cluster'
fill_in 'cluster_platform_kubernetes_attributes_token', with: 'new-token'
page.within('#js-cluster-details') { click_button 'Save changes' }
page.within('.js-provider-details') { click_button 'Save changes' }
end
it 'user sees the successful message' do
......@@ -117,6 +117,7 @@ describe 'User Cluster', :js do
context 'when user destroys the cluster' do
before do
click_link 'Advanced Settings'
click_button 'Remove integration and resources'
fill_in 'confirm_cluster_name_input', with: cluster.name
click_button 'Remove integration'
......
......@@ -119,7 +119,7 @@ describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do
context 'when user disables the cluster' do
before do
page.find(:css, '.js-cluster-enable-toggle-area .js-project-feature-toggle').click
page.within('#cluster-integration') { click_button 'Save changes' }
page.within('.js-cluster-integration-form') { click_button 'Save changes' }
end
it 'user sees the successful message' do
......@@ -130,7 +130,7 @@ describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do
context 'when user changes cluster parameters' do
before do
fill_in 'cluster_platform_kubernetes_attributes_namespace', with: 'my-namespace'
page.within('#js-cluster-details') { click_button 'Save changes' }
page.within('.js-provider-details') { click_button 'Save changes' }
end
it 'user sees the successful message' do
......@@ -141,6 +141,7 @@ describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do
context 'when user destroys the cluster' do
before do
click_link 'Advanced Settings'
click_button 'Remove integration and resources'
fill_in 'confirm_cluster_name_input', with: cluster.name
click_button 'Remove integration'
......
......@@ -41,7 +41,7 @@ describe 'User Cluster', :js do
it 'user sees a cluster details page' do
subject
expect(page).to have_content('Kubernetes cluster integration')
expect(page).to have_content('GitLab Integration')
expect(page.find_field('cluster[name]').value).to eq('dev-cluster')
expect(page.find_field('cluster[platform_kubernetes_attributes][api_url]').value)
.to have_content('http://example.com')
......@@ -79,7 +79,7 @@ describe 'User Cluster', :js do
context 'when user disables the cluster' do
before do
page.find(:css, '.js-cluster-enable-toggle-area .js-project-feature-toggle').click
page.within('#cluster-integration') { click_button 'Save changes' }
page.within('.js-cluster-integration-form') { click_button 'Save changes' }
end
it 'user sees the successful message' do
......@@ -91,7 +91,7 @@ describe 'User Cluster', :js do
before do
fill_in 'cluster_name', with: 'my-dev-cluster'
fill_in 'cluster_platform_kubernetes_attributes_namespace', with: 'my-namespace'
page.within('#js-cluster-details') { click_button 'Save changes' }
page.within('.js-provider-details') { click_button 'Save changes' }
end
it 'user sees the successful message' do
......@@ -103,6 +103,7 @@ describe 'User Cluster', :js do
context 'when user destroys the cluster' do
before do
click_link 'Advanced Settings'
click_button 'Remove integration and resources'
fill_in 'confirm_cluster_name_input', with: cluster.name
click_button 'Remove integration'
......
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