2017-10-05 10:58:05 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'Clusters', :js do
|
2017-10-31 14:59:40 -04:00
|
|
|
include GoogleApi::CloudPlatformHelpers
|
|
|
|
|
2017-12-03 15:34:00 -05:00
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:user) { create(:user) }
|
2017-10-05 10:58:05 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_master(user)
|
|
|
|
gitlab_sign_in(user)
|
|
|
|
end
|
|
|
|
|
2017-12-03 15:34:00 -05:00
|
|
|
context 'when user does not have a cluster and visits cluster index page' do
|
2017-10-05 10:58:05 -04:00
|
|
|
before do
|
|
|
|
visit project_clusters_path(project)
|
|
|
|
end
|
|
|
|
|
2017-12-03 16:55:32 -05:00
|
|
|
it 'sees empty state' do
|
2018-01-29 14:49:00 -05:00
|
|
|
expect(page).to have_link('Add Kubernetes cluster')
|
2017-12-03 16:55:32 -05:00
|
|
|
expect(page).to have_selector('.empty-state')
|
2017-10-05 10:58:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-12-03 16:55:32 -05:00
|
|
|
context 'when user has a cluster and visits cluster index page' do
|
|
|
|
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
|
|
|
|
let(:project) { cluster.project }
|
2017-11-07 11:22:28 -05:00
|
|
|
|
2017-12-03 16:55:32 -05:00
|
|
|
before do
|
|
|
|
visit project_clusters_path(project)
|
|
|
|
end
|
2017-10-05 10:58:05 -04:00
|
|
|
|
2017-12-03 16:55:32 -05:00
|
|
|
it 'user sees a table with one cluster' do
|
|
|
|
# One is the header row, the other the cluster row
|
|
|
|
expect(page).to have_selector('.gl-responsive-table-row', count: 2)
|
|
|
|
end
|
2017-11-07 11:22:28 -05:00
|
|
|
|
2017-12-03 16:55:32 -05:00
|
|
|
context 'inline update of cluster' do
|
|
|
|
it 'user can update cluster' do
|
2018-01-24 16:54:33 -05:00
|
|
|
expect(page).to have_selector('.js-project-feature-toggle')
|
2017-12-03 16:55:32 -05:00
|
|
|
end
|
2017-11-07 11:22:28 -05:00
|
|
|
|
2017-12-03 16:55:32 -05:00
|
|
|
context 'with sucessfull request' do
|
|
|
|
it 'user sees updated cluster' do
|
|
|
|
expect do
|
2018-01-24 16:54:33 -05:00
|
|
|
page.find('.js-project-feature-toggle').click
|
2017-12-03 16:55:32 -05:00
|
|
|
wait_for_requests
|
|
|
|
end.to change { cluster.reload.enabled }
|
2017-11-07 11:22:28 -05:00
|
|
|
|
2017-12-03 16:55:32 -05:00
|
|
|
expect(page).not_to have_selector('.is-checked')
|
|
|
|
expect(cluster.reload).not_to be_enabled
|
2017-11-07 11:22:28 -05:00
|
|
|
end
|
2017-10-05 10:58:05 -04:00
|
|
|
end
|
|
|
|
|
2017-12-03 16:55:32 -05:00
|
|
|
context 'with failed request' do
|
|
|
|
it 'user sees not update cluster and error message' do
|
|
|
|
expect_any_instance_of(Clusters::UpdateService).to receive(:execute).and_call_original
|
|
|
|
allow_any_instance_of(Clusters::Cluster).to receive(:valid?) { false }
|
2017-10-05 10:58:05 -04:00
|
|
|
|
2018-01-24 16:54:33 -05:00
|
|
|
page.find('.js-project-feature-toggle').click
|
2017-12-03 16:55:32 -05:00
|
|
|
|
|
|
|
expect(page).to have_content('Something went wrong on our end.')
|
|
|
|
expect(page).to have_selector('.is-checked')
|
|
|
|
expect(cluster.reload).to be_enabled
|
2017-10-05 10:58:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-12-03 16:55:32 -05:00
|
|
|
context 'when user clicks on a cluster' do
|
2017-10-05 10:58:05 -04:00
|
|
|
before do
|
2017-12-03 16:55:32 -05:00
|
|
|
click_link cluster.name
|
2017-10-05 10:58:05 -04:00
|
|
|
end
|
|
|
|
|
2017-12-03 16:55:32 -05:00
|
|
|
it 'user sees a cluster details page' do
|
2017-10-06 10:14:14 -04:00
|
|
|
expect(page).to have_button('Save')
|
2017-10-31 14:59:40 -04:00
|
|
|
expect(page.find(:css, '.cluster-name').value).to eq(cluster.name)
|
2017-10-05 10:58:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user has not signed in Google' do
|
|
|
|
before do
|
|
|
|
visit project_clusters_path(project)
|
2017-11-01 10:13:22 -04:00
|
|
|
|
2018-01-29 14:49:00 -05:00
|
|
|
click_link 'Add Kubernetes cluster'
|
2018-04-17 08:59:31 -04:00
|
|
|
click_link 'Create on Google Kubernetes Engine'
|
2017-10-05 10:58:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'user sees a login page' do
|
|
|
|
expect(page).to have_css('.signin-with-google')
|
2017-11-30 12:09:32 -05:00
|
|
|
expect(page).to have_link('Google account')
|
2017-10-05 10:58:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|