diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-10-04 03:44:14 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-10-04 03:44:14 +0300 |
commit | 5381985bd012562696637122b1dcd067480a94d3 (patch) | |
tree | 7e05baefc2df32f6ef324cae755de6294c89c92f /spec/features/projects | |
parent | 9c13a512f4a836d2d0d61dc4fbbc6fd8f76aa474 (diff) | |
parent | dfb9ac3a5f97a4c556bacea78174836fe7d39145 (diff) |
Merge branch 'master-ce' into scheduled-manual-jobs
Diffstat (limited to 'spec/features/projects')
-rw-r--r-- | spec/features/projects/environments/environment_spec.rb | 12 | ||||
-rw-r--r-- | spec/features/projects/import_export/export_file_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/projects/jobs/user_browses_job_spec.rb | 14 | ||||
-rw-r--r-- | spec/features/projects/jobs_spec.rb | 166 | ||||
-rw-r--r-- | spec/features/projects/wiki/user_views_wiki_page_spec.rb | 13 |
5 files changed, 172 insertions, 35 deletions
diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb index 4c5dda29fee..70e0879dd81 100644 --- a/spec/features/projects/environments/environment_spec.rb +++ b/spec/features/projects/environments/environment_spec.rb @@ -60,7 +60,7 @@ describe 'Environment' do context 'with manual action' do let(:action) do create(:ci_build, :manual, pipeline: pipeline, - name: 'deploy to production') + name: 'deploy to production', environment: environment.name) end context 'when user has ability to trigger deployment' do @@ -73,12 +73,16 @@ describe 'Environment' do expect(page).to have_link(action.name.humanize) end - it 'does allow to play manual action' do + it 'does allow to play manual action', :js do expect(action).to be_manual + find('button.dropdown').click + expect { click_link(action.name.humanize) } .not_to change { Ci::Pipeline.count } + wait_for_all_requests + expect(page).to have_content(action.name) expect(action.reload).to be_pending end @@ -165,10 +169,10 @@ describe 'Environment' do name: action.ref, project: project) end - it 'allows to stop environment' do + it 'allows to stop environment', :js do click_button('Stop') click_button('Stop environment') # confirm modal - + wait_for_all_requests expect(page).to have_content('close_app') end end diff --git a/spec/features/projects/import_export/export_file_spec.rb b/spec/features/projects/import_export/export_file_spec.rb index a2b96514d64..f76f9ba7577 100644 --- a/spec/features/projects/import_export/export_file_spec.rb +++ b/spec/features/projects/import_export/export_file_spec.rb @@ -12,7 +12,7 @@ describe 'Import/Export - project export integration test', :js do let(:export_path) { "#{Dir.tmpdir}/import_file_spec" } let(:config_hash) { YAML.load_file(Gitlab::ImportExport.config_file).deep_stringify_keys } - let(:sensitive_words) { %w[pass secret token key] } + let(:sensitive_words) { %w[pass secret token key encrypted] } let(:safe_list) do { token: [ProjectHook, Ci::Trigger, CommitStatus], diff --git a/spec/features/projects/jobs/user_browses_job_spec.rb b/spec/features/projects/jobs/user_browses_job_spec.rb index 2d791947ee9..fc7b78ac21f 100644 --- a/spec/features/projects/jobs/user_browses_job_spec.rb +++ b/spec/features/projects/jobs/user_browses_job_spec.rb @@ -16,7 +16,9 @@ describe 'User browses a job', :js do visit(project_job_path(project, build)) end - it 'erases the job log' do + it 'erases the job log', :js do + wait_for_requests + expect(page).to have_content("Job ##{build.id}") expect(page).to have_css('#build-trace') @@ -29,18 +31,17 @@ describe 'User browses a job', :js do expect(build.artifacts_file.exists?).to be_falsy expect(build.artifacts_metadata.exists?).to be_falsy - page.within('.erased') do - expect(page).to have_content('Job has been erased') - end + expect(page).to have_content('Job has been erased') end context 'with a failed job' do let!(:build) { create(:ci_build, :failed, :trace_artifact, pipeline: pipeline) } it 'displays the failure reason' do + wait_for_all_requests within('.builds-container') do build_link = first('.build-job > a') - expect(build_link['data-title']).to eq('test - failed - (unknown failure)') + expect(build_link['data-original-title']).to eq('test - failed - (unknown failure)') end end end @@ -49,9 +50,10 @@ describe 'User browses a job', :js do let!(:build) { create(:ci_build, :failed, :retried, :trace_artifact, pipeline: pipeline) } it 'displays the failure reason and retried label' do + wait_for_all_requests within('.builds-container') do build_link = first('.build-job > a') - expect(build_link['data-title']).to eq('test - failed - (unknown failure) (retried)') + expect(build_link['data-original-title']).to eq('test - failed - (unknown failure) (retried)') end end end diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 5b767c96910..45fc492f23f 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -134,23 +134,25 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do expect(page).to have_content pipeline.commit.title end - it 'shows active job' do + it 'shows active job', :js do visit project_job_path(project, job) + wait_for_requests expect(page).to have_selector('.build-job.active') end end - context 'sidebar' do + context 'sidebar', :js do let(:job) { create(:ci_build, :success, :trace_live, pipeline: pipeline, name: '<img src=x onerror=alert(document.domain)>') } before do visit project_job_path(project, job) + wait_for_requests end it 'renders escaped tooltip name' do page.within('aside.right-sidebar') do - expect(find('.active.build-job a')['data-title']).to eq('<img src="x"> - passed') + expect(find('.active.build-job a')['data-original-title']).to eq('<img src=x onerror=alert(document.domain)> - passed') end end end @@ -367,39 +369,167 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do end end - context 'when job starts environment' do - let(:environment) { create(:environment, project: project) } - let(:pipeline) { create(:ci_pipeline, project: project) } + context 'when job starts environment', :js do + let(:environment) { create(:environment, name: 'production', project: project) } - context 'job is successfull and has deployment' do - let(:deployment) { create(:deployment) } - let(:job) { create(:ci_build, :success, :trace_artifact, environment: environment.name, deployments: [deployment], pipeline: pipeline) } + context 'job is successful and has deployment' do + let(:build) { create(:ci_build, :success, :trace_live, environment: environment.name, pipeline: pipeline) } + let!(:deployment) { create(:deployment, environment: environment, project: environment.project, deployable: build) } - it 'shows a link for the job' do - visit project_job_path(project, job) + before do + visit project_job_path(project, build) + wait_for_requests + # scroll to the top of the page first + execute_script "window.scrollTo(0,0)" + end + it 'shows a link for the job' do expect(page).to have_link environment.name end + + it 'shows deployment message' do + expect(page).to have_content 'This job is the most recent deployment' + expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}") + end end context 'job is complete and not successful' do - let(:job) { create(:ci_build, :failed, :trace_artifact, environment: environment.name, pipeline: pipeline) } + let(:build) { create(:ci_build, :failed, :trace_artifact, environment: environment.name, pipeline: pipeline) } it 'shows a link for the job' do - visit project_job_path(project, job) + visit project_job_path(project, build) + wait_for_requests + # scroll to the top of the page first + execute_script "window.scrollTo(0,0)" expect(page).to have_link environment.name + expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}") end end - context 'job creates a new deployment' do - let!(:deployment) { create(:deployment, environment: environment, sha: project.commit.id) } - let(:job) { create(:ci_build, :success, :trace_artifact, environment: environment.name, pipeline: pipeline) } + context 'deployment still not finished' do + let(:build) { create(:ci_build, :success, environment: environment.name, pipeline: pipeline) } it 'shows a link to latest deployment' do - visit project_job_path(project, job) + visit project_job_path(project, build) + wait_for_all_requests + # scroll to the top of the page first + execute_script "window.scrollTo(0,0)" + + expect(page).to have_link environment.name + expect(page).to have_content 'This job is creating a deployment' + expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}") + end + end + end + + describe 'environment info in job view', :js do + before do + visit project_job_path(project, job) + wait_for_requests + # scroll to the top of the page first + execute_script "window.scrollTo(0,0)" + end + + context 'job with outdated deployment' do + let(:job) { create(:ci_build, :success, :trace_artifact, environment: 'staging', pipeline: pipeline) } + let(:second_build) { create(:ci_build, :success, :trace_artifact, environment: 'staging', pipeline: pipeline) } + let(:environment) { create(:environment, name: 'staging', project: project) } + let!(:first_deployment) { create(:deployment, environment: environment, deployable: job) } + let!(:second_deployment) { create(:deployment, environment: environment, deployable: second_build) } + + it 'shows deployment message' do + expected_text = 'This job is an out-of-date deployment ' \ + "to staging. View the most recent deployment ##{second_deployment.iid}." + + expect(page).to have_css('.environment-information', text: expected_text) + end + + it 'renders a link to the most recent deployment' do + expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}") + expect(find('.js-job-deployment-link')['href']).to include(second_deployment.deployable.project.path, second_deployment.deployable_id.to_s) + end + end + + context 'job failed to deploy' do + let(:job) { create(:ci_build, :failed, :trace_artifact, environment: 'staging', pipeline: pipeline) } + let!(:environment) { create(:environment, name: 'staging', project: project) } + + it 'shows deployment message' do + expected_text = 'The deployment of this job to staging did not succeed.' + + expect(page).to have_css( + '.environment-information', text: expected_text) + end + end + + context 'job will deploy' do + let(:job) { create(:ci_build, :running, :trace_live, environment: 'staging', pipeline: pipeline) } + + context 'when environment exists' do + let!(:environment) { create(:environment, name: 'staging', project: project) } + + it 'shows deployment message' do + expected_text = 'This job is creating a deployment to staging' + + expect(page).to have_css( + '.environment-information', text: expected_text) + expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}") + end + + context 'when it has deployment' do + let!(:deployment) { create(:deployment, environment: environment) } + + it 'shows that deployment will be overwritten' do + expected_text = 'This job is creating a deployment to staging' + + expect(page).to have_css( + '.environment-information', text: expected_text) + expect(page).to have_css( + '.environment-information', text: 'latest deployment') + expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}") + end + end + end + + context 'when environment does not exist' do + let!(:environment) { create(:environment, name: 'staging', project: project) } + + it 'shows deployment message' do + expected_text = 'This job is creating a deployment to staging' + + expect(page).to have_css( + '.environment-information', text: expected_text) + expect(page).not_to have_css( + '.environment-information', text: 'latest deployment') + expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}") + end + end + end + + context 'job that failed to deploy and environment has not been created' do + let(:job) { create(:ci_build, :failed, :trace_artifact, environment: 'staging', pipeline: pipeline) } + let!(:environment) { create(:environment, name: 'staging', project: project) } + + it 'shows deployment message' do + expected_text = 'The deployment of this job to staging did not succeed' + + expect(page).to have_css( + '.environment-information', text: expected_text) + end + end + + context 'job that will deploy and environment has not been created' do + let(:job) { create(:ci_build, :running, :trace_live, environment: 'staging', pipeline: pipeline) } + let!(:environment) { create(:environment, name: 'staging', project: project) } + + it 'shows deployment message' do + expected_text = 'This job is creating a deployment to staging' - expect(page).to have_link('latest deployment') + expect(page).to have_css( + '.environment-information', text: expected_text) + expect(page).not_to have_css( + '.environment-information', text: 'latest deployment') end end end diff --git a/spec/features/projects/wiki/user_views_wiki_page_spec.rb b/spec/features/projects/wiki/user_views_wiki_page_spec.rb index 747406efc8b..9a4ce426e69 100644 --- a/spec/features/projects/wiki/user_views_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_views_wiki_page_spec.rb @@ -83,12 +83,13 @@ describe 'User views a wiki page' do end it 'shows a file stored in a page' do - gollum_file_double = double('Gollum::File', - mime_type: 'image/jpeg', - name: 'images/image.jpg', - path: 'images/image.jpg', - raw_data: '') - wiki_file = Gitlab::Git::WikiFile.new(gollum_file_double) + raw_file = Gitlab::GitalyClient::WikiFile.new( + mime_type: 'image/jpeg', + name: 'images/image.jpg', + path: 'images/image.jpg', + raw_data: '' + ) + wiki_file = Gitlab::Git::WikiFile.new(raw_file) allow(wiki_file).to receive(:mime_type).and_return('image/jpeg') allow_any_instance_of(ProjectWiki).to receive(:find_file).with('image.jpg', nil).and_return(wiki_file) |