diff options
Diffstat (limited to 'spec/features')
30 files changed, 315 insertions, 258 deletions
diff --git a/spec/features/admin/admin_appearance_spec.rb b/spec/features/admin/admin_appearance_spec.rb index 3c2ae5b3c6a..57215c0d1e9 100644 --- a/spec/features/admin/admin_appearance_spec.rb +++ b/spec/features/admin/admin_appearance_spec.rb @@ -10,10 +10,10 @@ describe 'Admin Appearance' do fill_in 'appearance_title', with: 'MyCompany' fill_in 'appearance_description', with: 'dev server' fill_in 'appearance_new_project_guidelines', with: 'Custom project guidelines' - click_button 'Save' + click_button 'Update appearance settings' expect(current_path).to eq admin_appearances_path - expect(page).to have_content 'Appearance settings' + expect(page).to have_content 'Appearance' expect(page).to have_field('appearance_title', with: 'MyCompany') expect(page).to have_field('appearance_description', with: 'dev server') @@ -57,7 +57,7 @@ describe 'Admin Appearance' do visit admin_appearances_path attach_file(:appearance_logo, logo_fixture) - click_button 'Save' + click_button 'Update appearance settings' expect(page).to have_css(logo_selector) click_link 'Remove logo' @@ -69,7 +69,7 @@ describe 'Admin Appearance' do visit admin_appearances_path attach_file(:appearance_header_logo, logo_fixture) - click_button 'Save' + click_button 'Update appearance settings' expect(page).to have_css(header_logo_selector) click_link 'Remove header logo' @@ -81,7 +81,7 @@ describe 'Admin Appearance' do visit admin_appearances_path attach_file(:appearance_favicon, logo_fixture) - click_button 'Save' + click_button 'Update appearance settings' expect(page).to have_css('.appearance-light-logo-preview') @@ -91,7 +91,7 @@ describe 'Admin Appearance' do # allowed file types attach_file(:appearance_favicon, Rails.root.join('spec', 'fixtures', 'sanitized.svg')) - click_button 'Save' + click_button 'Update appearance settings' expect(page).to have_content 'Favicon You are not allowed to upload "svg" files, allowed types: png, ico' end diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index 931095936a6..b1c6f308bc6 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' describe "Admin::Users" do - include Spec::Support::Helpers::Features::ListRowsHelpers + include Spec::Support::Helpers::Features::ResponsiveTableHelpers let!(:user) do create(:omniauth_user, provider: 'twitter', extern_uid: '123456') end - let!(:current_user) { create(:admin) } + let!(:current_user) { create(:admin, last_activity_on: 5.days.ago) } before do sign_in(current_user) @@ -25,6 +25,8 @@ describe "Admin::Users" do it "has users list" do expect(page).to have_content(current_user.email) expect(page).to have_content(current_user.name) + expect(page).to have_content(current_user.created_at.strftime("%e %b, %Y")) + expect(page).to have_content(current_user.last_activity_on.strftime("%e %b, %Y")) expect(page).to have_content(user.email) expect(page).to have_content(user.name) expect(page).to have_link('Block', href: block_admin_user_path(user)) @@ -32,10 +34,24 @@ describe "Admin::Users" do expect(page).to have_button('Delete user and contributions') end + describe "view extra user information", :js do + it 'does not have the user popover open' do + expect(page).not_to have_selector('#__BV_popover_1__') + end + + it 'shows the user popover on hover' do + first_user_link = page.first('.js-user-link') + + first_user_link.hover + + expect(page).to have_selector('#__BV_popover_1__') + end + end + describe 'search and sort' do before do - create(:user, name: 'Foo Bar') - create(:user, name: 'Foo Baz') + create(:user, name: 'Foo Bar', last_activity_on: 3.days.ago) + create(:user, name: 'Foo Baz', last_activity_on: 2.days.ago) create(:user, name: 'Dmitriy') end @@ -75,6 +91,24 @@ describe "Admin::Users" do expect(first_row.text).to include('Foo Bar') expect(second_row.text).to include('Foo Baz') end + + it 'sorts users by recent last activity' do + visit admin_users_path(search_query: 'Foo') + + sort_by('Recent last activity') + + expect(first_row.text).to include('Foo Baz') + expect(second_row.text).to include('Foo Bar') + end + + it 'sorts users by oldest last activity' do + visit admin_users_path(search_query: 'Foo') + + sort_by('Oldest last activity') + + expect(first_row.text).to include('Foo Bar') + expect(second_row.text).to include('Foo Baz') + end end describe 'Two-factor Authentication filters' do diff --git a/spec/features/clusters/cluster_detail_page_spec.rb b/spec/features/clusters/cluster_detail_page_spec.rb new file mode 100644 index 00000000000..0a9c4bcaf12 --- /dev/null +++ b/spec/features/clusters/cluster_detail_page_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Clusterable > Show page' do + let(:current_user) { create(:user) } + + before do + sign_in(current_user) + end + + shared_examples 'editing domain' do + before do + clusterable.add_maintainer(current_user) + end + + it 'allow the user to set domain' do + visit cluster_path + + within '#cluster-integration' do + fill_in('cluster_base_domain', with: 'test.com') + click_on 'Save changes' + end + + expect(page.status_code).to eq(200) + expect(page).to have_content('Kubernetes cluster was successfully updated.') + end + + context 'when there is a cluster with ingress and external ip' do + before do + cluster.create_application_ingress!(external_ip: '192.168.1.100') + + visit cluster_path + end + + it 'shows help text with the domain as an alternative to custom domain' do + within '#cluster-integration' do + expect(page).to have_content('Alternatively 192.168.1.100.nip.io can be used instead of a custom domain') + end + end + end + + context 'when there is no ingress' do + it 'alternative to custom domain is not shown' do + visit cluster_path + + within '#cluster-integration' do + expect(page).not_to have_content('can be used instead of a custom domain.') + end + end + end + end + + context 'when clusterable is a project' do + it_behaves_like 'editing domain' do + let(:clusterable) { create(:project) } + let(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [clusterable]) } + let(:cluster_path) { project_cluster_path(clusterable, cluster) } + end + end + + context 'when clusterable is a group' do + it_behaves_like 'editing domain' do + let(:clusterable) { create(:group) } + let(:cluster) { create(:cluster, :provided_by_gcp, :group, groups: [clusterable]) } + let(:cluster_path) { group_cluster_path(clusterable, cluster) } + end + end +end diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index edca8f9df08..6c4b04ab76b 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -147,6 +147,27 @@ describe 'Dashboard Projects' do expect(page).to have_link('Commit: passed') end end + + context 'guest user of project and project has private pipelines' do + let(:guest_user) { create(:user) } + + before do + project.update(public_builds: false) + project.add_guest(guest_user) + sign_in(guest_user) + end + + it 'shows that the last pipeline passed' do + visit dashboard_projects_path + + page.within('.controls') do + expect(page).not_to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit, ref: pipeline.ref)}']") + expect(page).not_to have_css('.ci-status-link') + expect(page).not_to have_css('.ci-status-icon-success') + expect(page).not_to have_link('Commit: passed') + end + end + end end context 'last push widget', :use_clean_rails_memory_store_caching do diff --git a/spec/features/markdown/copy_as_gfm_spec.rb b/spec/features/markdown/copy_as_gfm_spec.rb index 16754035076..60ddb02da2c 100644 --- a/spec/features/markdown/copy_as_gfm_spec.rb +++ b/spec/features/markdown/copy_as_gfm_spec.rb @@ -843,6 +843,7 @@ describe 'Copy as GFM', :js do def verify(selector, gfm, target: nil) html = html_for_selector(selector) output_gfm = html_to_gfm(html, 'transformCodeSelection', target: target) + wait_for_requests expect(output_gfm.strip).to eq(gfm.strip) end end @@ -861,6 +862,9 @@ describe 'Copy as GFM', :js do def html_to_gfm(html, transformer = 'transformGFMSelection', target: nil) js = <<~JS (function(html) { + // Setting it off so the import already starts + window.CopyAsGFM.nodeToGFM(document.createElement('div')); + var transformer = window.CopyAsGFM[#{transformer.inspect}]; var node = document.createElement('div'); @@ -875,9 +879,18 @@ describe 'Copy as GFM', :js do node = transformer(node, target); if (!node) return null; - return window.CopyAsGFM.nodeToGFM(node); + + window.gfmCopytestRes = null; + window.CopyAsGFM.nodeToGFM(node) + .then((res) => { + window.gfmCopytestRes = res; + }); })("#{escape_javascript(html)}") JS - page.evaluate_script(js) + page.execute_script(js) + + loop until page.evaluate_script('window.gfmCopytestRes !== null') + + page.evaluate_script('window.gfmCopytestRes') end end diff --git a/spec/features/markdown/markdown_spec.rb b/spec/features/markdown/markdown_spec.rb index 3b37ede8579..8815643ca96 100644 --- a/spec/features/markdown/markdown_spec.rb +++ b/spec/features/markdown/markdown_spec.rb @@ -13,7 +13,7 @@ require 'erb' # # Raw Markdown # -> `markdown` helper -# -> Redcarpet::Render::GitlabHTML converts Markdown to HTML +# -> CommonMark::Render::GitlabHTML converts Markdown to HTML # -> Post-process HTML # -> `gfm` helper # -> HTML::Pipeline @@ -324,31 +324,6 @@ describe 'GitLab Markdown', :aggregate_failures do end end - context 'Redcarpet documents' do - before do - allow_any_instance_of(Banzai::Filter::MarkdownFilter).to receive(:engine).and_return('Redcarpet') - @html = markdown(@feat.raw_markdown) - end - - it 'processes certain elements differently' do - aggregate_failures 'parses superscript' do - expect(doc).to have_selector('sup', count: 3) - end - - aggregate_failures 'permits style attribute in th elements' do - expect(doc.at_css('th:contains("Header")')['style']).to eq 'text-align: center' - expect(doc.at_css('th:contains("Row")')['style']).to eq 'text-align: right' - expect(doc.at_css('th:contains("Example")')['style']).to eq 'text-align: left' - end - - aggregate_failures 'permits style attribute in td elements' do - expect(doc.at_css('td:contains("Foo")')['style']).to eq 'text-align: center' - expect(doc.at_css('td:contains("Bar")')['style']).to eq 'text-align: right' - expect(doc.at_css('td:contains("Baz")')['style']).to eq 'text-align: left' - end - end - end - # Fake a `current_user` helper def current_user @feat.user diff --git a/spec/features/markdown/math_spec.rb b/spec/features/markdown/math_spec.rb index 678ce80b382..16ad0d456be 100644 --- a/spec/features/markdown/math_spec.rb +++ b/spec/features/markdown/math_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe 'Math rendering', :js do + let!(:project) { create(:project, :public) } + it 'renders inline and display math correctly' do description = <<~MATH This math is inline $`a^2+b^2=c^2`$. @@ -11,7 +13,6 @@ describe 'Math rendering', :js do ``` MATH - project = create(:project, :public) issue = create(:issue, project: project, description: description) visit project_issue_path(project, issue) @@ -19,4 +20,19 @@ describe 'Math rendering', :js do expect(page).to have_selector('.katex .mord.mathdefault', text: 'b') expect(page).to have_selector('.katex-display .mord.mathdefault', text: 'b') end + + it 'only renders non XSS links' do + description = <<~MATH + This link is valid $`\\href{javascript:alert('xss');}{xss}`$. + + This link is valid $`\\href{https://gitlab.com}{Gitlab}`$. + MATH + + issue = create(:issue, project: project, description: description) + + visit project_issue_path(project, issue) + + expect(page).to have_selector('.katex-error', text: "\href{javascript:alert('xss');}{xss}") + expect(page).to have_selector('.katex-html a', text: 'Gitlab') + end end diff --git a/spec/features/merge_request/user_accepts_merge_request_spec.rb b/spec/features/merge_request/user_accepts_merge_request_spec.rb index 00ac7c72a11..5fa23dbb998 100644 --- a/spec/features/merge_request/user_accepts_merge_request_spec.rb +++ b/spec/features/merge_request/user_accepts_merge_request_spec.rb @@ -80,8 +80,8 @@ describe 'User accepts a merge request', :js do end it 'accepts a merge request' do - click_button('Modify commit message') - fill_in('Commit message', with: 'wow such merge') + find('.js-mr-widget-commits-count').click + fill_in('merge-message-edit', with: 'wow such merge') click_button('Merge') diff --git a/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb b/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb index 8d2d4279d3c..c6b11fce388 100644 --- a/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb +++ b/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb @@ -13,7 +13,7 @@ describe 'Merge request < User customizes merge commit message', :js do description: "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" ) end - let(:textbox) { page.find(:css, '.js-commit-message', visible: false) } + let(:textbox) { page.find(:css, '#merge-message-edit', visible: false) } let(:default_message) do [ "Merge branch 'feature' into 'master'", @@ -38,16 +38,16 @@ describe 'Merge request < User customizes merge commit message', :js do end it 'toggles commit message between message with description and without description' do - expect(page).not_to have_selector('.js-commit-message') - click_button "Modify commit message" + expect(page).not_to have_selector('#merge-message-edit') + first('.js-mr-widget-commits-count').click expect(textbox).to be_visible expect(textbox.value).to eq(default_message) - click_link "Include description in commit message" + check('Include merge request description') expect(textbox.value).to eq(message_with_description) - click_link "Don't include description in commit message" + uncheck('Include merge request description') expect(textbox.value).to eq(default_message) end diff --git a/spec/features/merge_request/user_posts_notes_spec.rb b/spec/features/merge_request/user_posts_notes_spec.rb index ee5f5377ca6..1bbcf455ac7 100644 --- a/spec/features/merge_request/user_posts_notes_spec.rb +++ b/spec/features/merge_request/user_posts_notes_spec.rb @@ -66,6 +66,38 @@ describe 'Merge request > User posts notes', :js do is_expected.to have_css('.js-note-text', visible: true) end end + + describe 'when reply_to_individual_notes feature flag is not set' do + before do + stub_feature_flags(reply_to_individual_notes: false) + visit project_merge_request_path(project, merge_request) + end + + it 'does not show a reply button' do + expect(page).to have_no_selector('.js-reply-button') + end + end + + describe 'when reply_to_individual_notes feature flag is set' do + before do + stub_feature_flags(reply_to_individual_notes: true) + visit project_merge_request_path(project, merge_request) + end + + it 'shows a reply button' do + reply_button = find('.js-reply-button', match: :first) + + expect(reply_button).to have_selector('.ic-comment') + end + + it 'shows reply placeholder when clicking reply button' do + reply_button = find('.js-reply-button', match: :first) + + reply_button.click + + expect(page).to have_selector('.discussion-reply-holder') + end + end end describe 'when previewing a note' do diff --git a/spec/features/merge_request/user_resolves_conflicts_spec.rb b/spec/features/merge_request/user_resolves_conflicts_spec.rb index 50c723776a3..16c058ab6bd 100644 --- a/spec/features/merge_request/user_resolves_conflicts_spec.rb +++ b/spec/features/merge_request/user_resolves_conflicts_spec.rb @@ -37,6 +37,8 @@ describe 'Merge request > User resolves conflicts', :js do click_on 'Changes' wait_for_requests + find('.js-toggle-tree-list').click + within find('.diff-file', text: 'files/ruby/popen.rb') do expect(page).to have_selector('.line_content.new', text: "vars = { 'PWD' => path }") expect(page).to have_selector('.line_content.new', text: "options = { chdir: path }") diff --git a/spec/features/merge_request/user_sees_versions_spec.rb b/spec/features/merge_request/user_sees_versions_spec.rb index 63d8decc2d2..aa91ade46ca 100644 --- a/spec/features/merge_request/user_sees_versions_spec.rb +++ b/spec/features/merge_request/user_sees_versions_spec.rb @@ -42,7 +42,7 @@ describe 'Merge request > User sees versions', :js do expect(page).to have_content 'latest version' end - expect(page).to have_content '8 changed files' + expect(page).to have_content '8 Files' end it_behaves_like 'allows commenting', @@ -76,7 +76,7 @@ describe 'Merge request > User sees versions', :js do end it 'shows comments that were last relevant at that version' do - expect(page).to have_content '5 changed files' + expect(page).to have_content '5 Files' position = Gitlab::Diff::Position.new( old_path: ".gitmodules", @@ -120,8 +120,15 @@ describe 'Merge request > User sees versions', :js do diff_id: merge_request_diff3.id, start_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9' ) - expect(page).to have_content '4 changed files' - expect(page).to have_content '15 additions 6 deletions' + expect(page).to have_content '4 Files' + + additions_content = page.find('.diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-addition') + .ancestor('.diff-stats-group').text + deletions_content = page.find('.diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-deletion') + .ancestor('.diff-stats-group').text + + expect(additions_content).to eq '15' + expect(deletions_content).to eq '6' position = Gitlab::Diff::Position.new( old_path: ".gitmodules", @@ -141,8 +148,14 @@ describe 'Merge request > User sees versions', :js do end it 'show diff between new and old version' do - expect(page).to have_content '4 changed files' - expect(page).to have_content '15 additions 6 deletions' + additions_content = page.find('.diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-addition') + .ancestor('.diff-stats-group').text + deletions_content = page.find('.diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-deletion') + .ancestor('.diff-stats-group').text + + expect(page).to have_content '4 Files' + expect(additions_content).to eq '15' + expect(deletions_content).to eq '6' end it 'returns to latest version when "Show latest version" button is clicked' do @@ -150,7 +163,7 @@ describe 'Merge request > User sees versions', :js do page.within '.mr-version-dropdown' do expect(page).to have_content 'latest version' end - expect(page).to have_content '8 changed files' + expect(page).to have_content '8 Files' end it_behaves_like 'allows commenting', @@ -176,7 +189,7 @@ describe 'Merge request > User sees versions', :js do find('.btn-default').click click_link 'version 1' end - expect(page).to have_content '0 changed files' + expect(page).to have_content '0 Files' end end @@ -202,7 +215,7 @@ describe 'Merge request > User sees versions', :js do expect(page).to have_content 'version 1' end - expect(page).to have_content '0 changed files' + expect(page).to have_content '0 Files' end end diff --git a/spec/features/merge_requests/user_squashes_merge_request_spec.rb b/spec/features/merge_requests/user_squashes_merge_request_spec.rb index 47f9f10815c..bf9c55cf22c 100644 --- a/spec/features/merge_requests/user_squashes_merge_request_spec.rb +++ b/spec/features/merge_requests/user_squashes_merge_request_spec.rb @@ -14,7 +14,7 @@ describe 'User squashes a merge request', :js do latest_master_commits = project.repository.commits_between(original_head.sha, 'master').map(&:raw) squash_commit = an_object_having_attributes(sha: a_string_matching(/\h{40}/), - message: "Csv\n", + message: a_string_starting_with(project.merge_requests.first.default_squash_commit_message), author_name: user.name, committer_name: user.name) diff --git a/spec/features/profiles/user_edit_profile_spec.rb b/spec/features/profiles/user_edit_profile_spec.rb index f45bcabd196..b43711f6ef6 100644 --- a/spec/features/profiles/user_edit_profile_spec.rb +++ b/spec/features/profiles/user_edit_profile_spec.rb @@ -10,6 +10,7 @@ describe 'User edit profile' do def submit_settings click_button 'Update profile settings' + wait_for_requests if respond_to?(:wait_for_requests) end it 'changes user profile' do @@ -35,6 +36,17 @@ describe 'User edit profile' do expect(page).to have_content('Profile was successfully updated') end + it 'shows an error if the full name contains an emoji', :js do + simulate_input('#user_name', 'Martin 😀') + submit_settings + + page.within('.qa-full-name') do + expect(page).to have_css '.gl-field-error-outline' + expect(find('.gl-field-error')).not_to have_selector('.hidden') + expect(find('.gl-field-error')).to have_content('Using emojis in names seems fun, but please try to set a status message instead') + end + end + context 'user avatar' do before do attach_file(:user_avatar, Rails.root.join('spec', 'fixtures', 'banana_sample.gif')) @@ -61,6 +73,11 @@ describe 'User edit profile' do end context 'user status', :js do + def visit_user + visit user_path(user) + wait_for_requests + end + def select_emoji(emoji_name, is_modal = false) emoji_menu_class = is_modal ? '.js-modal-status-emoji-menu' : '.js-status-emoji-menu' toggle_button = find('.js-toggle-emoji-menu') @@ -71,18 +88,16 @@ describe 'User edit profile' do context 'profile edit form' do it 'shows the user status form' do - visit(profile_path) - expect(page).to have_content('Current status') end it 'adds emoji to user status' do emoji = 'biohazard' - visit(profile_path) select_emoji(emoji) submit_settings - visit user_path(user) + visit_user + within('.cover-status') do expect(page).to have_emoji(emoji) end @@ -90,11 +105,11 @@ describe 'User edit profile' do it 'adds message to user status' do message = 'I have something to say' - visit(profile_path) fill_in 'js-status-message-field', with: message submit_settings - visit user_path(user) + visit_user + within('.cover-status') do expect(page).to have_emoji('speech_balloon') expect(page).to have_content message @@ -104,12 +119,12 @@ describe 'User edit profile' do it 'adds message and emoji to user status' do emoji = 'tanabata_tree' message = 'Playing outside' - visit(profile_path) select_emoji(emoji) fill_in 'js-status-message-field', with: message submit_settings - visit user_path(user) + visit_user + within('.cover-status') do expect(page).to have_emoji(emoji) expect(page).to have_content message @@ -119,7 +134,8 @@ describe 'User edit profile' do it 'clears the user status' do user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread') - visit user_path(user) + visit_user + within('.cover-status') do expect(page).to have_emoji(user_status.emoji) expect(page).to have_content user_status.message @@ -129,15 +145,13 @@ describe 'User edit profile' do click_button 'js-clear-user-status-button' submit_settings - wait_for_requests + visit_user - visit user_path(user) expect(page).not_to have_selector '.cover-status' end it 'displays a default emoji if only message is entered' do message = 'a status without emoji' - visit(profile_path) fill_in 'js-status-message-field', with: message within('.js-toggle-emoji-menu') do @@ -162,6 +176,7 @@ describe 'User edit profile' do page.within "#set-user-status-modal" do click_button 'Set status' end + wait_for_requests end before do @@ -202,7 +217,8 @@ describe 'User edit profile' do select_emoji(emoji, true) set_user_status_in_modal - visit user_path(user) + visit_user + within('.cover-status') do expect(page).to have_emoji(emoji) end @@ -225,7 +241,8 @@ describe 'User edit profile' do find('.js-status-message-field').native.send_keys(message) set_user_status_in_modal - visit user_path(user) + visit_user + within('.cover-status') do expect(page).to have_emoji('speech_balloon') expect(page).to have_content message @@ -240,7 +257,8 @@ describe 'User edit profile' do find('.js-status-message-field').native.send_keys(message) set_user_status_in_modal - visit user_path(user) + visit_user + within('.cover-status') do expect(page).to have_emoji(emoji) expect(page).to have_content message @@ -250,7 +268,9 @@ describe 'User edit profile' do it 'clears the user status with the "X" button' do user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread') - visit user_path(user) + visit_user + wait_for_requests + within('.cover-status') do expect(page).to have_emoji(user_status.emoji) expect(page).to have_content user_status.message @@ -265,14 +285,18 @@ describe 'User edit profile' do find('.js-clear-user-status-button').click set_user_status_in_modal - visit user_path(user) + visit_user + wait_for_requests + expect(page).not_to have_selector '.cover-status' end it 'clears the user status with the "Remove status" button' do user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread') - visit user_path(user) + visit_user + wait_for_requests + within('.cover-status') do expect(page).to have_emoji(user_status.emoji) expect(page).to have_content user_status.message @@ -288,7 +312,8 @@ describe 'User edit profile' do click_button 'Remove status' end - visit user_path(user) + visit_user + expect(page).not_to have_selector '.cover-status' end diff --git a/spec/features/projects/artifacts/user_downloads_artifacts_spec.rb b/spec/features/projects/artifacts/user_downloads_artifacts_spec.rb index 554f0b49052..5cb015e80be 100644 --- a/spec/features/projects/artifacts/user_downloads_artifacts_spec.rb +++ b/spec/features/projects/artifacts/user_downloads_artifacts_spec.rb @@ -7,7 +7,7 @@ describe "User downloads artifacts" do shared_examples "downloading" do it "downloads the zip" do - expect(page.response_headers["Content-Disposition"]).to eq(%Q{attachment; filename="#{job.artifacts_file.filename}"}) + expect(page.response_headers["Content-Disposition"]).to eq(%Q{attachment; filename*=UTF-8''#{job.artifacts_file.filename}; filename="#{job.artifacts_file.filename}"}) expect(page.response_headers['Content-Transfer-Encoding']).to eq("binary") expect(page.response_headers['Content-Type']).to eq("application/zip") expect(page.source.b).to eq(job.artifacts_file.file.read.b) diff --git a/spec/features/projects/blobs/blob_show_spec.rb b/spec/features/projects/blobs/blob_show_spec.rb index e2f9e7e9cc5..3edcc7ac2cd 100644 --- a/spec/features/projects/blobs/blob_show_spec.rb +++ b/spec/features/projects/blobs/blob_show_spec.rb @@ -5,8 +5,8 @@ describe 'File blob', :js do let(:project) { create(:project, :public, :repository) } - def visit_blob(path, anchor: nil, ref: 'master', legacy_render: nil) - visit project_blob_path(project, File.join(ref, path), anchor: anchor, legacy_render: legacy_render) + def visit_blob(path, anchor: nil, ref: 'master') + visit project_blob_path(project, File.join(ref, path), anchor: anchor) wait_for_requests end @@ -171,21 +171,6 @@ describe 'File blob', :js do end end end - - context 'when rendering legacy markdown' do - before do - visit_blob('files/commonmark/file.md', legacy_render: 1) - - wait_for_requests - end - - it 'renders using RedCarpet' do - aggregate_failures do - expect(page).to have_content("sublist") - expect(page).to have_xpath("//ol//li//ul") - end - end - end end context 'Markdown file (stored in LFS)' do diff --git a/spec/features/projects/blobs/edit_spec.rb b/spec/features/projects/blobs/edit_spec.rb index d5b20605860..6e6c299ee2e 100644 --- a/spec/features/projects/blobs/edit_spec.rb +++ b/spec/features/projects/blobs/edit_spec.rb @@ -81,17 +81,6 @@ describe 'Editing file blob', :js do expect(page).to have_content("sublist") expect(page).not_to have_xpath("//ol//li//ul") end - - it 'renders content with RedCarpet when legacy_render is set' do - visit project_edit_blob_path(project, tree_join(branch, readme_file_path), legacy_render: 1) - fill_editor(content: "1. one\\n - sublist\\n") - click_link 'Preview' - wait_for_requests - - # the above generates a sublist list in RedCarpet - expect(page).to have_content("sublist") - expect(page).to have_xpath("//ol//li//ul") - end end end diff --git a/spec/features/projects/clusters/applications_spec.rb b/spec/features/projects/clusters/applications_spec.rb index fab9e035d53..2c8d014c36d 100644 --- a/spec/features/projects/clusters/applications_spec.rb +++ b/spec/features/projects/clusters/applications_spec.rb @@ -48,9 +48,9 @@ describe 'Clusters Applications', :js do it 'they see status transition' do page.within('.js-cluster-application-row-helm') do - # FE sends request and gets the response, then the buttons is "Install" + # FE sends request and gets the response, then the buttons is "Installing" expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true') - expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Install') + expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing') wait_until_helm_created! @@ -118,7 +118,7 @@ describe 'Clusters Applications', :js do page.within('.js-cluster-application-row-cert_manager') do expect(email_form_value).to eq(cluster.user.email) - expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Install') + expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing') page.find('.js-email').set("new_email@example.org") Clusters::Cluster.last.application_cert_manager.make_installing! @@ -153,9 +153,9 @@ describe 'Clusters Applications', :js do it 'they see status transition' do page.within('.js-cluster-application-row-ingress') do - # FE sends request and gets the response, then the buttons is "Install" + # FE sends request and gets the response, then the buttons is "Installing" expect(page).to have_css('.js-cluster-application-install-button[disabled]') - expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Install') + expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing') Clusters::Cluster.last.application_ingress.make_installing! diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 24830b2bd3e..65ce872363f 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -220,7 +220,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do artifact_request = requests.find { |req| req.url.match(%r{artifacts/download}) } - expect(artifact_request.response_headers["Content-Disposition"]).to eq(%Q{attachment; filename="#{job.artifacts_file.filename}"}) + expect(artifact_request.response_headers["Content-Disposition"]).to eq(%Q{attachment; filename*=UTF-8''#{job.artifacts_file.filename}; filename="#{job.artifacts_file.filename}"}) expect(artifact_request.response_headers['Content-Transfer-Encoding']).to eq("binary") expect(artifact_request.response_headers['Content-Type']).to eq("image/gif") expect(artifact_request.body).to eq(job.artifacts_file.file.read.b) diff --git a/spec/features/projects/serverless/functions_spec.rb b/spec/features/projects/serverless/functions_spec.rb index 766c63725b3..aa71669de98 100644 --- a/spec/features/projects/serverless/functions_spec.rb +++ b/spec/features/projects/serverless/functions_spec.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'Functions', :js do + include KubernetesHelpers + let(:project) { create(:project) } let(:user) { create(:user) } @@ -34,11 +38,14 @@ describe 'Functions', :js do end context 'when the user has a cluster and knative installed and visits the serverless page' do - let!(:cluster) { create(:cluster, :project, :provided_by_gcp) } + let(:cluster) { create(:cluster, :project, :provided_by_gcp) } + let(:service) { cluster.platform_kubernetes } let(:knative) { create(:clusters_applications_knative, :installed, cluster: cluster) } let(:project) { knative.cluster.project } before do + stub_kubeclient_knative_services + stub_kubeclient_service_pods visit project_serverless_functions_path(project) end diff --git a/spec/features/projects/settings/pipelines_settings_spec.rb b/spec/features/projects/settings/pipelines_settings_spec.rb index 6f8ec0015ad..4c85abe9971 100644 --- a/spec/features/projects/settings/pipelines_settings_spec.rb +++ b/spec/features/projects/settings/pipelines_settings_spec.rb @@ -98,14 +98,12 @@ describe "Projects > Settings > Pipelines settings" do expect(page).not_to have_content('instance enabled') expect(find_field('project_auto_devops_attributes_enabled')).not_to be_checked check 'Default to Auto DevOps pipeline' - fill_in('project_auto_devops_attributes_domain', with: 'test.com') click_on 'Save changes' end expect(page.status_code).to eq(200) expect(project.auto_devops).to be_present expect(project.auto_devops).to be_enabled - expect(project.auto_devops.domain).to eq('test.com') page.within '#autodevops-settings' do expect(find_field('project_auto_devops_attributes_enabled')).to be_checked @@ -113,29 +111,6 @@ describe "Projects > Settings > Pipelines settings" do end end end - - context 'when there is a cluster with ingress and external_ip' do - before do - cluster = create(:cluster, projects: [project]) - cluster.create_application_ingress!(external_ip: '192.168.1.100') - end - - it 'shows the help text with the nip.io domain as an alternative to custom domain' do - visit project_settings_ci_cd_path(project) - expect(page).to have_content('192.168.1.100.nip.io can be used as an alternative to a custom domain') - end - end - - context 'when there is no ingress' do - before do - create(:cluster, projects: [project]) - end - - it 'alternative to custom domain is not shown' do - visit project_settings_ci_cd_path(project) - expect(page).not_to have_content('can be used as an alternative to a custom domain') - end - end end describe 'runners registration token' do diff --git a/spec/features/projects/settings/user_changes_default_branch_spec.rb b/spec/features/projects/settings/user_changes_default_branch_spec.rb index fcf05e04a5c..7dc18601f50 100644 --- a/spec/features/projects/settings/user_changes_default_branch_spec.rb +++ b/spec/features/projects/settings/user_changes_default_branch_spec.rb @@ -15,6 +15,9 @@ describe 'Projects > Settings > User changes default branch' do let(:project) { create(:project, :repository, namespace: user.namespace) } it 'allows to change the default branch', :js do + # Otherwise, running JS may overwrite our change to project_default_branch + wait_for_requests + select2('fix', from: '#project_default_branch') page.within '#default-branch-settings' do diff --git a/spec/features/projects/wiki/markdown_preview_spec.rb b/spec/features/projects/wiki/markdown_preview_spec.rb index f505023d1d0..3b469fee867 100644 --- a/spec/features/projects/wiki/markdown_preview_spec.rb +++ b/spec/features/projects/wiki/markdown_preview_spec.rb @@ -175,20 +175,6 @@ describe 'Projects > Wiki > User previews markdown changes', :js do expect(page).to have_content("sublist") expect(page).not_to have_xpath("//ol//li//ul") end - - it 'renders content with RedCarpet when legacy_render is set' do - wiki_page = create(:wiki_page, - wiki: project.wiki, - attrs: { title: 'home', content: "Empty content" }) - visit(project_wiki_edit_path(project, wiki_page, legacy_render: 1)) - - fill_in :wiki_content, with: "1. one\n - sublist\n" - click_on "Preview" - - # the above generates a sublist list in RedCarpet - expect(page).to have_content("sublist") - expect(page).to have_xpath("//ol//li//ul") - end end end diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index f7efc3f325c..bc36c6f948f 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -110,16 +110,23 @@ describe 'Project' do it 'shows project topics' do project.update_attribute(:tag_list, 'topic1') + visit path + expect(page).to have_css('.home-panel-topic-list') - expect(page).to have_content('topic1') + expect(page).to have_link('Topic1', href: explore_projects_path(tag: 'topic1')) end it 'shows up to 3 project tags' do project.update_attribute(:tag_list, 'topic1, topic2, topic3, topic4') + visit path + expect(page).to have_css('.home-panel-topic-list') - expect(page).to have_content('topic1, topic2, topic3 + 1 more') + expect(page).to have_link('Topic1', href: explore_projects_path(tag: 'topic1')) + expect(page).to have_link('Topic2', href: explore_projects_path(tag: 'topic2')) + expect(page).to have_link('Topic3', href: explore_projects_path(tag: 'topic3')) + expect(page).to have_content('+ 1 more') end end diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb index 843dbcd5b4d..e23000fa676 100644 --- a/spec/features/security/project/internal_access_spec.rb +++ b/spec/features/security/project/internal_access_spec.rb @@ -452,9 +452,9 @@ describe "Internal Project Access" do it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } - it { is_expected.to be_allowed_for(:reporter).of(project) } - it { is_expected.to be_allowed_for(:guest).of(project) } - it { is_expected.to be_allowed_for(:user) } + it { is_expected.to be_denied_for(:reporter).of(project) } + it { is_expected.to be_denied_for(:guest).of(project) } + it { is_expected.to be_denied_for(:user) } it { is_expected.to be_denied_for(:external) } it { is_expected.to be_denied_for(:visitor) } end diff --git a/spec/features/security/project/private_access_spec.rb b/spec/features/security/project/private_access_spec.rb index cf0837c1e67..f380bc122a7 100644 --- a/spec/features/security/project/private_access_spec.rb +++ b/spec/features/security/project/private_access_spec.rb @@ -485,7 +485,7 @@ describe "Private Project Access" do it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } - it { is_expected.to be_allowed_for(:reporter).of(project) } + it { is_expected.to be_denied_for(:reporter).of(project) } it { is_expected.to be_denied_for(:guest).of(project) } it { is_expected.to be_denied_for(:user) } it { is_expected.to be_denied_for(:external) } diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb index 7e1b735fd3d..57d56371719 100644 --- a/spec/features/security/project/public_access_spec.rb +++ b/spec/features/security/project/public_access_spec.rb @@ -272,11 +272,11 @@ describe "Public Project Access" do it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:maintainer).of(project) } it { is_expected.to be_allowed_for(:developer).of(project) } - it { is_expected.to be_allowed_for(:reporter).of(project) } - it { is_expected.to be_allowed_for(:guest).of(project) } - it { is_expected.to be_allowed_for(:user) } - it { is_expected.to be_allowed_for(:external) } - it { is_expected.to be_allowed_for(:visitor) } + it { is_expected.to be_denied_for(:reporter).of(project) } + it { is_expected.to be_denied_for(:guest).of(project) } + it { is_expected.to be_denied_for(:user) } + it { is_expected.to be_denied_for(:external) } + it { is_expected.to be_denied_for(:visitor) } end describe "GET /:project_path/environments" do diff --git a/spec/features/snippets/show_spec.rb b/spec/features/snippets/show_spec.rb index 367a479f62a..74fdfcf492e 100644 --- a/spec/features/snippets/show_spec.rb +++ b/spec/features/snippets/show_spec.rb @@ -79,35 +79,6 @@ describe 'Snippet', :js do expect(page).not_to have_xpath("//ol//li//ul") end end - - context 'when rendering legacy markdown' do - before do - visit snippet_path(snippet, legacy_render: 1) - - wait_for_requests - end - - it 'renders using RedCarpet' do - expect(page).to have_content("sublist") - expect(page).to have_xpath("//ol//li//ul") - end - end - - context 'with cached CommonMark html' do - let(:snippet) { create(:personal_snippet, :public, file_name: file_name, content: content, cached_markdown_version: CacheMarkdownField::CACHE_COMMONMARK_VERSION) } - - it 'renders correctly' do - expect(page).not_to have_xpath("//ol//li//ul") - end - end - - context 'with cached Redcarpet html' do - let(:snippet) { create(:personal_snippet, :public, file_name: file_name, content: content, cached_markdown_version: CacheMarkdownField::CACHE_REDCARPET_VERSION) } - - it 'renders correctly' do - expect(page).to have_xpath("//ol//li//ul") - end - end end context 'switching to the simple viewer' do diff --git a/spec/features/task_lists_spec.rb b/spec/features/task_lists_spec.rb index 9c9127980a1..6fe840dccf6 100644 --- a/spec/features/task_lists_spec.rb +++ b/spec/features/task_lists_spec.rb @@ -36,19 +36,6 @@ describe 'Task Lists' do MARKDOWN end - let(:nested_tasks_markdown_redcarpet) do - <<-EOT.strip_heredoc - - [ ] Task a - - [x] Task a.1 - - [ ] Task a.2 - - [ ] Task b - - 1. [ ] Task 1 - 1. [ ] Task 1.1 - 1. [x] Task 1.2 - EOT - end - let(:nested_tasks_markdown) do <<-EOT.strip_heredoc - [ ] Task a @@ -153,59 +140,6 @@ describe 'Task Lists' do expect(page).to have_content("1 of 1 task completed") end end - - shared_examples 'shared nested tasks' do - before do - allow(Banzai::Filter::MarkdownFilter).to receive(:engine).and_return('Redcarpet') - visit_issue(project, issue) - end - it 'renders' do - expect(page).to have_selector('ul.task-list', count: 2) - expect(page).to have_selector('li.task-list-item', count: 7) - expect(page).to have_selector('ul input[checked]', count: 1) - expect(page).to have_selector('ol input[checked]', count: 1) - end - - it 'solves tasks' do - expect(page).to have_content("2 of 7 tasks completed") - - page.find('li.task-list-item', text: 'Task b').find('input').click - page.find('li.task-list-item ul li.task-list-item', text: 'Task a.2').find('input').click - page.find('li.task-list-item ol li.task-list-item', text: 'Task 1.1').find('input').click - - expect(page).to have_content("5 of 7 tasks completed") - - visit_issue(project, issue) # reload to see new system notes - - expect(page).to have_content('marked the task Task b as complete') - expect(page).to have_content('marked the task Task a.2 as complete') - expect(page).to have_content('marked the task Task 1.1 as complete') - end - end - - describe 'nested tasks', :js do - context 'with Redcarpet' do - let(:issue) { create(:issue, description: nested_tasks_markdown_redcarpet, author: user, project: project) } - - before do - allow_any_instance_of(Banzai::Filter::MarkdownFilter).to receive(:engine).and_return('Redcarpet') - visit_issue(project, issue) - end - - it_behaves_like 'shared nested tasks' - end - - context 'with CommonMark' do - let(:issue) { create(:issue, description: nested_tasks_markdown, author: user, project: project) } - - before do - allow_any_instance_of(Banzai::Filter::MarkdownFilter).to receive(:engine).and_return('CommonMark') - visit_issue(project, issue) - end - - it_behaves_like 'shared nested tasks' - end - end end describe 'for Notes' do diff --git a/spec/features/users/overview_spec.rb b/spec/features/users/overview_spec.rb index 3708f0ee477..3db9ae7a951 100644 --- a/spec/features/users/overview_spec.rb +++ b/spec/features/users/overview_spec.rb @@ -34,7 +34,7 @@ describe 'Overview tab on a user profile', :js do it 'does not show any entries in the list of activities' do page.within('.activities-block') do expect(page).to have_selector('.loading', visible: false) - expect(page).to have_content('No activities found') + expect(page).to have_content('Join or create a group to start contributing by commenting on issues or submitting merge requests!') expect(page).not_to have_selector('.event-item') end end @@ -96,7 +96,7 @@ describe 'Overview tab on a user profile', :js do it 'it shows an empty project list with an info message' do page.within('.projects-block') do expect(page).to have_selector('.loading', visible: false) - expect(page).to have_content('This user doesn\'t have any personal projects') + expect(page).to have_content('You haven\'t created any personal projects.') expect(page).not_to have_selector('.project-row') end end |