diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-13 21:08:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-13 21:08:35 +0300 |
commit | e62d575077d6265497d7bbc7a31548ab15908a9e (patch) | |
tree | 5e10d28367cfe2652aacadd2ea0cdc8094c503cd /spec | |
parent | f62886ebffeda00b6972f1644097a6b9f5016453 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
59 files changed, 422 insertions, 139 deletions
diff --git a/spec/features/discussion_comments/issue_spec.rb b/spec/features/discussion_comments/issue_spec.rb index 90be3f0760d..b270a4c7600 100644 --- a/spec/features/discussion_comments/issue_spec.rb +++ b/spec/features/discussion_comments/issue_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'Thread Comments Issue', :js, feature_category: :source_code_management do + include ContentEditorHelpers + let(:user) { create(:user) } let(:project) { create(:project) } let(:issue) { create(:issue, project: project) } @@ -12,6 +14,7 @@ RSpec.describe 'Thread Comments Issue', :js, feature_category: :source_code_mana sign_in(user) visit project_issue_path(project, issue) + close_rich_text_promo_popover_if_present end it_behaves_like 'thread comments for issue, epic and merge request', 'issue' diff --git a/spec/features/groups/milestone_spec.rb b/spec/features/groups/milestone_spec.rb index bb7cc3db452..d870471d646 100644 --- a/spec/features/groups/milestone_spec.rb +++ b/spec/features/groups/milestone_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'Group milestones', feature_category: :groups_and_projects do + include ContentEditorHelpers + let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project_empty_repo, group: group) } let_it_be(:user) { create(:group_member, :maintainer, user: create(:user), group: group).user } @@ -18,6 +20,7 @@ RSpec.describe 'Group milestones', feature_category: :groups_and_projects do context 'create a milestone', :js do before do visit new_group_milestone_path(group) + close_rich_text_promo_popover_if_present end it 'renders description preview' do @@ -66,6 +69,7 @@ RSpec.describe 'Group milestones', feature_category: :groups_and_projects do context 'when no milestones' do it 'renders no milestones text' do visit group_milestones_path(group) + close_rich_text_promo_popover_if_present expect(page).to have_content('Use milestones to track issues and merge requests') end end @@ -95,6 +99,7 @@ RSpec.describe 'Group milestones', feature_category: :groups_and_projects do before do visit group_milestones_path(group) + close_rich_text_promo_popover_if_present end it 'counts milestones correctly' do @@ -170,6 +175,7 @@ RSpec.describe 'Group milestones', feature_category: :groups_and_projects do before do visit group_milestone_path(group, milestone) + close_rich_text_promo_popover_if_present end it 'renders the issues tab' do diff --git a/spec/features/issuables/markdown_references/jira_spec.rb b/spec/features/issuables/markdown_references/jira_spec.rb index 887bc7d0c87..e072231c6e9 100644 --- a/spec/features/issuables/markdown_references/jira_spec.rb +++ b/spec/features/issuables/markdown_references/jira_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe "Jira", :js, feature_category: :team_planning do + include ContentEditorHelpers + let(:user) { create(:user) } let(:actual_project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, target_project: actual_project, source_project: actual_project) } @@ -24,6 +26,7 @@ RSpec.describe "Jira", :js, feature_category: :team_planning do sign_in(user) visit(merge_request_path(merge_request)) + close_rich_text_promo_popover_if_present build_note end diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index 3dc291718ea..5f7a4f26a98 100644 --- a/spec/features/issues/form_spec.rb +++ b/spec/features/issues/form_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do include ActionView::Helpers::JavaScriptHelper include ListboxHelpers + include ContentEditorHelpers let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } @@ -36,6 +37,7 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do describe 'new issue' do before do visit new_project_issue_path(project) + close_rich_text_promo_popover_if_present end describe 'shorten users API pagination limit' do diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index a1f2275df6e..47e9575da54 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe 'GFM autocomplete', :js, feature_category: :team_planning do include CookieHelper include Features::AutocompleteHelpers + include ContentEditorHelpers let_it_be(:user) { create(:user, name: '💃speciąl someone💃', username: 'someone.special') } let_it_be(:user2) { create(:user, name: 'Marge Simpson', username: 'msimpson') } @@ -32,6 +33,7 @@ RSpec.describe 'GFM autocomplete', :js, feature_category: :team_planning do before do sign_in(user) visit new_project_issue_path(project) + close_rich_text_promo_popover_if_present wait_for_requests end @@ -50,6 +52,7 @@ RSpec.describe 'GFM autocomplete', :js, feature_category: :team_planning do sign_in(user) set_cookie('new-actions-popover-viewed', 'true') visit project_issue_path(project, issue_to_edit) + close_rich_text_promo_popover_if_present wait_for_requests end @@ -85,6 +88,7 @@ RSpec.describe 'GFM autocomplete', :js, feature_category: :team_planning do before do sign_in(user) visit project_issue_path(project, issue) + close_rich_text_promo_popover_if_present wait_for_requests end diff --git a/spec/features/issues/markdown_toolbar_spec.rb b/spec/features/issues/markdown_toolbar_spec.rb index 5cabaf16960..03c95c275b5 100644 --- a/spec/features/issues/markdown_toolbar_spec.rb +++ b/spec/features/issues/markdown_toolbar_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'Issue markdown toolbar', :js, feature_category: :team_planning do + include ContentEditorHelpers + let_it_be(:project) { create(:project, :public) } let_it_be(:issue) { create(:issue, project: project) } let_it_be(:user) { create(:user) } @@ -11,6 +13,7 @@ RSpec.describe 'Issue markdown toolbar', :js, feature_category: :team_planning d sign_in(user) visit project_issue_path(project, issue) + close_rich_text_promo_popover_if_present end it "doesn't include first new line when adding bold" do diff --git a/spec/features/issues/note_polling_spec.rb b/spec/features/issues/note_polling_spec.rb index 0fa4aba9a11..23f9347d726 100644 --- a/spec/features/issues/note_polling_spec.rb +++ b/spec/features/issues/note_polling_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'Issue notes polling', :js, feature_category: :team_planning do include NoteInteractionHelpers + include ContentEditorHelpers let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project) } @@ -11,6 +12,7 @@ RSpec.describe 'Issue notes polling', :js, feature_category: :team_planning do describe 'creates' do before do visit project_issue_path(project, issue) + close_rich_text_promo_popover_if_present end it 'displays the new comment' do @@ -31,6 +33,7 @@ RSpec.describe 'Issue notes polling', :js, feature_category: :team_planning do before do sign_in(user) visit project_issue_path(project, issue) + close_rich_text_promo_popover_if_present end it 'displays the updated content' do diff --git a/spec/features/issues/notes_on_issues_spec.rb b/spec/features/issues/notes_on_issues_spec.rb index 8d6262efa53..62855c7467f 100644 --- a/spec/features/issues/notes_on_issues_spec.rb +++ b/spec/features/issues/notes_on_issues_spec.rb @@ -3,9 +3,12 @@ require 'spec_helper' RSpec.describe 'Create notes on issues', :js, feature_category: :team_planning do + include ContentEditorHelpers + let(:user) { create(:user) } def submit_comment(text) + close_rich_text_promo_popover_if_present fill_in 'note[note]', with: text click_button 'Comment' wait_for_requests diff --git a/spec/features/issues/user_comments_on_issue_spec.rb b/spec/features/issues/user_comments_on_issue_spec.rb index d954a1d15ff..f18992325d8 100644 --- a/spec/features/issues/user_comments_on_issue_spec.rb +++ b/spec/features/issues/user_comments_on_issue_spec.rb @@ -5,6 +5,7 @@ require "spec_helper" RSpec.describe "User comments on issue", :js, feature_category: :team_planning do include Features::AutocompleteHelpers include Features::NotesHelpers + include ContentEditorHelpers let_it_be(:project) { create(:project, :public) } let_it_be(:issue) { create(:issue, project: project) } @@ -15,6 +16,7 @@ RSpec.describe "User comments on issue", :js, feature_category: :team_planning d sign_in(user) visit(project_issue_path(project, issue)) + close_rich_text_promo_popover_if_present end context "when adding comments" do diff --git a/spec/features/issues/user_creates_issue_spec.rb b/spec/features/issues/user_creates_issue_spec.rb index 57183b2e8d9..76b07d903bc 100644 --- a/spec/features/issues/user_creates_issue_spec.rb +++ b/spec/features/issues/user_creates_issue_spec.rb @@ -4,6 +4,7 @@ require "spec_helper" RSpec.describe "User creates issue", feature_category: :team_planning do include DropzoneHelper + include ContentEditorHelpers let_it_be(:project) { create(:project_empty_repo, :public) } let_it_be(:user) { create(:user) } @@ -41,6 +42,7 @@ RSpec.describe "User creates issue", feature_category: :team_planning do sign_in(user) visit(new_project_issue_path(project)) + close_rich_text_promo_popover_if_present end context 'available metadata' do diff --git a/spec/features/issues/user_edits_issue_spec.rb b/spec/features/issues/user_edits_issue_spec.rb index 47c532c3963..0938f9c7d12 100644 --- a/spec/features/issues/user_edits_issue_spec.rb +++ b/spec/features/issues/user_edits_issue_spec.rb @@ -4,6 +4,7 @@ require "spec_helper" RSpec.describe "Issues > User edits issue", :js, feature_category: :team_planning do include CookieHelper + include ContentEditorHelpers let_it_be(:project) { create(:project_empty_repo, :public) } let_it_be(:project_with_milestones) { create(:project_empty_repo, :public) } @@ -27,6 +28,7 @@ RSpec.describe "Issues > User edits issue", :js, feature_category: :team_plannin before do stub_licensed_features(multiple_issue_assignees: false) visit edit_project_issue_path(project, issue) + close_rich_text_promo_popover_if_present end it_behaves_like 'edits content using the content editor' diff --git a/spec/features/issues/user_interacts_with_awards_spec.rb b/spec/features/issues/user_interacts_with_awards_spec.rb index 539e429534e..e1099ba242e 100644 --- a/spec/features/issues/user_interacts_with_awards_spec.rb +++ b/spec/features/issues/user_interacts_with_awards_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'User interacts with awards', feature_category: :team_planning do include MobileHelpers + include ContentEditorHelpers let(:user) { create(:user) } @@ -16,6 +17,7 @@ RSpec.describe 'User interacts with awards', feature_category: :team_planning do sign_in(user) visit(project_issue_path(project, issue)) + close_rich_text_promo_popover_if_present end it 'toggles the thumbsup award emoji', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/27959' do diff --git a/spec/features/issues/user_sees_sidebar_updates_in_realtime_spec.rb b/spec/features/issues/user_sees_sidebar_updates_in_realtime_spec.rb index 91b18454af5..ef448c06a3f 100644 --- a/spec/features/issues/user_sees_sidebar_updates_in_realtime_spec.rb +++ b/spec/features/issues/user_sees_sidebar_updates_in_realtime_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'Issues > Real-time sidebar', :js, :with_license, feature_category: :team_planning do + include ContentEditorHelpers + let_it_be(:project) { create(:project, :public) } let_it_be(:issue) { create(:issue, project: project) } let_it_be(:user) { create(:user) } @@ -20,6 +22,7 @@ RSpec.describe 'Issues > Real-time sidebar', :js, :with_license, feature_categor using_session :other_session do visit project_issue_path(project, issue) + close_rich_text_promo_popover_if_present expect(page.find('.assignee')).to have_content 'None' end @@ -43,6 +46,7 @@ RSpec.describe 'Issues > Real-time sidebar', :js, :with_license, feature_categor using_session :other_session do visit project_issue_path(project, issue) wait_for_requests + close_rich_text_promo_popover_if_present expect(labels_value).to have_content('None') end @@ -50,6 +54,7 @@ RSpec.describe 'Issues > Real-time sidebar', :js, :with_license, feature_categor visit project_issue_path(project, issue) wait_for_requests + close_rich_text_promo_popover_if_present expect(labels_value).to have_content('None') page.within(labels_widget) do diff --git a/spec/features/issues/user_uses_quick_actions_spec.rb b/spec/features/issues/user_uses_quick_actions_spec.rb index e85a521e242..dc149ccc698 100644 --- a/spec/features/issues/user_uses_quick_actions_spec.rb +++ b/spec/features/issues/user_uses_quick_actions_spec.rb @@ -9,6 +9,7 @@ require 'spec_helper' # for each existing quick action unless they test something not tested by existing tests. RSpec.describe 'Issues > User uses quick actions', :js, feature_category: :team_planning do include Features::NotesHelpers + include ContentEditorHelpers context "issuable common quick actions" do let(:new_url_opts) { {} } @@ -34,6 +35,7 @@ RSpec.describe 'Issues > User uses quick actions', :js, feature_category: :team_ sign_in(user) visit project_issue_path(project, issue) wait_for_all_requests + close_rich_text_promo_popover_if_present end after do diff --git a/spec/features/labels_hierarchy_spec.rb b/spec/features/labels_hierarchy_spec.rb index e8f40a1ceab..eb79d6e64f3 100644 --- a/spec/features/labels_hierarchy_spec.rb +++ b/spec/features/labels_hierarchy_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'Labels Hierarchy', :js, feature_category: :team_planning do include FilteredSearchHelpers + include ContentEditorHelpers let!(:user) { create(:user) } let!(:grandparent) { create(:group) } @@ -165,6 +166,7 @@ RSpec.describe 'Labels Hierarchy', :js, feature_category: :team_planning do context 'when creating new issuable' do before do visit new_project_issue_path(project_1) + close_rich_text_promo_popover_if_present end it 'is able to assign ancestor group labels' do @@ -202,6 +204,7 @@ RSpec.describe 'Labels Hierarchy', :js, feature_category: :team_planning do context 'when creating new issuable' do before do visit new_project_issue_path(project_1) + close_rich_text_promo_popover_if_present end it 'is able to assign ancestor group labels' do @@ -233,6 +236,7 @@ RSpec.describe 'Labels Hierarchy', :js, feature_category: :team_planning do project_1.add_developer(user) visit project_issue_path(project_1, issue) + close_rich_text_promo_popover_if_present end it_behaves_like 'assigning labels from sidebar' 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 e3989a8a192..38291573256 100644 --- a/spec/features/merge_request/user_accepts_merge_request_spec.rb +++ b/spec/features/merge_request/user_accepts_merge_request_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'User accepts a merge request', :js, :sidekiq_might_not_need_inline, feature_category: :code_review_workflow do + include ContentEditorHelpers + let(:merge_request) { create(:merge_request, :simple, source_project: project) } let(:project) { create(:project, :public, :repository) } let(:user) { create(:user) } @@ -15,6 +17,7 @@ RSpec.describe 'User accepts a merge request', :js, :sidekiq_might_not_need_inli context 'presents merged merge request content' do it 'when merge method is set to merge commit' do visit(merge_request_path(merge_request)) + close_rich_text_promo_popover_if_present click_merge_button @@ -30,6 +33,7 @@ RSpec.describe 'User accepts a merge request', :js, :sidekiq_might_not_need_inli merge_request = create(:merge_request, :rebased, source_project: project) visit(merge_request_path(merge_request)) + close_rich_text_promo_popover_if_present click_merge_button @@ -40,6 +44,7 @@ RSpec.describe 'User accepts a merge request', :js, :sidekiq_might_not_need_inli merge_request = create(:merge_request, :rebased, source_project: project, squash: true) visit(merge_request_path(merge_request)) + close_rich_text_promo_popover_if_present click_merge_button @@ -51,6 +56,7 @@ RSpec.describe 'User accepts a merge request', :js, :sidekiq_might_not_need_inli context 'with removing the source branch' do before do visit(merge_request_path(merge_request)) + close_rich_text_promo_popover_if_present end it 'accepts a merge request' do @@ -69,6 +75,7 @@ RSpec.describe 'User accepts a merge request', :js, :sidekiq_might_not_need_inli context 'without removing the source branch' do before do visit(merge_request_path(merge_request)) + close_rich_text_promo_popover_if_present end it 'accepts a merge request' do @@ -86,6 +93,7 @@ RSpec.describe 'User accepts a merge request', :js, :sidekiq_might_not_need_inli context 'when a URL has an anchor' do before do visit(merge_request_path(merge_request, anchor: 'note_123')) + close_rich_text_promo_popover_if_present end it 'accepts a merge request' do @@ -106,6 +114,7 @@ RSpec.describe 'User accepts a merge request', :js, :sidekiq_might_not_need_inli merge_request.mark_as_mergeable visit(merge_request_path(merge_request)) + close_rich_text_promo_popover_if_present end it 'accepts a merge request' do diff --git a/spec/features/merge_request/user_edits_merge_request_spec.rb b/spec/features/merge_request/user_edits_merge_request_spec.rb index 584a17ae33d..b1cff72c374 100644 --- a/spec/features/merge_request/user_edits_merge_request_spec.rb +++ b/spec/features/merge_request/user_edits_merge_request_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'User edits a merge request', :js, feature_category: :code_review_workflow do + include ContentEditorHelpers + let(:project) { create(:project, :repository) } let(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let(:user) { create(:user) } @@ -85,6 +87,8 @@ RSpec.describe 'User edits a merge request', :js, feature_category: :code_review describe 'changing target branch' do it 'allows user to change target branch' do + close_rich_text_promo_popover_if_present + expect(page).to have_content('From master into feature') first('.js-target-branch').click diff --git a/spec/features/merge_request/user_edits_mr_spec.rb b/spec/features/merge_request/user_edits_mr_spec.rb index 76588832ee1..ab7183775b9 100644 --- a/spec/features/merge_request/user_edits_mr_spec.rb +++ b/spec/features/merge_request/user_edits_mr_spec.rb @@ -184,7 +184,11 @@ RSpec.describe 'Merge request > User edits MR', feature_category: :code_review_w it 'allows to unselect "Remove source branch"', :js do expect(merge_request.merge_params['force_remove_source_branch']).to be_truthy - visit edit_project_merge_request_path(target_project, merge_request) + begin + visit edit_project_merge_request_path(target_project, merge_request) + rescue Selenium::WebDriver::Error::UnexpectedAlertOpenError + end + uncheck 'Delete source branch when merge request is accepted' click_button 'Save changes' diff --git a/spec/features/merge_request/user_merges_immediately_spec.rb b/spec/features/merge_request/user_merges_immediately_spec.rb index 71af2045bab..5fe9947d0df 100644 --- a/spec/features/merge_request/user_merges_immediately_spec.rb +++ b/spec/features/merge_request/user_merges_immediately_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'Merge requests > User merges immediately', :js, feature_category: :code_review_workflow do + include ContentEditorHelpers + let(:project) { create(:project, :public, :repository) } let(:user) { project.creator } let!(:merge_request) do @@ -31,6 +33,7 @@ RSpec.describe 'Merge requests > User merges immediately', :js, feature_category project.add_maintainer(user) sign_in(user) visit project_merge_request_path(project, merge_request) + close_rich_text_promo_popover_if_present end it 'enables merge immediately' do diff --git a/spec/features/merge_request/user_merges_merge_request_spec.rb b/spec/features/merge_request/user_merges_merge_request_spec.rb index 6ffb33603d5..402405e1fb6 100644 --- a/spec/features/merge_request/user_merges_merge_request_spec.rb +++ b/spec/features/merge_request/user_merges_merge_request_spec.rb @@ -3,6 +3,8 @@ require "spec_helper" RSpec.describe "User merges a merge request", :js, feature_category: :code_review_workflow do + include ContentEditorHelpers + let(:user) { project.first_owner } before do @@ -29,6 +31,7 @@ RSpec.describe "User merges a merge request", :js, feature_category: :code_revie create(:merge_request, source_project: project, source_branch: 'branch-1') visit(merge_request_path(merge_request)) + close_rich_text_promo_popover_if_present expect(page).to have_css('.js-merge-counter', text: '2') diff --git a/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb index 78814e36cfe..62404077cea 100644 --- a/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb +++ b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'Merge request > User merges only if pipeline succeeds', :js, feature_category: :code_review_workflow do + include ContentEditorHelpers + let(:merge_request) { create(:merge_request_with_diffs) } let(:project) { merge_request.target_project } @@ -114,6 +116,7 @@ RSpec.describe 'Merge request > User merges only if pipeline succeeds', :js, fea it 'allows MR to be merged immediately' do visit project_merge_request_path(project, merge_request) + close_rich_text_promo_popover_if_present wait_for_requests diff --git a/spec/features/merge_request/user_posts_notes_spec.rb b/spec/features/merge_request/user_posts_notes_spec.rb index 146e4d1265a..0278d2af08f 100644 --- a/spec/features/merge_request/user_posts_notes_spec.rb +++ b/spec/features/merge_request/user_posts_notes_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'Merge request > User posts notes', :js, feature_category: :code_review_workflow do include NoteInteractionHelpers + include ContentEditorHelpers let_it_be(:project) { create(:project, :repository) } @@ -21,6 +22,7 @@ RSpec.describe 'Merge request > User posts notes', :js, feature_category: :code_ sign_in(user) visit project_merge_request_path(project, merge_request) + close_rich_text_promo_popover_if_present end subject { page } diff --git a/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb b/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb index 4bdef20304a..e8ffca43aa2 100644 --- a/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb +++ b/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'Merge request > User resolves diff notes and threads', :js, feature_category: :code_review_workflow do + include ContentEditorHelpers + let(:project) { create(:project, :public, :repository) } let(:user) { project.creator } let(:guest) { create(:user) } @@ -541,5 +543,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js, feat # Wait for MR widget to load wait_for_requests + + close_rich_text_promo_popover_if_present end end diff --git a/spec/features/merge_request/user_reverts_merge_request_spec.rb b/spec/features/merge_request/user_reverts_merge_request_spec.rb index 8c782056aa4..68adc4d47b6 100644 --- a/spec/features/merge_request/user_reverts_merge_request_spec.rb +++ b/spec/features/merge_request/user_reverts_merge_request_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'User reverts a merge request', :js, feature_category: :code_review_workflow do + include ContentEditorHelpers + let(:merge_request) { create(:merge_request, :simple, source_project: project) } let(:project) { create(:project, :public, :repository) } let(:user) { create(:user) } @@ -13,6 +15,7 @@ RSpec.describe 'User reverts a merge request', :js, feature_category: :code_revi sign_in(user) visit(merge_request_path(merge_request)) + close_rich_text_promo_popover_if_present page.within('.mr-state-widget') do click_button 'Merge' diff --git a/spec/features/merge_request/user_sees_diff_spec.rb b/spec/features/merge_request/user_sees_diff_spec.rb index 3fb3ef12fcc..57f378a86b6 100644 --- a/spec/features/merge_request/user_sees_diff_spec.rb +++ b/spec/features/merge_request/user_sees_diff_spec.rb @@ -77,8 +77,9 @@ RSpec.describe 'Merge request > User sees diff', :js, feature_category: :code_re sign_in(author_user) visit diffs_project_merge_request_path(project, merge_request) - # Throws `Capybara::Poltergeist::InvalidSelector` if we try to use `#hash` syntax - expect(page).to have_selector(".js-edit-blob", visible: false) + first(".js-diff-more-actions").click + + expect(page).to have_selector(".js-edit-blob") end end diff --git a/spec/features/merge_request/user_sees_discussions_spec.rb b/spec/features/merge_request/user_sees_discussions_spec.rb index 3ca5ac23ddb..3482d468bc1 100644 --- a/spec/features/merge_request/user_sees_discussions_spec.rb +++ b/spec/features/merge_request/user_sees_discussions_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'Merge request > User sees threads', :js, feature_category: :code_review_workflow do + include ContentEditorHelpers + let(:project) { create(:project, :public, :repository) } let(:user) { project.creator } let(:merge_request) { create(:merge_request, source_project: project) } @@ -29,6 +31,7 @@ RSpec.describe 'Merge request > User sees threads', :js, feature_category: :code before do visit project_merge_request_path(project, merge_request) + close_rich_text_promo_popover_if_present end context 'active threads' do @@ -71,6 +74,7 @@ RSpec.describe 'Merge request > User sees threads', :js, feature_category: :code before do visit project_merge_request_path(project, merge_request) + close_rich_text_promo_popover_if_present end # TODO: https://gitlab.com/gitlab-org/gitlab-foss/issues/48034 diff --git a/spec/features/merge_request/user_sees_merge_widget_spec.rb b/spec/features/merge_request/user_sees_merge_widget_spec.rb index 33694c056a0..3cac24838a3 100644 --- a/spec/features/merge_request/user_sees_merge_widget_spec.rb +++ b/spec/features/merge_request/user_sees_merge_widget_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: include ProjectForksHelper include TestReportsHelper include ReactiveCachingHelpers + include ContentEditorHelpers let(:project) { create(:project, :repository) } let(:project_only_mwps) { create(:project, :repository, only_allow_merge_if_pipeline_succeeds: true) } @@ -57,6 +58,7 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: merge_request.update!(head_pipeline: pipeline) deployment.update!(status: :success) visit project_merge_request_path(project, merge_request) + close_rich_text_promo_popover_if_present end it 'shows environments link' do @@ -130,6 +132,7 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: create(:ci_build, :pending, pipeline: pipeline) visit project_merge_request_path(project, merge_request) + close_rich_text_promo_popover_if_present end it 'has merge button that shows modal when pipeline does not succeeded' do @@ -403,6 +406,7 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: before do allow_any_instance_of(Repository).to receive(:merge).and_return(false) visit project_merge_request_path(project, merge_request) + close_rich_text_promo_popover_if_present end it 'updates the MR widget', :sidekiq_might_not_need_inline do @@ -424,6 +428,7 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: sign_in(user2) merge_request.update!(source_project: forked_project) visit project_merge_request_path(project, merge_request) + close_rich_text_promo_popover_if_present end it 'user can merge into the target project', :sidekiq_inline do @@ -461,6 +466,7 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: allow_any_instance_of(MergeRequest).to receive(:merge_ongoing?).and_return(true) visit project_merge_request_path(project, merge_request) + close_rich_text_promo_popover_if_present wait_for_requests diff --git a/spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb b/spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb index 92bedc47718..ad7ed1ceada 100644 --- a/spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb +++ b/spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'Merge request > User sees notes from forked project', :js, feature_category: :code_review_workflow do include ProjectForksHelper + include ContentEditorHelpers let(:project) { create(:project, :public, :repository) } let(:user) { project.creator } @@ -29,6 +30,7 @@ RSpec.describe 'Merge request > User sees notes from forked project', :js, featu it 'user can reply to the comment', :sidekiq_might_not_need_inline do visit project_merge_request_path(project, merge_request) + close_rich_text_promo_popover_if_present expect(page).to have_content('A commit comment') diff --git a/spec/features/merge_request/user_squashes_merge_request_spec.rb b/spec/features/merge_request/user_squashes_merge_request_spec.rb index 5fd0f353e56..200f310d929 100644 --- a/spec/features/merge_request/user_squashes_merge_request_spec.rb +++ b/spec/features/merge_request/user_squashes_merge_request_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'User squashes a merge request', :js, feature_category: :code_review_workflow do + include ContentEditorHelpers + let(:user) { create(:user) } let(:project) { create(:project, :repository) } let(:source_branch) { 'csv' } @@ -12,6 +14,8 @@ RSpec.describe 'User squashes a merge request', :js, feature_category: :code_rev shared_examples 'squash' do it 'squashes the commits into a single commit, and adds a merge commit', :sidekiq_might_not_need_inline do + close_rich_text_promo_popover_if_present + expect(page).to have_content('Merged') latest_master_commits = project.repository.commits_between(original_head.sha, 'master').map(&:raw) @@ -37,12 +41,16 @@ RSpec.describe 'User squashes a merge request', :js, feature_category: :code_rev shared_examples 'no squash' do it 'accepts the merge request without squashing', :sidekiq_might_not_need_inline do + close_rich_text_promo_popover_if_present + expect(page).to have_content('Merged') expect(project.repository).to be_merged_to_root_ref(source_branch) end end def accept_mr + close_rich_text_promo_popover_if_present + expect(page).to have_button('Merge') uncheck 'Delete source branch' unless protected_source_branch diff --git a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb index 6152d9f8259..1a814aeb89d 100644 --- a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb +++ b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe 'User comments on a diff', :js, feature_category: :code_review_workflow do include MergeRequestDiffHelpers include RepoHelpers + include ContentEditorHelpers def expect_suggestion_has_content(element, expected_changing_content, expected_suggested_content) changing_content = element.all(:css, '.line_holder.old').map { |el| el.text(normalize_ws: true) } @@ -35,6 +36,7 @@ RSpec.describe 'User comments on a diff', :js, feature_category: :code_review_wo context 'single suggestion note' do it 'hides suggestion popover' do click_diff_line(find_by_scrolling("[id='#{sample_compare.changes[1][:line_code]}']")) + close_rich_text_promo_popover_if_present expect(page).to have_selector('.diff-suggest-popover') diff --git a/spec/features/merge_request/user_views_open_merge_request_spec.rb b/spec/features/merge_request/user_views_open_merge_request_spec.rb index 1a9d40ae926..cd0ea639d4d 100644 --- a/spec/features/merge_request/user_views_open_merge_request_spec.rb +++ b/spec/features/merge_request/user_views_open_merge_request_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'User views an open merge request', feature_category: :code_review_workflow do + include ContentEditorHelpers + let(:merge_request) do create(:merge_request, source_project: project, target_project: project, description: '# Description header') end @@ -53,6 +55,7 @@ RSpec.describe 'User views an open merge request', feature_category: :code_revie sign_in(user) visit(edit_project_merge_request_path(project, merge_request)) + close_rich_text_promo_popover_if_present end it 'renders empty description preview' do diff --git a/spec/features/projects/issuable_templates_spec.rb b/spec/features/projects/issuable_templates_spec.rb index bb43d019701..4221fa26e00 100644 --- a/spec/features/projects/issuable_templates_spec.rb +++ b/spec/features/projects/issuable_templates_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe 'issuable templates', :js, feature_category: :groups_and_projects do include ProjectForksHelper include CookieHelper + include ContentEditorHelpers let(:user) { create(:user) } let(:project) { create(:project, :public, :repository) } @@ -36,6 +37,7 @@ RSpec.describe 'issuable templates', :js, feature_category: :groups_and_projects message: 'added issue template', branch_name: 'master') visit project_issue_path project, issue + close_rich_text_promo_popover_if_present page.find('.js-issuable-edit').click fill_in :'issuable-title', with: 'test issue title' end @@ -79,6 +81,7 @@ RSpec.describe 'issuable templates', :js, feature_category: :groups_and_projects message: 'added issue template', branch_name: 'master') visit project_issue_path project, issue + close_rich_text_promo_popover_if_present page.find('.js-issuable-edit').click fill_in :'issuable-title', with: 'test issue title' fill_in :'issue-description', with: prior_description @@ -108,6 +111,7 @@ RSpec.describe 'issuable templates', :js, feature_category: :groups_and_projects it 'does not overwrite autosaved description' do visit new_project_issue_path project wait_for_requests + close_rich_text_promo_popover_if_present assert_template # default template is loaded the first time @@ -141,6 +145,7 @@ RSpec.describe 'issuable templates', :js, feature_category: :groups_and_projects message: 'added merge request bug template', branch_name: 'master') visit edit_project_merge_request_path project, merge_request + close_rich_text_promo_popover_if_present fill_in :'merge_request[title]', with: 'test merge request title' end @@ -200,6 +205,7 @@ RSpec.describe 'issuable templates', :js, feature_category: :groups_and_projects message: 'added merge request template', branch_name: 'master') visit edit_project_merge_request_path project, merge_request + close_rich_text_promo_popover_if_present fill_in :'merge_request[title]', with: 'test merge request title' end diff --git a/spec/features/user_sees_revert_modal_spec.rb b/spec/features/user_sees_revert_modal_spec.rb index 2b0ff2cdf01..9ee3fe846a6 100644 --- a/spec/features/user_sees_revert_modal_spec.rb +++ b/spec/features/user_sees_revert_modal_spec.rb @@ -4,6 +4,8 @@ require 'spec_helper' RSpec.describe 'Merge request > User sees revert modal', :js, :sidekiq_might_not_need_inline, feature_category: :code_review_workflow do + include ContentEditorHelpers + let(:project) { create(:project, :public, :repository) } let(:user) { project.creator } let(:merge_request) { create(:merge_request, source_project: project) } @@ -22,6 +24,8 @@ RSpec.describe 'Merge request > User sees revert modal', :js, :sidekiq_might_not stub_feature_flags(unbatch_graphql_queries: false) sign_in(user) visit(project_merge_request_path(project, merge_request)) + close_rich_text_promo_popover_if_present + page.within('.mr-state-widget') do click_button 'Merge' end @@ -36,6 +40,7 @@ RSpec.describe 'Merge request > User sees revert modal', :js, :sidekiq_might_not context 'with page reload validates js correctly loaded' do before do visit(merge_request_path(merge_request)) + close_rich_text_promo_popover_if_present end it_behaves_like 'showing the revert modal' diff --git a/spec/frontend/diffs/components/diff_file_spec.js b/spec/frontend/diffs/components/diff_file_spec.js index 9b9a1a84b1d..db6cde883f3 100644 --- a/spec/frontend/diffs/components/diff_file_spec.js +++ b/spec/frontend/diffs/components/diff_file_spec.js @@ -546,24 +546,6 @@ describe('DiffFile', () => { }); }); - it('loads collapsed file on mounted when single file mode is enabled', async () => { - const file = { - ...getReadableFile(), - load_collapsed_diff_url: '/diff_for_path', - highlighted_diff_lines: [], - parallel_diff_lines: [], - viewer: { name: 'collapsed', automaticallyCollapsed: true }, - }; - - axiosMock.onGet(file.load_collapsed_diff_url).reply(HTTP_STATUS_OK, getReadableFile()); - - ({ wrapper, store } = createComponent({ file, props: { viewDiffsFileByFile: true } })); - - await nextTick(); - - expect(findLoader(wrapper).exists()).toBe(true); - }); - describe('merge conflicts', () => { it('does not render conflict alert', () => { const file = { diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js index 963346a34b6..bbe748b8e1f 100644 --- a/spec/frontend/diffs/store/actions_spec.js +++ b/spec/frontend/diffs/store/actions_spec.js @@ -365,7 +365,7 @@ describe('DiffsStoreActions', () => { { type: types.SET_RETRIEVING_BATCHES, payload: false }, { type: types.SET_BATCH_LOADING_STATE, payload: 'error' }, ], - [{ type: 'startRenderDiffsQueue' }, { type: 'startRenderDiffsQueue' }], + [], ); }); }); @@ -664,41 +664,6 @@ describe('DiffsStoreActions', () => { }); }); - describe('startRenderDiffsQueue', () => { - it('should set all files to RENDER_FILE', () => { - const state = { - diffFiles: [ - { - id: 1, - renderIt: false, - viewer: { - automaticallyCollapsed: false, - }, - }, - { - id: 2, - renderIt: false, - viewer: { - automaticallyCollapsed: false, - }, - }, - ], - }; - - const pseudoCommit = (commitType, file) => { - expect(commitType).toBe(types.RENDER_FILE); - Object.assign(file, { - renderIt: true, - }); - }; - - diffActions.startRenderDiffsQueue({ state, commit: pseudoCommit }); - - expect(state.diffFiles[0].renderIt).toBe(true); - expect(state.diffFiles[1].renderIt).toBe(true); - }); - }); - describe('setInlineDiffViewType', () => { it('should set diff view type to inline and also set the cookie properly', async () => { await testAction( @@ -1286,12 +1251,11 @@ describe('DiffsStoreActions', () => { $emit = jest.spyOn(eventHub, '$emit'); }); - it('renders and expands file for the given discussion id', () => { + it('expands the file for the given discussion id', () => { const localState = state({ collapsed: true, renderIt: false }); diffActions.renderFileForDiscussionId({ rootState, state: localState, commit }, '123'); - expect(commit).toHaveBeenCalledWith('RENDER_FILE', localState.diffFiles[0]); expect($emit).toHaveBeenCalledTimes(1); expect(commonUtils.scrollToElement).toHaveBeenCalledTimes(1); }); @@ -1378,18 +1342,6 @@ describe('DiffsStoreActions', () => { }); }); - describe('setRenderIt', () => { - it('commits RENDER_FILE', () => { - return testAction( - diffActions.setRenderIt, - 'file', - {}, - [{ type: types.RENDER_FILE, payload: 'file' }], - [], - ); - }); - }); - describe('receiveFullDiffError', () => { it('updates state with the file that did not load', () => { return testAction( @@ -1514,7 +1466,7 @@ describe('DiffsStoreActions', () => { payload: { filePath: testFilePath, lines: [preparedLine, preparedLine] }, }, ], - [{ type: 'startRenderDiffsQueue' }], + [], ); }, ); diff --git a/spec/frontend/diffs/store/mutations_spec.js b/spec/frontend/diffs/store/mutations_spec.js index 4f9534ed5db..274cb40dac8 100644 --- a/spec/frontend/diffs/store/mutations_spec.js +++ b/spec/frontend/diffs/store/mutations_spec.js @@ -105,7 +105,6 @@ describe('DiffsStoreMutations', () => { mutations[types.SET_DIFF_DATA_BATCH](state, diffMock); - expect(state.diffFiles[0].renderIt).toEqual(true); expect(state.diffFiles[0].collapsed).toEqual(false); expect(state.treeEntries[mockFile.file_path].diffLoaded).toBe(true); }); diff --git a/spec/frontend/diffs/store/utils_spec.js b/spec/frontend/diffs/store/utils_spec.js index 888df06d6b9..117ed56e347 100644 --- a/spec/frontend/diffs/store/utils_spec.js +++ b/spec/frontend/diffs/store/utils_spec.js @@ -437,7 +437,7 @@ describe('DiffsStoreUtils', () => { }); }); - it('sets the renderIt and collapsed attribute on files', () => { + it('sets the collapsed attribute on files', () => { const checkLine = preparedDiff.diff_files[0][INLINE_DIFF_LINES_KEY][0]; expect(checkLine.discussions.length).toBe(0); @@ -448,7 +448,6 @@ describe('DiffsStoreUtils', () => { expect(firstChar).not.toBe('+'); expect(firstChar).not.toBe('-'); - expect(preparedDiff.diff_files[0].renderIt).toBe(true); expect(preparedDiff.diff_files[0].collapsed).toBe(false); }); @@ -529,8 +528,7 @@ describe('DiffsStoreUtils', () => { preparedDiffFiles = utils.prepareDiffData({ diff: mock, meta: true }); }); - it('sets the renderIt and collapsed attribute on files', () => { - expect(preparedDiffFiles[0].renderIt).toBe(true); + it('sets the collapsed attribute on files', () => { expect(preparedDiffFiles[0].collapsed).toBeUndefined(); }); diff --git a/spec/frontend/notes/components/comment_form_spec.js b/spec/frontend/notes/components/comment_form_spec.js index 703f17cc77a..9fc688fd8a6 100644 --- a/spec/frontend/notes/components/comment_form_spec.js +++ b/spec/frontend/notes/components/comment_form_spec.js @@ -121,6 +121,15 @@ describe('issue_comment_form component', () => { provide: { glFeatures: features, }, + mocks: { + $apollo: { + queries: { + currentUser: { + loading: false, + }, + }, + }, + }, }), ); }; diff --git a/spec/frontend/notes/components/note_form_spec.js b/spec/frontend/notes/components/note_form_spec.js index 0a68225d411..fb81d5ce6d1 100644 --- a/spec/frontend/notes/components/note_form_spec.js +++ b/spec/frontend/notes/components/note_form_spec.js @@ -26,6 +26,15 @@ describe('issue_note_form component', () => { provide: { glFeatures: provide, }, + mocks: { + $apollo: { + queries: { + currentUser: { + loading: false, + }, + }, + }, + }, }); }; diff --git a/spec/frontend/pages/shared/wikis/components/wiki_form_spec.js b/spec/frontend/pages/shared/wikis/components/wiki_form_spec.js index 0b3def2a69e..3b2533b1a27 100644 --- a/spec/frontend/pages/shared/wikis/components/wiki_form_spec.js +++ b/spec/frontend/pages/shared/wikis/components/wiki_form_spec.js @@ -95,6 +95,15 @@ describe('WikiForm', () => { GlFormInput, GlFormGroup, }, + mocks: { + $apollo: { + queries: { + currentUser: { + loading: false, + }, + }, + }, + }, }), ); } diff --git a/spec/frontend/pipeline_wizard/components/editor_spec.js b/spec/frontend/pipeline_wizard/components/editor_spec.js index 6d7d4363189..2284c875f58 100644 --- a/spec/frontend/pipeline_wizard/components/editor_spec.js +++ b/spec/frontend/pipeline_wizard/components/editor_spec.js @@ -1,42 +1,58 @@ import { mount } from '@vue/test-utils'; import { Document } from 'yaml'; import YamlEditor from '~/pipeline_wizard/components/editor.vue'; +import SourceEditor from '~/editor/source_editor'; describe('Pages Yaml Editor wrapper', () => { let wrapper; + const defaultDoc = new Document({ foo: 'bar' }); + const defaultOptions = { - propsData: { doc: new Document({ foo: 'bar' }), filename: 'foo.yml' }, + propsData: { doc: defaultDoc, filename: 'foo.yml' }, + }; + + const getLatestValue = () => { + const latest = wrapper.emitted('update:yaml').pop(); + return latest[0]; }; describe('mount hook', () => { beforeEach(() => { + jest.spyOn(SourceEditor.prototype, 'createInstance'); + wrapper = mount(YamlEditor, defaultOptions); }); - it('editor is mounted', () => { - expect(wrapper.vm.editor).not.toBeUndefined(); - expect(wrapper.find('.gl-source-editor').exists()).toBe(true); + it('creates a source editor instance', () => { + expect(SourceEditor.prototype.createInstance).toHaveBeenCalledWith({ + el: wrapper.element, + blobPath: 'foo.yml', + language: 'yaml', + }); + }); + + it('editor is mounted in the wrapper', () => { + expect(wrapper.find('.gl-source-editor.monaco-editor').exists()).toBe(true); + }); + + it("causes the editor's value to be set to the stringified document", () => { + expect(getLatestValue()).toEqual(defaultDoc.toString()); }); }); describe('watchers', () => { + beforeEach(() => { + wrapper = mount(YamlEditor, defaultOptions); + }); + describe('doc', () => { const doc = new Document({ baz: ['bar'] }); - beforeEach(() => { - wrapper = mount(YamlEditor, defaultOptions); - }); - - it("causes the editor's value to be set to the stringified document", async () => { - await wrapper.setProps({ doc }); - expect(wrapper.vm.editor.getValue()).toEqual(doc.toString()); - }); - it('emits an update:yaml event with the yaml representation of doc', async () => { await wrapper.setProps({ doc }); - const changeEvents = wrapper.emitted('update:yaml'); - expect(changeEvents[2]).toEqual([doc.toString()]); + + expect(getLatestValue()).toEqual(doc.toString()); }); it('does not cause the touch event to be emitted', () => { diff --git a/spec/frontend/vue_shared/components/markdown/editor_mode_switcher_spec.js b/spec/frontend/vue_shared/components/markdown/editor_mode_switcher_spec.js index f8d5faf317c..712e78458c6 100644 --- a/spec/frontend/vue_shared/components/markdown/editor_mode_switcher_spec.js +++ b/spec/frontend/vue_shared/components/markdown/editor_mode_switcher_spec.js @@ -1,25 +1,47 @@ -import { GlButton } from '@gitlab/ui'; -import { shallowMount } from '@vue/test-utils'; +import { nextTick } from 'vue'; +import { GlButton, GlLink, GlPopover } from '@gitlab/ui'; +import { mount } from '@vue/test-utils'; import EditorModeSwitcher from '~/vue_shared/components/markdown/editor_mode_switcher.vue'; +import { counter } from '~/vue_shared/components/markdown/utils'; +import UserCalloutDismisser from '~/vue_shared/components/user_callout_dismisser.vue'; +import { stubComponent } from 'helpers/stub_component'; +import { useLocalStorageSpy } from 'helpers/local_storage_helper'; + +jest.mock('~/vue_shared/components/markdown/utils', () => ({ + counter: jest.fn().mockReturnValue(0), +})); describe('vue_shared/component/markdown/editor_mode_switcher', () => { let wrapper; + useLocalStorageSpy(); - const createComponent = ({ value } = {}) => { - wrapper = shallowMount(EditorModeSwitcher, { + const createComponent = ({ + value, + userCalloutDismisserSlotProps = { dismiss: jest.fn() }, + } = {}) => { + wrapper = mount(EditorModeSwitcher, { propsData: { value, }, + stubs: { + UserCalloutDismisser: stubComponent(UserCalloutDismisser, { + render() { + return this.$scopedSlots.default(userCalloutDismisserSlotProps); + }, + }), + }, }); }; const findSwitcherButton = () => wrapper.findComponent(GlButton); + const findUserCalloutDismisser = () => wrapper.findComponent(UserCalloutDismisser); + const findCalloutPopover = () => wrapper.findComponent(GlPopover); describe.each` - modeText | value | buttonText - ${'Rich text'} | ${'richText'} | ${'Switch to plain text editing'} - ${'Markdown'} | ${'markdown'} | ${'Switch to rich text editing'} - `('when $modeText', ({ modeText, value, buttonText }) => { + value | buttonText + ${'richText'} | ${'Switch to plain text editing'} + ${'markdown'} | ${'Switch to rich text editing'} + `('when $value', ({ value, buttonText }) => { beforeEach(() => { createComponent({ value }); }); @@ -28,10 +50,66 @@ describe('vue_shared/component/markdown/editor_mode_switcher', () => { expect(findSwitcherButton().text()).toEqual(buttonText); }); - it('emits event on click', () => { - findSwitcherButton(modeText).vm.$emit('click'); + it('emits event on click', async () => { + await nextTick(); + findSwitcherButton().vm.$emit('click'); + + expect(wrapper.emitted().switch).toEqual([[false]]); + }); + }); + + describe('rich text editor callout', () => { + let dismiss; + + beforeEach(() => { + dismiss = jest.fn(); + createComponent({ value: 'markdown', userCalloutDismisserSlotProps: { dismiss } }); + }); + + it('does not skip the user_callout_dismisser query', () => { + expect(findUserCalloutDismisser().props()).toMatchObject({ + skipQuery: false, + featureName: 'rich_text_editor', + }); + }); + + it('mounts new rich text editor popover', () => { + expect(findCalloutPopover().props()).toMatchObject({ + showCloseButton: '', + triggers: 'manual', + target: 'switch-to-rich-text-editor', + }); + }); + + it('dismisses the callout and emits "switch" event when popover close button is clicked', async () => { + await findCalloutPopover().findComponent(GlLink).vm.$emit('click'); + + expect(wrapper.emitted().switch).toEqual([[true]]); + expect(dismiss).toHaveBeenCalled(); + }); + + it('dismisses the callout when action button is clicked', () => { + findSwitcherButton().vm.$emit('click'); + + expect(dismiss).toHaveBeenCalled(); + }); + + it('does not show the callout if rich text is already enabled', async () => { + await wrapper.setProps({ value: 'richText' }); + + expect(findCalloutPopover().props()).toMatchObject({ + show: false, + }); + }); + + it('does not show the callout if already displayed once on the page', () => { + counter.mockReturnValue(1); + + createComponent({ value: 'markdown' }); - expect(wrapper.emitted().input).toEqual([[]]); + expect(findCalloutPopover().props()).toMatchObject({ + show: false, + }); }); }); }); diff --git a/spec/frontend/vue_shared/components/markdown/field_spec.js b/spec/frontend/vue_shared/components/markdown/field_spec.js index 37d18455bf2..4ade8f28fd0 100644 --- a/spec/frontend/vue_shared/components/markdown/field_spec.js +++ b/spec/frontend/vue_shared/components/markdown/field_spec.js @@ -67,6 +67,15 @@ describe('Markdown field component', () => { showContentEditorSwitcher, supportsQuickActions: true, }, + mocks: { + $apollo: { + queries: { + currentUser: { + loading: false, + }, + }, + }, + }, }, ); } diff --git a/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js b/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js index a9e8e9408f8..8411e22f6c7 100644 --- a/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js +++ b/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js @@ -64,6 +64,15 @@ describe('vue_shared/component/markdown/markdown_editor', () => { BubbleMenu: stubComponent(BubbleMenu), ...stubs, }, + mocks: { + $apollo: { + queries: { + currentUser: { + loading: false, + }, + }, + }, + }, }); }; @@ -439,8 +448,6 @@ describe('vue_shared/component/markdown/markdown_editor', () => { describe('when contentEditor is disabled', () => { it('resets the editingMode to markdownField', () => { - localStorage.setItem('gl-markdown-editor-mode', 'contentEditor'); - buildWrapper({ propsData: { autosaveKey: 'issue/1234', enableContentEditor: false } }); expect(wrapper.vm.editingMode).toBe(EDITING_MODE_MARKDOWN_FIELD); diff --git a/spec/frontend/vue_shared/components/markdown/toolbar_spec.js b/spec/frontend/vue_shared/components/markdown/toolbar_spec.js index 28dc6fcde74..5bf11ff2b26 100644 --- a/spec/frontend/vue_shared/components/markdown/toolbar_spec.js +++ b/spec/frontend/vue_shared/components/markdown/toolbar_spec.js @@ -1,13 +1,27 @@ import { mount } from '@vue/test-utils'; import Toolbar from '~/vue_shared/components/markdown/toolbar.vue'; import EditorModeSwitcher from '~/vue_shared/components/markdown/editor_mode_switcher.vue'; +import { updateText } from '~/lib/utils/text_markdown'; +import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; + +jest.mock('~/lib/utils/text_markdown'); describe('toolbar', () => { let wrapper; - const createWrapper = (props = {}) => { + const createWrapper = (props = {}, attachTo = document.body) => { wrapper = mount(Toolbar, { + attachTo, propsData: { markdownDocsPath: '', ...props }, + mocks: { + $apollo: { + queries: { + currentUser: { + loading: false, + }, + }, + }, + }, }); }; @@ -47,15 +61,49 @@ describe('toolbar', () => { describe('with content editor switcher', () => { beforeEach(() => { - createWrapper({ - showContentEditorSwitcher: true, - }); + setHTMLFixture( + '<div class="md-area"><textarea>some value</textarea><div id="root"></div></div>', + ); + createWrapper( + { + showContentEditorSwitcher: true, + }, + '#root', + ); + }); + + afterEach(() => { + resetHTMLFixture(); }); it('re-emits event from switcher', () => { - wrapper.findComponent(EditorModeSwitcher).vm.$emit('input', 'richText'); + wrapper.findComponent(EditorModeSwitcher).vm.$emit('switch'); expect(wrapper.emitted('enableContentEditor')).toEqual([[]]); + expect(updateText).not.toHaveBeenCalled(); + }); + + it('does not insert a template text if textarea has some value', () => { + wrapper.findComponent(EditorModeSwitcher).vm.$emit('switch', true); + + expect(updateText).not.toHaveBeenCalled(); + }); + + it('inserts a "getting started with rich text" template when switched for the first time', () => { + document.querySelector('textarea').value = ''; + + wrapper.findComponent(EditorModeSwitcher).vm.$emit('switch', true); + + expect(updateText).toHaveBeenCalledWith( + expect.objectContaining({ + tag: `### Rich text editor + +Try out **styling** _your_ content right here or read the [direction](https://about.gitlab.com/direction/plan/knowledge/content_editor/).`, + textArea: document.querySelector('textarea'), + cursorOffset: 0, + wrap: false, + }), + ); }); }); }); diff --git a/spec/frontend/vue_shared/issuable/show/components/issuable_header_spec.js b/spec/frontend/vue_shared/issuable/show/components/issuable_header_spec.js index fa38ab8d44d..d2b7b2e89c8 100644 --- a/spec/frontend/vue_shared/issuable/show/components/issuable_header_spec.js +++ b/spec/frontend/vue_shared/issuable/show/components/issuable_header_spec.js @@ -1,13 +1,16 @@ import { GlButton, GlBadge, GlIcon, GlAvatarLabeled, GlAvatarLink } from '@gitlab/ui'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; +import { TYPE_ISSUE, WORKSPACE_PROJECT } from '~/issues/constants'; +import ConfidentialityBadge from '~/vue_shared/components/confidentiality_badge.vue'; import IssuableHeader from '~/vue_shared/issuable/show/components/issuable_header.vue'; - import { mockIssuableShowProps, mockIssuable } from '../mock_data'; const issuableHeaderProps = { ...mockIssuable, ...mockIssuableShowProps, + issuableType: TYPE_ISSUE, + workspaceType: WORKSPACE_PROJECT, }; describe('IssuableHeader', () => { @@ -53,6 +56,14 @@ describe('IssuableHeader', () => { setHTMLFixture('<button class="js-toggle-right-sidebar-button">Collapse sidebar</button>'); }); + it('emits a "toggle" event', () => { + createComponent(); + + findButton().vm.$emit('click'); + + expect(wrapper.emitted('toggle')).toEqual([[]]); + }); + it('dispatches `click` event on sidebar toggle button', () => { createComponent(); const toggleSidebarButtonEl = document.querySelector('.js-toggle-right-sidebar-button'); @@ -94,14 +105,12 @@ describe('IssuableHeader', () => { }); it('renders confidential icon when issuable is confidential', () => { - createComponent({ - confidential: true, - }); + createComponent({ confidential: true }); - const confidentialEl = wrapper.findByTestId('confidential'); - - expect(confidentialEl.exists()).toBe(true); - expect(confidentialEl.findComponent(GlIcon).props('name')).toBe('eye-slash'); + expect(wrapper.findComponent(ConfidentialityBadge).props()).toEqual({ + issuableType: 'issue', + workspaceType: 'project', + }); }); it('renders issuable author avatar', () => { diff --git a/spec/frontend_integration/content_editor/content_editor_integration_spec.js b/spec/frontend_integration/content_editor/content_editor_integration_spec.js index 6bafe609995..8419c7aae63 100644 --- a/spec/frontend_integration/content_editor/content_editor_integration_spec.js +++ b/spec/frontend_integration/content_editor/content_editor_integration_spec.js @@ -22,6 +22,15 @@ describe('content_editor', () => { listeners: { ...listeners, }, + mocks: { + $apollo: { + queries: { + currentUser: { + loading: false, + }, + }, + }, + }, }); }; diff --git a/spec/helpers/admin/application_settings/settings_helper_spec.rb b/spec/helpers/admin/application_settings/settings_helper_spec.rb index efffc224eb2..b008f52c0eb 100644 --- a/spec/helpers/admin/application_settings/settings_helper_spec.rb +++ b/spec/helpers/admin/application_settings/settings_helper_spec.rb @@ -33,6 +33,12 @@ RSpec.describe Admin::ApplicationSettings::SettingsHelper do end describe 'Code Suggestions for Self-Managed instances', feature_category: :code_suggestions do + describe '#code_suggestions_description' do + subject { helper.code_suggestions_description } + + it { is_expected.to include 'https://docs.gitlab.com/ee/user/project/repository/code_suggestions.html' } + end + describe '#code_suggestions_token_explanation' do subject { helper.code_suggestions_token_explanation } diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 11f177b8f02..1c02b4754fa 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -685,14 +685,6 @@ RSpec.describe Namespace, feature_category: :groups_and_projects do it_behaves_like 'makes recursive queries' end - - context 'when feature flag :use_traversal_ids_for_descendants_scopes is disabled' do - before do - stub_feature_flags(use_traversal_ids_for_descendants_scopes: false) - end - - it_behaves_like 'makes recursive queries' - end end describe '.self_and_descendant_ids' do @@ -709,14 +701,6 @@ RSpec.describe Namespace, feature_category: :groups_and_projects do it_behaves_like 'makes recursive queries' end - - context 'when feature flag :use_traversal_ids_for_descendants_scopes is disabled' do - before do - stub_feature_flags(use_traversal_ids_for_descendants_scopes: false) - end - - it_behaves_like 'makes recursive queries' - end end end diff --git a/spec/support/helpers/content_editor_helpers.rb b/spec/support/helpers/content_editor_helpers.rb index a3ecafbbec6..a6cc2560d0b 100644 --- a/spec/support/helpers/content_editor_helpers.rb +++ b/spec/support/helpers/content_editor_helpers.rb @@ -1,6 +1,14 @@ # frozen_string_literal: true module ContentEditorHelpers + def close_rich_text_promo_popover_if_present + return unless page.has_css?("[data-testid='rich-text-promo-popover']") + + page.within("[data-testid='rich-text-promo-popover']") do + click_button "Close" + end + end + def switch_to_content_editor click_button("Switch to rich text editing") end diff --git a/spec/support/shared_contexts/merge_request_create_shared_context.rb b/spec/support/shared_contexts/merge_request_create_shared_context.rb index fc9a3767365..bf8eeeb7ab6 100644 --- a/spec/support/shared_contexts/merge_request_create_shared_context.rb +++ b/spec/support/shared_contexts/merge_request_create_shared_context.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true RSpec.shared_context 'merge request create context' do + include ContentEditorHelpers + let(:user) { create(:user) } let(:user2) { create(:user) } let(:target_project) { create(:project, :public, :repository) } @@ -23,5 +25,7 @@ RSpec.shared_context 'merge request create context' do source_branch: 'fix', target_branch: 'master' }) + + close_rich_text_promo_popover_if_present end end diff --git a/spec/support/shared_contexts/merge_request_edit_shared_context.rb b/spec/support/shared_contexts/merge_request_edit_shared_context.rb index f0e89b0c5f9..8fe0174b13e 100644 --- a/spec/support/shared_contexts/merge_request_edit_shared_context.rb +++ b/spec/support/shared_contexts/merge_request_edit_shared_context.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true RSpec.shared_context 'merge request edit context' do + include ContentEditorHelpers + let(:user) { create(:user) } let(:user2) { create(:user) } let!(:milestone) { create(:milestone, project: target_project) } @@ -25,5 +27,6 @@ RSpec.shared_context 'merge request edit context' do sign_in(user) visit edit_project_merge_request_path(target_project, merge_request) + close_rich_text_promo_popover_if_present end end diff --git a/spec/support/shared_examples/features/discussion_comments_shared_example.rb b/spec/support/shared_examples/features/discussion_comments_shared_example.rb index ba520d0c609..430a8ac39d7 100644 --- a/spec/support/shared_examples/features/discussion_comments_shared_example.rb +++ b/spec/support/shared_examples/features/discussion_comments_shared_example.rb @@ -150,6 +150,8 @@ RSpec.shared_examples 'thread comments for commit and snippet' do |resource_name end RSpec.shared_examples 'thread comments for issue, epic and merge request' do |resource_name| + include ContentEditorHelpers + let(:form_selector) { '.js-main-target-form' } let(:dropdown_selector) { "#{form_selector} .comment-type-dropdown" } let(:toggle_selector) { "#{dropdown_selector} .gl-new-dropdown-toggle" } @@ -159,6 +161,10 @@ RSpec.shared_examples 'thread comments for issue, epic and merge request' do |re let(:comments_selector) { '.timeline > .note.timeline-entry:not(.being-posted)' } let(:comment) { 'My comment' } + before do + close_rich_text_promo_popover_if_present + end + it 'clicking "Comment" will post a comment' do expect(page).to have_selector toggle_selector diff --git a/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb b/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb index 14e53dc8655..f802404518b 100644 --- a/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb +++ b/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb @@ -125,7 +125,11 @@ RSpec.shared_examples 'an editable merge request' do it 'allows to unselect "Remove source branch"', :js do expect(merge_request.merge_params['force_remove_source_branch']).to be_truthy - visit edit_project_merge_request_path(target_project, merge_request) + begin + visit edit_project_merge_request_path(target_project, merge_request) + rescue Selenium::WebDriver::Error::UnexpectedAlertOpenError + end + uncheck 'Delete source branch when merge request is accepted' click_button 'Save changes' diff --git a/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb index ed885d7a226..c3df89c8002 100644 --- a/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb @@ -6,6 +6,7 @@ RSpec.shared_examples 'User creates wiki page' do include WikiHelpers + include ContentEditorHelpers before do sign_in(user) @@ -18,6 +19,7 @@ RSpec.shared_examples 'User creates wiki page' do wait_for_svg_to_be_loaded(example) click_link "Create your first page" + close_rich_text_promo_popover_if_present end it 'shows all available formats in the dropdown' do @@ -190,6 +192,7 @@ RSpec.shared_examples 'User creates wiki page' do context "via the `new wiki page` page", :js do it "creates a page with a single word" do click_link("New page") + close_rich_text_promo_popover_if_present page.within(".wiki-form") do fill_in(:wiki_title, with: "foo") @@ -208,6 +211,7 @@ RSpec.shared_examples 'User creates wiki page' do it "creates a page with spaces in the name", :js do click_link("New page") + close_rich_text_promo_popover_if_present page.within(".wiki-form") do fill_in(:wiki_title, with: "Spaces in the name") @@ -226,6 +230,7 @@ RSpec.shared_examples 'User creates wiki page' do it "creates a page with hyphens in the name", :js do click_link("New page") + close_rich_text_promo_popover_if_present page.within(".wiki-form") do fill_in(:wiki_title, with: "hyphens-in-the-name") @@ -249,6 +254,7 @@ RSpec.shared_examples 'User creates wiki page' do context 'when a server side validation error is returned' do it "still displays edit form", :js do click_link("New page") + close_rich_text_promo_popover_if_present page.within(".wiki-form") do fill_in(:wiki_title, with: "home") @@ -266,6 +272,7 @@ RSpec.shared_examples 'User creates wiki page' do it "shows the emoji autocompletion dropdown", :js do click_link("New page") + close_rich_text_promo_popover_if_present page.within(".wiki-form") do find("#wiki_content").native.send_keys("") diff --git a/spec/support/shared_examples/features/wiki/user_previews_wiki_changes_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_previews_wiki_changes_shared_examples.rb index ca68df9a89b..827c875494a 100644 --- a/spec/support/shared_examples/features/wiki/user_previews_wiki_changes_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_previews_wiki_changes_shared_examples.rb @@ -5,6 +5,8 @@ # user RSpec.shared_examples 'User previews wiki changes' do + include ContentEditorHelpers + let(:wiki_page) { build(:wiki_page, wiki: wiki) } before do @@ -74,6 +76,7 @@ RSpec.shared_examples 'User previews wiki changes' do before do wiki_page.create # rubocop:disable Rails/SaveBang visit wiki_page_path(wiki, wiki_page, action: :edit) + close_rich_text_promo_popover_if_present end it_behaves_like 'relative links' do diff --git a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb index 91cacaf9209..d06f04db1ce 100644 --- a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb @@ -6,6 +6,8 @@ RSpec.shared_examples 'User updates wiki page' do include WikiHelpers + include ContentEditorHelpers + let(:diagramsnet_url) { 'https://embed.diagrams.net' } before do @@ -21,6 +23,7 @@ RSpec.shared_examples 'User updates wiki page' do wait_for_svg_to_be_loaded(example) click_link "Create your first page" + close_rich_text_promo_popover_if_present end it 'redirects back to the home edit page' do @@ -67,6 +70,7 @@ RSpec.shared_examples 'User updates wiki page' do visit(wiki_path(wiki)) click_link('Edit') + close_rich_text_promo_popover_if_present end it 'updates a page', :js do @@ -126,10 +130,6 @@ RSpec.shared_examples 'User updates wiki page' do expect(page).to have_content('Updated Wiki Content') end - it 'focuses on the content field', :js do - expect(page).to have_selector '.note-textarea:focus' - end - it 'cancels editing of a page' do page.within(:css, '.wiki-form .form-actions') do click_on('Cancel') @@ -164,6 +164,7 @@ RSpec.shared_examples 'User updates wiki page' do before do visit wiki_page_path(wiki, wiki_page, action: :edit) + close_rich_text_promo_popover_if_present end it 'moves the page to the root folder', :js do @@ -234,6 +235,7 @@ RSpec.shared_examples 'User updates wiki page' do stub_application_setting(wiki_page_max_content_bytes: 10) visit wiki_page_path(wiki_page.wiki, wiki_page, action: :edit) + close_rich_text_promo_popover_if_present end it 'allows changing the title if the content does not change', :js do diff --git a/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb index 767caffd417..3ee7725305e 100644 --- a/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb @@ -6,6 +6,7 @@ RSpec.shared_examples 'User views a wiki page' do include WikiHelpers + include ContentEditorHelpers let(:path) { 'image.png' } let(:wiki_page) do @@ -269,6 +270,7 @@ RSpec.shared_examples 'User views a wiki page' do wait_for_svg_to_be_loaded click_link "Create your first page" + close_rich_text_promo_popover_if_present expect(page).to have_content('Create New Page') end diff --git a/spec/support/shared_examples/quick_actions/issuable/close_quick_action_shared_examples.rb b/spec/support/shared_examples/quick_actions/issuable/close_quick_action_shared_examples.rb index 7cbaf40721a..4b27f1f2520 100644 --- a/spec/support/shared_examples/quick_actions/issuable/close_quick_action_shared_examples.rb +++ b/spec/support/shared_examples/quick_actions/issuable/close_quick_action_shared_examples.rb @@ -2,6 +2,7 @@ RSpec.shared_examples 'close quick action' do |issuable_type| include Features::NotesHelpers + include ContentEditorHelpers before do project.add_maintainer(maintainer) @@ -76,6 +77,7 @@ RSpec.shared_examples 'close quick action' do |issuable_type| context "preview of note on #{issuable_type}", :js do it 'explains close quick action' do visit public_send("project_#{issuable_type}_path", project, issuable) + close_rich_text_promo_popover_if_present preview_note("this is done, close\n/close") do expect(page).not_to have_content '/close' |