diff options
Diffstat (limited to 'spec/features/projects')
20 files changed, 703 insertions, 242 deletions
diff --git a/spec/features/projects/blobs/blob_show_spec.rb b/spec/features/projects/blobs/blob_show_spec.rb index 3d465e709b9..88813d9b5ff 100644 --- a/spec/features/projects/blobs/blob_show_spec.rb +++ b/spec/features/projects/blobs/blob_show_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' feature 'File blob', :js do + include MobileHelpers + let(:project) { create(:project, :public, :repository) } def visit_blob(path, anchor: nil, ref: 'master') @@ -30,6 +32,16 @@ feature 'File blob', :js do expect(page).to have_link('Open raw') end end + + it 'displays file actions on all screen sizes' do + file_actions_selector = '.file-actions' + + resize_screen_sm + expect(page).to have_selector(file_actions_selector, visible: true) + + resize_screen_xs + expect(page).to have_selector(file_actions_selector, visible: true) + end end context 'Markdown file' do diff --git a/spec/features/projects/clusters/applications_spec.rb b/spec/features/projects/clusters/applications_spec.rb new file mode 100644 index 00000000000..b34cd061ec6 --- /dev/null +++ b/spec/features/projects/clusters/applications_spec.rb @@ -0,0 +1,107 @@ +require 'spec_helper' + +feature 'Clusters Applications', :js do + include GoogleApi::CloudPlatformHelpers + + let(:project) { create(:project) } + let(:user) { create(:user) } + + before do + project.add_master(user) + sign_in(user) + end + + describe 'Installing applications' do + before do + visit project_cluster_path(project, cluster) + end + + context 'when cluster is being created' do + let(:cluster) { create(:cluster, :providing_by_gcp, projects: [project])} + + scenario 'user is unable to install applications' do + page.within('.js-cluster-application-row-helm') do + expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') + expect(page.find(:css, '.js-cluster-application-install-button').text).to eq('Install') + end + end + end + + context 'when cluster is created' do + let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project])} + + scenario 'user can install applications' do + page.within('.js-cluster-application-row-helm') do + expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to be_nil + expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Install') + end + end + + context 'when user installs Helm' do + before do + allow(ClusterInstallAppWorker).to receive(:perform_async).and_return(nil) + + page.within('.js-cluster-application-row-helm') do + page.find(:css, '.js-cluster-application-install-button').click + end + end + + it 'he sees status transition' do + page.within('.js-cluster-application-row-helm') do + # FE sends request and gets the response, then the buttons is "Install" + expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') + expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Install') + + Clusters::Cluster.last.application_helm.make_installing! + + # FE starts polling and update the buttons to "Installing" + expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') + expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installing') + + Clusters::Cluster.last.application_helm.make_installed! + + expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') + expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installed') + end + + expect(page).to have_content('Helm Tiller was successfully installed on your cluster') + end + end + + context 'when user installs Ingress' do + context 'when user installs application: Ingress' do + before do + allow(ClusterInstallAppWorker).to receive(:perform_async).and_return(nil) + + create(:cluster_applications_helm, :installed, cluster: cluster) + + page.within('.js-cluster-application-row-ingress') do + page.find(:css, '.js-cluster-application-install-button').click + end + end + + it 'he sees status transition' do + page.within('.js-cluster-application-row-ingress') do + # FE sends request and gets the response, then the buttons is "Install" + expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') + expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Install') + + Clusters::Cluster.last.application_ingress.make_installing! + + # FE starts polling and update the buttons to "Installing" + expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') + expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installing') + + Clusters::Cluster.last.application_ingress.make_installed! + + expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') + expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installed') + end + + expect(page).to have_content('Ingress was successfully installed on your cluster') + end + end + end + end + end +end diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb new file mode 100644 index 00000000000..5a00b463960 --- /dev/null +++ b/spec/features/projects/clusters/gcp_spec.rb @@ -0,0 +1,138 @@ +require 'spec_helper' + +feature 'Gcp Cluster', :js do + include GoogleApi::CloudPlatformHelpers + + let(:project) { create(:project) } + let(:user) { create(:user) } + + before do + project.add_master(user) + gitlab_sign_in(user) + allow(Projects::ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 } + end + + context 'when user has signed with Google' do + before do + allow_any_instance_of(Projects::Clusters::GcpController) + .to receive(:token_in_session).and_return('token') + allow_any_instance_of(Projects::Clusters::GcpController) + .to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s) + end + + context 'when user does not have a cluster and visits cluster index page' do + before do + visit project_clusters_path(project) + + click_link 'Add cluster' + click_link 'Create on GKE' + end + + context 'when user filled form with valid parameters' do + before do + allow_any_instance_of(GoogleApi::CloudPlatform::Client) + .to receive(:projects_zones_clusters_create) do + OpenStruct.new( + self_link: 'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123', + status: 'RUNNING' + ) + end + + allow(WaitForClusterCreationWorker).to receive(:perform_in).and_return(nil) + + fill_in 'cluster_provider_gcp_attributes_gcp_project_id', with: 'gcp-project-123' + fill_in 'cluster_name', with: 'dev-cluster' + click_button 'Create cluster' + end + + it 'user sees a cluster details page and creation status' do + expect(page).to have_content('Cluster is being created on Google Container Engine...') + + Clusters::Cluster.last.provider.make_created! + + expect(page).to have_content('Cluster was successfully created on Google Container Engine') + end + + it 'user sees a error if something worng during creation' do + expect(page).to have_content('Cluster is being created on Google Container Engine...') + + Clusters::Cluster.last.provider.make_errored!('Something wrong!') + + expect(page).to have_content('Something wrong!') + end + end + + context 'when user filled form with invalid parameters' do + before do + click_button 'Create cluster' + end + + it 'user sees a validation error' do + expect(page).to have_css('#error_explanation') + end + end + end + + context 'when user does have a cluster and visits cluster page' do + let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) } + + before do + visit project_cluster_path(project, cluster) + end + + it 'user sees a cluster details page' do + expect(page).to have_button('Save') + expect(page.find(:css, '.cluster-name').value).to eq(cluster.name) + end + + context 'when user disables the cluster' do + before do + page.find(:css, '.js-toggle-cluster').click + click_button 'Save' + end + + it 'user sees the successful message' do + expect(page).to have_content('Cluster was successfully updated.') + end + end + + context 'when user changes cluster parameters' do + before do + fill_in 'cluster_platform_kubernetes_attributes_namespace', with: 'my-namespace' + click_button 'Save changes' + end + + it 'user sees the successful message' do + expect(page).to have_content('Cluster was successfully updated.') + expect(cluster.reload.platform_kubernetes.namespace).to eq('my-namespace') + end + end + + context 'when user destroy the cluster' do + before do + page.accept_confirm do + click_link 'Remove integration' + end + end + + it 'user sees creation form with the successful message' do + expect(page).to have_content('Cluster integration was successfully removed.') + expect(page).to have_link('Add cluster') + end + end + end + end + + context 'when user has not signed with Google' do + before do + visit project_clusters_path(project) + + click_link 'Add cluster' + click_link 'Create on GKE' + end + + it 'user sees a login page' do + expect(page).to have_css('.signin-with-google') + end + end +end diff --git a/spec/features/projects/clusters/interchangeability_spec.rb b/spec/features/projects/clusters/interchangeability_spec.rb new file mode 100644 index 00000000000..01f9526608f --- /dev/null +++ b/spec/features/projects/clusters/interchangeability_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +feature 'Interchangeability between KubernetesService and Platform::Kubernetes' do + EXCEPT_METHODS = %i[test title description help fields initialize_properties namespace namespace= api_url api_url=].freeze + EXCEPT_METHODS_GREP_V = %w[_touched? _changed? _was].freeze + + it 'Clusters::Platform::Kubernetes covers core interfaces in KubernetesService' do + expected_interfaces = KubernetesService.instance_methods(false) + expected_interfaces = expected_interfaces - EXCEPT_METHODS + EXCEPT_METHODS_GREP_V.each do |g| + expected_interfaces = expected_interfaces.grep_v(/#{Regexp.escape(g)}\z/) + end + + expect(expected_interfaces - Clusters::Platforms::Kubernetes.instance_methods).to be_empty + end +end diff --git a/spec/features/projects/clusters/user_spec.rb b/spec/features/projects/clusters/user_spec.rb new file mode 100644 index 00000000000..414f4acba86 --- /dev/null +++ b/spec/features/projects/clusters/user_spec.rb @@ -0,0 +1,102 @@ +require 'spec_helper' + +feature 'User Cluster', :js do + include GoogleApi::CloudPlatformHelpers + + let(:project) { create(:project) } + let(:user) { create(:user) } + + before do + project.add_master(user) + gitlab_sign_in(user) + allow(Projects::ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 } + end + + context 'when user does not have a cluster and visits cluster index page' do + before do + visit project_clusters_path(project) + + click_link 'Add cluster' + click_link 'Add an existing cluster' + end + + context 'when user filled form with valid parameters' do + before do + fill_in 'cluster_name', with: 'dev-cluster' + fill_in 'cluster_platform_kubernetes_attributes_api_url', with: 'http://example.com' + fill_in 'cluster_platform_kubernetes_attributes_token', with: 'my-token' + click_button 'Add cluster' + end + + it 'user sees a cluster details page' do + expect(page).to have_content('Enable cluster 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') + expect(page.find_field('cluster[platform_kubernetes_attributes][token]').value) + .to have_content('my-token') + end + end + + context 'when user filled form with invalid parameters' do + before do + click_button 'Add cluster' + end + + it 'user sees a validation error' do + expect(page).to have_css('#error_explanation') + end + end + end + + context 'when user does have a cluster and visits cluster page' do + let(:cluster) { create(:cluster, :provided_by_user, projects: [project]) } + + before do + visit project_cluster_path(project, cluster) + end + + it 'user sees a cluster details page' do + expect(page).to have_button('Save') + end + + context 'when user disables the cluster' do + before do + page.find(:css, '.js-toggle-cluster').click + fill_in 'cluster_name', with: 'dev-cluster' + click_button 'Save' + end + + it 'user sees the successful message' do + expect(page).to have_content('Cluster was successfully updated.') + end + end + + context 'when user changes cluster parameters' do + before do + fill_in 'cluster_name', with: 'my-dev-cluster' + fill_in 'cluster_platform_kubernetes_attributes_namespace', with: 'my-namespace' + click_button 'Save changes' + end + + it 'user sees the successful message' do + expect(page).to have_content('Cluster was successfully updated.') + expect(cluster.reload.name).to eq('my-dev-cluster') + expect(cluster.reload.platform_kubernetes.namespace).to eq('my-namespace') + end + end + + context 'when user destroy the cluster' do + before do + page.accept_confirm do + click_link 'Remove integration' + end + end + + it 'user sees creation form with the successful message' do + expect(page).to have_content('Cluster integration was successfully removed.') + expect(page).to have_link('Add cluster') + end + end + end +end diff --git a/spec/features/projects/clusters_spec.rb b/spec/features/projects/clusters_spec.rb index 21f00b4e266..93929bf6814 100644 --- a/spec/features/projects/clusters_spec.rb +++ b/spec/features/projects/clusters_spec.rb @@ -3,217 +3,78 @@ require 'spec_helper' feature 'Clusters', :js do include GoogleApi::CloudPlatformHelpers - let!(:project) { create(:project, :repository) } - let!(:user) { create(:user) } + let(:project) { create(:project) } + let(:user) { create(:user) } before do project.add_master(user) gitlab_sign_in(user) end - context 'when user has signed in Google' do + context 'when user does not have a cluster and visits cluster index page' do before do - allow_any_instance_of(Projects::ClustersController) - .to receive(:token_in_session).and_return('token') - allow_any_instance_of(Projects::ClustersController) - .to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s) + visit project_clusters_path(project) end - context 'when user does not have a cluster and visits cluster index page' do - before do - visit project_clusters_path(project) - end - - it 'user sees a new page' do - expect(page).to have_button('Add cluster') - end - - context 'when user opens opens create on gke page' do - before do - click_button 'Add cluster' - click_link 'Create on GKE' - end - - context 'when user filled form with valid parameters' do - before do - double.tap do |dbl| - allow(dbl).to receive(:status).and_return('RUNNING') - allow(dbl).to receive(:self_link) - .and_return('projects/gcp-project-12345/zones/us-central1-a/operations/ope-123') - allow_any_instance_of(GoogleApi::CloudPlatform::Client) - .to receive(:projects_zones_clusters_create).and_return(dbl) - end - - allow(WaitForClusterCreationWorker).to receive(:perform_in).and_return(nil) - - fill_in 'cluster_provider_gcp_attributes_gcp_project_id', with: 'gcp-project-123' - fill_in 'cluster_name', with: 'dev-cluster' - click_button 'Create cluster' - end - - it 'user sees a cluster details page and creation status' do - expect(page).to have_content('Cluster is being created on Google Container Engine...') - - # Application Installation buttons - page.within('.js-cluster-application-row-helm') do - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page.find(:css, '.js-cluster-application-install-button').text).to eq('Install') - end - - Clusters::Cluster.last.provider.make_created! - - expect(page).to have_content('Cluster was successfully created on Google Container Engine') - end - - it 'user sees a error if something worng during creation' do - expect(page).to have_content('Cluster is being created on Google Container Engine...') - - Clusters::Cluster.last.provider.make_errored!('Something wrong!') - - expect(page).to have_content('Something wrong!') - end - end + it 'sees empty state' do + expect(page).to have_link('Add cluster') + expect(page).to have_selector('.empty-state') + end + end - context 'when user filled form with invalid parameters' do - before do - click_button 'Create cluster' - end + context 'when user has a cluster and visits cluster index page' do + let!(:cluster) { create(:cluster, :project, :provided_by_gcp) } + let(:project) { cluster.project } - it 'user sees a validation error' do - expect(page).to have_css('#error_explanation') - end - end - end + before do + visit project_clusters_path(project) end - context 'when user has a cluster and visits cluster index page' do - let!(:cluster) { create(:cluster, :project, :provided_by_gcp) } - let(:project) { cluster.project } + 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 - before do - visit project_clusters_path(project) + context 'inline update of cluster' do + it 'user can update cluster' do + expect(page).to have_selector('.js-toggle-cluster-list') end - context 'when user clicks on a cluster' do - before do - # TODO: Replace with Click on cluster after frontend implements list - visit project_cluster_path(project, cluster) - end - - it 'user sees an cluster details page' do - expect(page).to have_button('Save') - expect(page.find(:css, '.cluster-name').value).to eq(cluster.name) + context 'with sucessfull request' do + it 'user sees updated cluster' do + expect do + page.find('.js-toggle-cluster-list').click + wait_for_requests + end.to change { cluster.reload.enabled } - # Application Installation buttons - page.within('.js-cluster-application-row-helm') do - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to be_nil - expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Install') - end - end - - context 'when user installs application: Helm Tiller' do - before do - allow(ClusterInstallAppWorker).to receive(:perform_async).and_return(nil) - - page.within('.js-cluster-application-row-helm') do - page.find(:css, '.js-cluster-application-install-button').click - end - end - - it 'user sees status transition' do - page.within('.js-cluster-application-row-helm') do - # FE sends request and gets the response, then the buttons is "Install" - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Install') - - Clusters::Cluster.last.application_helm.make_installing! - - # FE starts polling and update the buttons to "Installing" - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installing') - - Clusters::Cluster.last.application_helm.make_installed! - - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installed') - end - - expect(page).to have_content('Helm Tiller was successfully installed on your cluster') - end - end - - context 'when user installs application: Ingress' do - before do - allow(ClusterInstallAppWorker).to receive(:perform_async).and_return(nil) - # Helm Tiller needs to be installed before you can install Ingress - create(:cluster_applications_helm, :installed, cluster: cluster) - - visit project_clusters_path(project) - - page.within('.js-cluster-application-row-ingress') do - page.find(:css, '.js-cluster-application-install-button').click - end - end - - it 'user sees status transition' do - page.within('.js-cluster-application-row-ingress') do - # FE sends request and gets the response, then the buttons is "Install" - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Install') - - Clusters::Cluster.last.application_ingress.make_installing! - - # FE starts polling and update the buttons to "Installing" - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installing') - - Clusters::Cluster.last.application_ingress.make_installed! - - expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page.find(:css, '.js-cluster-application-install-button')).to have_content('Installed') - end - - expect(page).to have_content('Ingress was successfully installed on your cluster') - end + expect(page).not_to have_selector('.is-checked') + expect(cluster.reload).not_to be_enabled end + end - context 'when user disables the cluster' do - before do - page.find(:css, '.js-toggle-cluster').click - click_button 'Save' - end + 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 } - it 'user sees the succeccful message' do - expect(page).to have_content('Cluster was successfully updated.') - end - end + page.find('.js-toggle-cluster-list').click - context 'when user destory the cluster' do - before do - page.accept_confirm do - click_link 'Remove integration' - end - end - - it 'user sees creation form with the succeccful message' do - expect(page).to have_content('Cluster integration was successfully removed.') - expect(page).to have_link('Create on GKE') - end + expect(page).to have_content('Something went wrong on our end.') + expect(page).to have_selector('.is-checked') + expect(cluster.reload).to be_enabled end end end - end - context 'when user has not signed in Google' do - before do - visit project_clusters_path(project) - - click_button 'Add cluster' - click_link 'Create on GKE' - end + context 'when user clicks on a cluster' do + before do + click_link cluster.name + end - it 'user sees a login page' do - expect(page).to have_css('.signin-with-google') + it 'user sees a cluster details page' do + expect(page).to have_button('Save') + expect(page.find(:css, '.cluster-name').value).to eq(cluster.name) + end end end end diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb index 5fc3ba54f65..dfcf97ad495 100644 --- a/spec/features/projects/environments/environment_spec.rb +++ b/spec/features/projects/environments/environment_spec.rb @@ -101,35 +101,48 @@ feature 'Environment' do end context 'with terminal' do - let(:project) { create(:kubernetes_project, :test_repo) } + shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do + context 'for project master' do + let(:role) { :master } - context 'for project master' do - let(:role) { :master } + scenario 'it shows the terminal button' do + expect(page).to have_terminal_button + end - scenario 'it shows the terminal button' do - expect(page).to have_terminal_button + context 'web terminal', :js do + before do + # Stub #terminals as it causes js-enabled feature specs to render the page incorrectly + allow_any_instance_of(Environment).to receive(:terminals) { nil } + visit terminal_project_environment_path(project, environment) + end + + it 'displays a web terminal' do + expect(page).to have_selector('#terminal') + expect(page).to have_link(nil, href: environment.external_url) + end + end end - context 'web terminal', :js do - before do - # Stub #terminals as it causes js-enabled feature specs to render the page incorrectly - allow_any_instance_of(Environment).to receive(:terminals) { nil } - visit terminal_project_environment_path(project, environment) - end + context 'for developer' do + let(:role) { :developer } - it 'displays a web terminal' do - expect(page).to have_selector('#terminal') - expect(page).to have_link(nil, href: environment.external_url) + scenario 'does not show terminal button' do + expect(page).not_to have_terminal_button end end end - context 'for developer' do - let(:role) { :developer } + context 'when user configured kubernetes from Integration > Kubernetes' do + let(:project) { create(:kubernetes_project, :test_repo) } - scenario 'does not show terminal button' do - expect(page).not_to have_terminal_button - end + it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes' + end + + context 'when user configured kubernetes from CI/CD > Clusters' do + let!(:cluster) { create(:cluster, :project, :provided_by_gcp) } + let(:project) { cluster.project } + + it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes' end end diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index b4eb5795470..4a05313c14a 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -14,8 +14,10 @@ feature 'Environments page', :js do it 'shows "Available" and "Stopped" tab with links' do visit_environments(project) - expect(page).to have_link('Available') - expect(page).to have_link('Stopped') + expect(page).to have_selector('.js-environments-tab-available') + expect(page).to have_content('Available') + expect(page).to have_selector('.js-environments-tab-stopped') + expect(page).to have_content('Stopped') end describe 'with one available environment' do @@ -75,8 +77,8 @@ feature 'Environments page', :js do it 'does not show environments and counters are set to zero' do expect(page).to have_content('You don\'t have any environments right now.') - expect(page.find('.js-available-environments-count').text).to eq('0') - expect(page.find('.js-stopped-environments-count').text).to eq('0') + expect(page.find('.js-environments-tab-available .badge').text).to eq('0') + expect(page.find('.js-environments-tab-stopped .badge').text).to eq('0') end end @@ -93,8 +95,8 @@ feature 'Environments page', :js do it 'shows environments names and counters' do expect(page).to have_link(environment.name) - expect(page.find('.js-available-environments-count').text).to eq('1') - expect(page.find('.js-stopped-environments-count').text).to eq('0') + expect(page.find('.js-environments-tab-available .badge').text).to eq('1') + expect(page.find('.js-environments-tab-stopped .badge').text).to eq('0') end it 'does not show deployments' do @@ -206,22 +208,35 @@ feature 'Environments page', :js do end context 'when kubernetes terminal is available' do - let(:project) { create(:kubernetes_project, :test_repo) } + shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do + context 'for project master' do + let(:role) { :master } - context 'for project master' do - let(:role) { :master } + it 'shows the terminal button' do + expect(page).to have_terminal_button + end + end + + context 'when user is a developer' do + let(:role) { :developer } - it 'shows the terminal button' do - expect(page).to have_terminal_button + it 'does not show terminal button' do + expect(page).not_to have_terminal_button + end end end - context 'when user is a developer' do - let(:role) { :developer } + context 'when user configured kubernetes from Integration > Kubernetes' do + let(:project) { create(:kubernetes_project, :test_repo) } - it 'does not show terminal button' do - expect(page).not_to have_terminal_button - end + it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes' + end + + context 'when user configured kubernetes from CI/CD > Clusters' do + let(:cluster) { create(:cluster, :provided_by_gcp, projects: [create(:project, :repository)]) } + let(:project) { cluster.project } + + it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes' end end end @@ -294,11 +309,32 @@ feature 'Environments page', :js do end end + describe 'environments folders view' do + before do + create(:environment, project: project, + name: 'staging.review/review-1', + state: :available) + create(:environment, project: project, + name: 'staging.review/review-2', + state: :available) + end + + scenario 'user opens folder view' do + visit folder_project_environments_path(project, 'staging.review') + wait_for_requests + + expect(page).to have_content('Environments / staging.review') + expect(page).to have_content('review-1') + expect(page).to have_content('review-2') + end + end + def have_terminal_button have_link(nil, href: terminal_project_environment_path(project, environment)) end def visit_environments(project, **opts) visit project_environments_path(project, **opts) + wait_for_requests end end diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb index 951456763dc..033c45a60bf 100644 --- a/spec/features/projects/features_visibility_spec.rb +++ b/spec/features/projects/features_visibility_spec.rb @@ -177,7 +177,7 @@ describe 'Edit Project Settings' do click_button "Save changes" end - expect(find(".sharing-permissions")).to have_selector(".project-feature-toggle.disabled", count: 2) + expect(find(".sharing-permissions")).to have_selector(".project-feature-toggle.is-disabled", count: 2) end it "shows empty features project homepage" do @@ -272,10 +272,10 @@ describe 'Edit Project Settings' do end def toggle_feature_off(feature_name) - find(".project-feature-controls[data-for=\"#{feature_name}\"] .project-feature-toggle.checked").click + find(".project-feature-controls[data-for=\"#{feature_name}\"] .project-feature-toggle.is-checked").click end def toggle_feature_on(feature_name) - find(".project-feature-controls[data-for=\"#{feature_name}\"] .project-feature-toggle:not(.checked)").click + find(".project-feature-controls[data-for=\"#{feature_name}\"] .project-feature-toggle:not(.is-checked)").click end end diff --git a/spec/features/projects/fork_spec.rb b/spec/features/projects/fork_spec.rb index e10d29e5eea..842840cc04c 100644 --- a/spec/features/projects/fork_spec.rb +++ b/spec/features/projects/fork_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe 'Project fork' do + include ProjectForksHelper + let(:user) { create(:user) } let(:project) { create(:project, :public, :repository) } @@ -24,8 +26,9 @@ describe 'Project fork' do end context 'master in group' do + let(:group) { create(:group) } + before do - group = create(:group) group.add_master(user) end @@ -53,5 +56,17 @@ describe 'Project fork' do expect(page).to have_css('.fork-thumbnail', count: 2) expect(page).to have_css('.fork-thumbnail.disabled') end + + it 'links to the fork if the project was already forked within that namespace' do + forked_project = fork_project(project, user, namespace: group, repository: true) + + visit new_project_fork_path(project) + + expect(page).to have_css('div.forked', text: group.full_name) + + click_link group.full_name + + expect(current_path).to eq(project_path(forked_project)) + end end end diff --git a/spec/features/projects/import_export/test_project_export.tar.gz b/spec/features/projects/import_export/test_project_export.tar.gz Binary files differindex fb6a3b8e733..0c354298433 100644 --- a/spec/features/projects/import_export/test_project_export.tar.gz +++ b/spec/features/projects/import_export/test_project_export.tar.gz diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index c2a0d2395a9..0b0d5a2dce8 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -187,7 +187,7 @@ feature 'Jobs' do context "Download artifacts" do before do - job.update_attributes(artifacts_file: artifacts_file) + job.update_attributes(legacy_artifacts_file: artifacts_file) visit project_job_path(project, job) end @@ -198,7 +198,7 @@ feature 'Jobs' do context 'Artifacts expire date' do before do - job.update_attributes(artifacts_file: artifacts_file, + job.update_attributes(legacy_artifacts_file: artifacts_file, artifacts_expire_at: expire_at) visit project_job_path(project, job) @@ -422,14 +422,14 @@ feature 'Jobs' do describe "GET /:project/jobs/:id/download" do before do - job.update_attributes(artifacts_file: artifacts_file) + job.update_attributes(legacy_artifacts_file: artifacts_file) visit project_job_path(project, job) click_link 'Download' end context "Build from other project" do before do - job2.update_attributes(artifacts_file: artifacts_file) + job2.update_attributes(legacy_artifacts_file: artifacts_file) visit download_project_job_artifacts_path(project, job2) end diff --git a/spec/features/projects/no_password_spec.rb b/spec/features/projects/no_password_spec.rb index 6aff079dd39..b3b3212556c 100644 --- a/spec/features/projects/no_password_spec.rb +++ b/spec/features/projects/no_password_spec.rb @@ -30,7 +30,7 @@ feature 'No Password Alert' do let(:user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'saml') } before do - stub_application_setting(password_authentication_enabled?: false) + stub_application_setting(password_authentication_enabled_for_git?: false) stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [mock_saml_config]) end diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index b8fa1a54c24..888e290292b 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -185,6 +185,36 @@ describe 'Pipeline', :js do end end + context 'when user does not have access to read jobs' do + before do + project.update(public_builds: false) + end + + describe 'GET /:project/pipelines/:id' do + include_context 'pipeline builds' + + let(:project) { create(:project, :repository) } + let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) } + + before do + visit project_pipeline_path(project, pipeline) + end + + it 'shows the pipeline graph' do + expect(page).to have_selector('.pipeline-visualization') + expect(page).to have_content('Build') + expect(page).to have_content('Test') + expect(page).to have_content('Deploy') + expect(page).to have_content('Retry') + expect(page).to have_content('Cancel running') + end + + it 'should not link to job' do + expect(page).not_to have_selector('.js-pipeline-graph-job-link') + end + end + end + describe 'GET /:project/pipelines/:id/builds' do include_context 'pipeline builds' diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index 50f8f13d261..b87b47d0e1a 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -304,7 +304,7 @@ describe 'Pipelines', :js do context 'with artifacts expired' do let!(:with_artifacts_expired) do - create(:ci_build, :artifacts_expired, :success, + create(:ci_build, :expired, :success, pipeline: pipeline, name: 'rspec', stage: 'test') @@ -500,6 +500,18 @@ describe 'Pipelines', :js do end it { expect(page).to have_content('Missing .gitlab-ci.yml file') } + it 'creates a pipeline after first request failed and a valid gitlab-ci.yml file is available when trying again' do + click_button project.default_branch + + stub_ci_pipeline_to_return_yaml_file + + page.within '.dropdown-menu' do + click_link 'master' + end + + expect { click_on 'Create pipeline' } + .to change { Ci::Pipeline.count }.by(1) + end end end end diff --git a/spec/features/projects/settings/pipelines_settings_spec.rb b/spec/features/projects/settings/pipelines_settings_spec.rb index ea8f997409d..eb8e7265dd3 100644 --- a/spec/features/projects/settings/pipelines_settings_spec.rb +++ b/spec/features/projects/settings/pipelines_settings_spec.rb @@ -8,13 +8,14 @@ feature "Pipelines settings" do background do sign_in(user) project.team << [user, role] - visit project_pipelines_settings_path(project) end context 'for developer' do given(:role) { :developer } scenario 'to be disallowed to view' do + visit project_settings_ci_cd_path(project) + expect(page.status_code).to eq(404) end end @@ -23,6 +24,8 @@ feature "Pipelines settings" do given(:role) { :master } scenario 'be allowed to change' do + visit project_settings_ci_cd_path(project) + fill_in('Test coverage parsing', with: 'coverage_regex') click_on 'Save changes' @@ -32,6 +35,8 @@ feature "Pipelines settings" do end scenario 'updates auto_cancel_pending_pipelines' do + visit project_settings_ci_cd_path(project) + page.check('Auto-cancel redundant, pending pipelines') click_on 'Save changes' @@ -42,14 +47,119 @@ feature "Pipelines settings" do expect(checkbox).to be_checked end - scenario 'update auto devops settings' do - fill_in('project_auto_devops_attributes_domain', with: 'test.com') - page.choose('project_auto_devops_attributes_enabled_false') - click_on 'Save changes' + describe 'Auto DevOps' do + it 'update auto devops settings' do + visit project_settings_ci_cd_path(project) - expect(page.status_code).to eq(200) - expect(project.auto_devops).to be_present - expect(project.auto_devops).not_to be_enabled + fill_in('project_auto_devops_attributes_domain', with: 'test.com') + page.choose('project_auto_devops_attributes_enabled_false') + click_on 'Save changes' + + expect(page.status_code).to eq(200) + expect(project.auto_devops).to be_present + expect(project.auto_devops).not_to be_enabled + end + + describe 'Immediately run pipeline checkbox option', :js do + context 'when auto devops is set to instance default (enabled)' do + before do + stub_application_setting(auto_devops_enabled: true) + project.create_auto_devops!(enabled: nil) + visit project_settings_ci_cd_path(project) + end + + it 'does not show checkboxes on page-load' do + expect(page).to have_selector('.js-run-auto-devops-pipeline-checkbox-wrapper.hide', count: 1, visible: false) + end + + it 'selecting explicit disabled hides all checkboxes' do + page.choose('project_auto_devops_attributes_enabled_false') + + expect(page).to have_selector('.js-run-auto-devops-pipeline-checkbox-wrapper.hide', count: 1, visible: false) + end + + it 'selecting explicit enabled hides all checkboxes because we are already enabled' do + page.choose('project_auto_devops_attributes_enabled_true') + + expect(page).to have_selector('.js-run-auto-devops-pipeline-checkbox-wrapper.hide', count: 1, visible: false) + end + end + + context 'when auto devops is set to instance default (disabled)' do + before do + stub_application_setting(auto_devops_enabled: false) + project.create_auto_devops!(enabled: nil) + visit project_settings_ci_cd_path(project) + end + + it 'does not show checkboxes on page-load' do + expect(page).to have_selector('.js-run-auto-devops-pipeline-checkbox-wrapper.hide', count: 1, visible: false) + end + + it 'selecting explicit disabled hides all checkboxes' do + page.choose('project_auto_devops_attributes_enabled_false') + + expect(page).to have_selector('.js-run-auto-devops-pipeline-checkbox-wrapper.hide', count: 1, visible: false) + end + + it 'selecting explicit enabled shows a checkbox' do + page.choose('project_auto_devops_attributes_enabled_true') + + expect(page).to have_selector('.js-run-auto-devops-pipeline-checkbox-wrapper:not(.hide)', count: 1) + end + end + + context 'when auto devops is set to explicit disabled' do + before do + stub_application_setting(auto_devops_enabled: true) + project.create_auto_devops!(enabled: false) + visit project_settings_ci_cd_path(project) + end + + it 'does not show checkboxes on page-load' do + expect(page).to have_selector('.js-run-auto-devops-pipeline-checkbox-wrapper.hide', count: 2, visible: false) + end + + it 'selecting explicit enabled shows a checkbox' do + page.choose('project_auto_devops_attributes_enabled_true') + + expect(page).to have_selector('.js-run-auto-devops-pipeline-checkbox-wrapper:not(.hide)', count: 1) + end + + it 'selecting instance default (enabled) shows a checkbox' do + page.choose('project_auto_devops_attributes_enabled_') + + expect(page).to have_selector('.js-run-auto-devops-pipeline-checkbox-wrapper:not(.hide)', count: 1) + end + end + + context 'when auto devops is set to explicit enabled' do + before do + stub_application_setting(auto_devops_enabled: false) + project.create_auto_devops!(enabled: true) + visit project_settings_ci_cd_path(project) + end + + it 'does not have any checkboxes' do + expect(page).not_to have_selector('.js-run-auto-devops-pipeline-checkbox-wrapper', visible: false) + end + end + + context 'when master contains a .gitlab-ci.yml file' do + let(:project) { create(:project, :repository) } + + before do + project.repository.create_file(user, '.gitlab-ci.yml', "script: ['test']", message: 'test', branch_name: project.default_branch) + stub_application_setting(auto_devops_enabled: true) + project.create_auto_devops!(enabled: false) + visit project_settings_ci_cd_path(project) + end + + it 'does not have any checkboxes' do + expect(page).not_to have_selector('.js-run-auto-devops-pipeline-checkbox-wrapper', visible: false) + end + end + end end end end diff --git a/spec/features/projects/snippets_spec.rb b/spec/features/projects/snippets_spec.rb index 1cfbbb4cb62..0fa7ca9afd4 100644 --- a/spec/features/projects/snippets_spec.rb +++ b/spec/features/projects/snippets_spec.rb @@ -39,6 +39,11 @@ describe 'Project snippets', :js do expect(page).to have_selector('.atwho-view') end + + it 'should have zen mode' do + find('.js-zen-enter').click() + expect(page).to have_selector('.fullscreen') + end end end end diff --git a/spec/features/projects/tree/create_directory_spec.rb b/spec/features/projects/tree/create_directory_spec.rb index 1686e7fa342..156293289dd 100644 --- a/spec/features/projects/tree/create_directory_spec.rb +++ b/spec/features/projects/tree/create_directory_spec.rb @@ -26,9 +26,11 @@ feature 'Multi-file editor new directory', :js do click_button('Create directory') end + find('.multi-file-commit-panel-collapse-btn').click + fill_in('commit-message', with: 'commit message') - click_button('Commit 1 file') + click_button('Commit') expect(page).to have_selector('td', text: 'commit message') end diff --git a/spec/features/projects/tree/create_file_spec.rb b/spec/features/projects/tree/create_file_spec.rb index 1e2de0711b8..8fb8476e631 100644 --- a/spec/features/projects/tree/create_file_spec.rb +++ b/spec/features/projects/tree/create_file_spec.rb @@ -26,9 +26,11 @@ feature 'Multi-file editor new file', :js do click_button('Create file') end + find('.multi-file-commit-panel-collapse-btn').click + fill_in('commit-message', with: 'commit message') - click_button('Commit 1 file') + click_button('Commit') expect(page).to have_selector('td', text: 'commit message') end diff --git a/spec/features/projects/tree/upload_file_spec.rb b/spec/features/projects/tree/upload_file_spec.rb index 8439bb5a69e..d4e57d1ecfa 100644 --- a/spec/features/projects/tree/upload_file_spec.rb +++ b/spec/features/projects/tree/upload_file_spec.rb @@ -26,7 +26,7 @@ feature 'Multi-file editor upload file', :js do find('.add-to-tree').click - expect(page).to have_selector('.repo-tab', text: 'doc_sample.txt') + expect(page).to have_selector('.multi-file-tab', text: 'doc_sample.txt') expect(find('.blob-editor-container .lines-content')['innerText']).to have_content(File.open(txt_file, &:readline)) end @@ -39,7 +39,7 @@ feature 'Multi-file editor upload file', :js do find('.add-to-tree').click - expect(page).to have_selector('.repo-tab', text: 'dk.png') + expect(page).to have_selector('.multi-file-tab', text: 'dk.png') expect(page).not_to have_selector('.monaco-editor') expect(page).to have_content('The source could not be displayed for this temporary file.') end |