diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2018-10-22 22:06:05 +0200 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2018-10-22 22:06:05 +0200 |
commit | 53be95daf41fc4e59deab149485210835e7e54cd (patch) | |
tree | 3f377dcc6289049581e2473b7e12f260e774784f /spec/features/projects | |
parent | 3fb7a1f97a812b7b2b5e80a8a0575cb7bfd2d3c4 (diff) | |
parent | d6be7ed79557ce31a5d0062ceea00c877157a6c7 (diff) | |
download | gitlab-ce-53be95daf41fc4e59deab149485210835e7e54cd.tar.gz |
Merge branch 'master' into scheduled-manual-jobs-environment-play-buttons
Conflicts:
spec/javascripts/environments/environment_actions_spec.js
Diffstat (limited to 'spec/features/projects')
10 files changed, 121 insertions, 101 deletions
diff --git a/spec/features/projects/commit/comments/user_adds_comment_spec.rb b/spec/features/projects/commit/comments/user_adds_comment_spec.rb index 6397df086a7..29442a58ea4 100644 --- a/spec/features/projects/commit/comments/user_adds_comment_spec.rb +++ b/spec/features/projects/commit/comments/user_adds_comment_spec.rb @@ -28,19 +28,19 @@ describe "User adds a comment on a commit", :js do fill_in("note[note]", with: "#{comment_text} #{emoji}") # Check on `Preview` tab - click_link("Preview") + click_button("Preview") expect(find(".js-md-preview")).to have_content(comment_text).and have_css("gl-emoji") expect(page).not_to have_css(".js-note-text") # Check on the `Write` tab - click_link("Write") + click_button("Write") expect(page).to have_field("note[note]", with: "#{comment_text} #{emoji}") # Submit comment from the `Preview` tab to get rid of a separate `it` block # which would specially tests if everything gets cleared from the note form. - click_link("Preview") + click_button("Preview") click_button("Comment") end @@ -88,13 +88,13 @@ describe "User adds a comment on a commit", :js do # Test Preview feature for both forms. page.within("form[data-line-code='#{sample_commit.line_code}']") do - click_link("Preview") + click_button("Preview") end page.within("form[data-line-code='#{sample_commit.del_line_code}']") do fill_in("note[note]", with: another_comment_text) - click_link("Preview") + click_button("Preview") end expect(page).to have_css(".js-md-preview", visible: true, count: 2) diff --git a/spec/features/projects/commit/user_comments_on_commit_spec.rb b/spec/features/projects/commit/user_comments_on_commit_spec.rb index 6397a8ad845..73ce8d2b996 100644 --- a/spec/features/projects/commit/user_comments_on_commit_spec.rb +++ b/spec/features/projects/commit/user_comments_on_commit_spec.rb @@ -25,19 +25,19 @@ describe "User comments on commit", :js do fill_in("note[note]", with: "#{comment_text} #{emoji_code}") # Check on `Preview` tab - click_link("Preview") + click_button("Preview") expect(find(".js-md-preview")).to have_content(comment_text).and have_css("gl-emoji") expect(page).not_to have_css(".js-note-text") # Check on `Write` tab - click_link("Write") + click_button("Write") expect(page).to have_field("note[note]", with: "#{comment_text} #{emoji_code}") # Submit comment from the `Preview` tab to get rid of a separate `it` block # which would specially tests if everything gets cleared from the note form. - click_link("Preview") + click_button("Preview") click_button("Comment") end diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index 89e21fcd56b..22d0187ac81 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -95,7 +95,7 @@ describe 'Environments page', :js do end 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).to have_content('You don\'t have any environments right now') expect(page.find('.js-environments-tab-available .badge').text).to eq('0') expect(page.find('.js-environments-tab-stopped .badge').text).to eq('0') diff --git a/spec/features/projects/files/user_deletes_files_spec.rb b/spec/features/projects/files/user_deletes_files_spec.rb index dcb7b947c61..614b11fa5c8 100644 --- a/spec/features/projects/files/user_deletes_files_spec.rb +++ b/spec/features/projects/files/user_deletes_files_spec.rb @@ -31,7 +31,7 @@ describe 'Projects > Files > User deletes files', :js do fill_in(:commit_message, with: 'New commit message', visible: true) click_button('Delete file') - expect(current_path).to eq(project_tree_path(project, 'master')) + expect(current_path).to eq(project_tree_path(project, 'master/')) expect(page).not_to have_content('.gitignore') end end diff --git a/spec/features/projects/jobs/permissions_spec.rb b/spec/features/projects/jobs/permissions_spec.rb index e639f0cf82e..6ce37297a7e 100644 --- a/spec/features/projects/jobs/permissions_spec.rb +++ b/spec/features/projects/jobs/permissions_spec.rb @@ -67,7 +67,7 @@ describe 'Project Jobs Permissions' do it_behaves_like 'recent job page details responds with status', 200 do it 'renders job details', :js do expect(page).to have_content "Job ##{job.id}" - expect(page).to have_css '#build-trace' + expect(page).to have_css '.js-build-trace' end end diff --git a/spec/features/projects/jobs/user_browses_job_spec.rb b/spec/features/projects/jobs/user_browses_job_spec.rb index fc7b78ac21f..908c616f2fc 100644 --- a/spec/features/projects/jobs/user_browses_job_spec.rb +++ b/spec/features/projects/jobs/user_browses_job_spec.rb @@ -20,7 +20,7 @@ describe 'User browses a job', :js do wait_for_requests expect(page).to have_content("Job ##{build.id}") - expect(page).to have_css('#build-trace') + expect(page).to have_css('.js-build-trace') # scroll to the top of the page first execute_script "window.scrollTo(0,0)" diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 2076ce7b4f7..1ea8a640e17 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -294,7 +294,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do end end - describe 'Raw trace' do + describe 'Raw trace', :js do before do job.run! @@ -302,7 +302,8 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do end it do - expect(page).to have_css('.js-raw-link') + wait_for_all_requests + expect(page).to have_css('.js-raw-link-controller') end end @@ -372,17 +373,15 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do context 'when job starts environment', :js do let(:environment) { create(:environment, name: 'production', project: project) } + before do + visit project_job_path(project, build) + wait_for_requests + end + 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) } - 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 @@ -397,11 +396,6 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do 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, 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 @@ -411,11 +405,6 @@ describe 'Jobs', :clean_gitlab_redis_shared_state 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, 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}") @@ -423,12 +412,35 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do end end + context 'when job stops environment', :js do + let(:environment) { create(:environment, name: 'production', project: project) } + let(:build) do + create( + :ci_build, + :success, + :trace_live, + environment: environment.name, + pipeline: pipeline, + options: { environment: { action: 'stop' } } + ) + end + + before do + visit project_job_path(project, build) + wait_for_requests + end + + it 'does not show environment information banner' do + expect(page).not_to have_selector('.js-environment-container') + expect(page).not_to have_selector('.environment-information') + expect(page).not_to have_text(environment.name) + 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 @@ -458,8 +470,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do 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) + expect(page).to have_css('.environment-information', text: expected_text) end end @@ -472,8 +483,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do 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).to have_css('.environment-information', text: expected_text) expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}") end @@ -483,10 +493,8 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do 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(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 @@ -568,7 +576,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do end it 'shows delayed job', :js do - expect(page).to have_content('This is a scheduled to run in') + expect(page).to have_content('This is a delayed to run in') expect(page).to have_content("This job will automatically run after it's timer finishes.") expect(page).to have_link('Unschedule job') end @@ -611,7 +619,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do end end - context 'Canceled job' do + context 'Canceled job', :js do context 'with log' do let(:job) { create(:ci_build, :canceled, :trace_artifact, pipeline: pipeline) } @@ -620,7 +628,8 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do end it 'renders job log' do - expect(page).to have_selector('.js-build-output') + wait_for_all_requests + expect(page).to have_selector('.js-build-trace') end end @@ -633,7 +642,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do it 'renders empty state' do expect(page).to have_content(job.detailed_status(user).illustration[:title]) - expect(page).not_to have_selector('.js-build-output') + expect(page).not_to have_selector('.js-build-trace') expect(page).to have_content('This job has been canceled') end end @@ -648,7 +657,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do it 'renders empty state' do expect(page).to have_content(job.detailed_status(user).illustration[:title]) - expect(page).not_to have_selector('.js-build-output') + expect(page).not_to have_selector('.js-build-trace') expect(page).to have_content('This job has been skipped') end end @@ -663,6 +672,56 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do expect(page).to have_content('This job does not have a trace.') end end + + context 'with erased job', :js do + let(:job) { create(:ci_build, :erased, pipeline: pipeline) } + + it 'renders erased job warning' do + visit project_job_path(project, job) + wait_for_requests + + page.within('.js-job-erased-block') do + expect(page).to have_content('Job has been erased') + end + end + end + + context 'without erased job', :js do + let(:job) { create(:ci_build, pipeline: pipeline) } + + it 'does not render erased job warning' do + visit project_job_path(project, job) + wait_for_requests + + expect(page).not_to have_css('.js-job-erased-block') + end + end + + context 'on mobile', :js do + let(:job) { create(:ci_build, pipeline: pipeline) } + + it 'renders collpased sidebar' do + page.current_window.resize_to(600, 800) + + visit project_job_path(project, job) + wait_for_requests + + expect(page).to have_css('.js-job-sidebar.right-sidebar-collapsed', visible: false) + expect(page).not_to have_css('.js-job-sidebar.right-sidebar-expanded', visible: false) + end + end + + context 'on desktop', :js do + let(:job) { create(:ci_build, pipeline: pipeline) } + + it 'renders expanded sidebar' do + visit project_job_path(project, job) + wait_for_requests + + expect(page).to have_css('.js-job-sidebar.right-sidebar-expanded') + expect(page).not_to have_css('.js-job-sidebar.right-sidebar-collpased') + end + end end describe "POST /:project/jobs/:id/cancel", :js do diff --git a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb index 6fe21579e8e..df2b492ae6b 100644 --- a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb +++ b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb @@ -350,41 +350,6 @@ describe 'Projects > Show > User sees setup shortcut buttons' do end end end - - describe '"Set up Koding" button' do - it 'no "Set up Koding" button if Koding disabled' do - stub_application_setting(koding_enabled?: false) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).not_to have_link('Set up Koding') - end - end - - it 'no "Set up Koding" button if the project already has a .koding.yml' do - stub_application_setting(koding_enabled?: true) - allow(Gitlab::CurrentSettings.current_application_settings).to receive(:koding_url).and_return('http://koding.example.com') - expect(project.repository.changelog).not_to be_nil - allow_any_instance_of(Repository).to receive(:koding_yml).and_return(project.repository.changelog) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).not_to have_link('Set up Koding') - end - end - - it '"Set up Koding" button linked to new file populated for a .koding.yml' do - stub_application_setting(koding_enabled?: true) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).to have_link('Set up Koding', href: presenter.add_koding_stack_path) - end - end - end end end end diff --git a/spec/features/projects/wiki/user_views_wiki_empty_spec.rb b/spec/features/projects/wiki/user_views_wiki_empty_spec.rb index 83ffbb4a94e..e94b3a9432b 100644 --- a/spec/features/projects/wiki/user_views_wiki_empty_spec.rb +++ b/spec/features/projects/wiki/user_views_wiki_empty_spec.rb @@ -54,7 +54,7 @@ describe 'User views empty wiki' do it_behaves_like 'empty wiki and non-accessible issues' end - context 'when user is logged in and a memeber' do + context 'when user is logged in and a member' do let(:project) { create(:project, :public, :wiki_repo) } before do 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 9a4ce426e69..4b974a3ca10 100644 --- a/spec/features/projects/wiki/user_views_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_views_wiki_page_spec.rb @@ -2,12 +2,15 @@ require 'spec_helper' describe 'User views a wiki page' do shared_examples 'wiki page user view' do + include WikiHelpers + let(:user) { create(:user) } let(:project) { create(:project, :wiki_repo, namespace: user.namespace) } + let(:path) { 'image.png' } let(:wiki_page) do create(:wiki_page, wiki: project.wiki, - attrs: { title: 'home', content: 'Look at this [image](image.jpg)\n\n ![alt text](image.jpg)' }) + attrs: { title: 'home', content: "Look at this [image](#{path})\n\n ![alt text](#{path})" }) end before do @@ -82,33 +85,26 @@ describe 'User views a wiki page' do expect(find('.wiki-pages')).to have_content(wiki_page.title.capitalize) end - it 'shows a file stored in a page' do - 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) + context 'shows a file stored in a page' do + let(:path) { upload_file_to_wiki(project, user, 'dk.png') } - expect(page).to have_xpath("//img[@data-src='#{project.wiki.wiki_base_path}/image.jpg']") - expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/image.jpg") + it do + expect(page).to have_xpath("//img[@data-src='#{project.wiki.wiki_base_path}/#{path}']") + expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/#{path}") - click_on('image') + click_on('image') - expect(current_path).to match('wikis/image.jpg') - expect(page).not_to have_xpath('/html') # Page should render the image which means there is no html involved + expect(current_path).to match("wikis/#{path}") + expect(page).not_to have_xpath('/html') # Page should render the image which means there is no html involved + end end it 'shows the creation page if file does not exist' do - expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/image.jpg") + expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/#{path}") click_on('image') - expect(current_path).to match('wikis/image.jpg') + expect(current_path).to match("wikis/#{path}") expect(page).to have_content('New Wiki Page') expect(page).to have_content('Create page') end |