diff options
Diffstat (limited to 'spec')
24 files changed, 176 insertions, 508 deletions
diff --git a/spec/features/ide/user_opens_merge_request_spec.rb b/spec/features/ide/user_opens_merge_request_spec.rb index dc280133a20..0074b4b1eb0 100644 --- a/spec/features/ide/user_opens_merge_request_spec.rb +++ b/spec/features/ide/user_opens_merge_request_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' RSpec.describe 'IDE merge request', :js, feature_category: :web_ide do - include CookieHelper - let(:merge_request) { create(:merge_request, :simple, source_project: project) } let(:project) { create(:project, :public, :repository) } let(:user) { project.first_owner } @@ -14,8 +12,6 @@ RSpec.describe 'IDE merge request', :js, feature_category: :web_ide do sign_in(user) - set_cookie('new-actions-popover-viewed', 'true') - visit(merge_request_path(merge_request)) end diff --git a/spec/features/incidents/incident_details_spec.rb b/spec/features/incidents/incident_details_spec.rb index a166ff46177..709919d0196 100644 --- a/spec/features/incidents/incident_details_spec.rb +++ b/spec/features/incidents/incident_details_spec.rb @@ -94,7 +94,6 @@ RSpec.describe 'Incident details', :js, feature_category: :incident_management d end it 'routes the user to the incident details page when the `issue_type` is set to incident' do - set_cookie('new-actions-popover-viewed', 'true') visit project_issue_path(project, issue) wait_for_requests @@ -114,7 +113,6 @@ RSpec.describe 'Incident details', :js, feature_category: :incident_management d end it 'routes the user to the issue details page when the `issue_type` is set to issue' do - set_cookie('new-actions-popover-viewed', 'true') visit incident_project_issues_path(project, incident) wait_for_requests diff --git a/spec/features/issues/discussion_lock_spec.rb b/spec/features/issues/discussion_lock_spec.rb index fb9addff1a2..47865d2b6ba 100644 --- a/spec/features/issues/discussion_lock_spec.rb +++ b/spec/features/issues/discussion_lock_spec.rb @@ -9,7 +9,6 @@ RSpec.describe 'Discussion Lock', :js, feature_category: :team_planning do before do sign_in(user) - stub_feature_flags(moved_mr_sidebar: false) end context 'when a user is a team member' do diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index 665c7307231..2bd5373b715 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' RSpec.describe 'GFM autocomplete', :js, feature_category: :team_planning do - include CookieHelper - let_it_be(:user) { create(:user, name: '💃speciąl someone💃', username: 'someone.special') } let_it_be(:user2) { create(:user, name: 'Marge Simpson', username: 'msimpson') } @@ -47,7 +45,6 @@ RSpec.describe 'GFM autocomplete', :js, feature_category: :team_planning do before do sign_in(user) - set_cookie('new-actions-popover-viewed', 'true') visit project_issue_path(project, issue_to_edit) wait_for_requests diff --git a/spec/features/issues/issue_detail_spec.rb b/spec/features/issues/issue_detail_spec.rb index 29a61d584ee..d5f90bb9260 100644 --- a/spec/features/issues/issue_detail_spec.rb +++ b/spec/features/issues/issue_detail_spec.rb @@ -98,7 +98,6 @@ RSpec.describe 'Issue Detail', :js, feature_category: :team_planning do project.add_developer(user_to_be_deleted) sign_in(user_to_be_deleted) - stub_feature_flags(moved_mr_sidebar: false) visit project_issue_path(project, issue) wait_for_requests @@ -130,7 +129,7 @@ RSpec.describe 'Issue Detail', :js, feature_category: :team_planning do describe 'when an issue `issue_type` is edited' do before do sign_in(user) - set_cookie('new-actions-popover-viewed', 'true') + visit project_issue_path(project, issue) wait_for_requests end @@ -164,7 +163,7 @@ RSpec.describe 'Issue Detail', :js, feature_category: :team_planning do describe 'when an incident `issue_type` is edited' do before do sign_in(user) - set_cookie('new-actions-popover-viewed', 'true') + visit project_issue_path(project, incident) wait_for_requests end diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index ee71181fba2..2ae347d4f9e 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -5,7 +5,6 @@ require 'spec_helper' RSpec.describe 'Issue Sidebar', feature_category: :team_planning do include MobileHelpers include Features::InviteMembersModalHelpers - include CookieHelper let_it_be(:group) { create(:group, :nested) } let_it_be(:project) { create(:project, :public, namespace: group) } @@ -21,7 +20,6 @@ RSpec.describe 'Issue Sidebar', feature_category: :team_planning do context 'when signed in' do before do sign_in(user) - set_cookie('new-actions-popover-viewed', 'true') end context 'when concerning the assignee', :js do @@ -207,7 +205,6 @@ RSpec.describe 'Issue Sidebar', feature_category: :team_planning do context 'as an allowed user' do before do - stub_feature_flags(moved_mr_sidebar: false) project.add_developer(user) visit_issue(project, issue) end @@ -296,7 +293,6 @@ RSpec.describe 'Issue Sidebar', feature_category: :team_planning do context 'as a guest' do before do - stub_feature_flags(moved_mr_sidebar: false) project.add_guest(user) visit_issue(project, issue) end diff --git a/spec/features/issues/user_edits_issue_spec.rb b/spec/features/issues/user_edits_issue_spec.rb index 4730406c2b2..3a927e76fd1 100644 --- a/spec/features/issues/user_edits_issue_spec.rb +++ b/spec/features/issues/user_edits_issue_spec.rb @@ -3,8 +3,6 @@ require "spec_helper" RSpec.describe "Issues > User edits issue", :js, feature_category: :team_planning do - include CookieHelper - let_it_be(:project) { create(:project_empty_repo, :public) } let_it_be(:project_with_milestones) { create(:project_empty_repo, :public) } let_it_be(:user) { create(:user) } @@ -20,7 +18,6 @@ RSpec.describe "Issues > User edits issue", :js, feature_category: :team_plannin project.add_developer(user) project_with_milestones.add_developer(user) sign_in(user) - set_cookie('new-actions-popover-viewed', 'true') end context "from edit page" do diff --git a/spec/features/issues/user_toggles_subscription_spec.rb b/spec/features/issues/user_toggles_subscription_spec.rb index 00b04c10d33..904fafdf56a 100644 --- a/spec/features/issues/user_toggles_subscription_spec.rb +++ b/spec/features/issues/user_toggles_subscription_spec.rb @@ -10,7 +10,6 @@ RSpec.describe "User toggles subscription", :js, feature_category: :team_plannin context 'user is not logged in' do before do - stub_feature_flags(moved_mr_sidebar: false) visit(project_issue_path(project, issue)) end @@ -21,9 +20,9 @@ RSpec.describe "User toggles subscription", :js, feature_category: :team_plannin context 'user is logged in' do before do - stub_feature_flags(moved_mr_sidebar: false) project.add_developer(user) sign_in(user) + visit(project_issue_path(project, issue)) end @@ -53,7 +52,6 @@ RSpec.describe "User toggles subscription", :js, feature_category: :team_plannin context 'user is logged in without edit permission' do before do - stub_feature_flags(moved_mr_sidebar: false) sign_in(user2) visit(project_issue_path(project, issue)) diff --git a/spec/features/merge_request/user_manages_subscription_spec.rb b/spec/features/merge_request/user_manages_subscription_spec.rb index 3bcc8255ab7..d4ccc4a93b5 100644 --- a/spec/features/merge_request/user_manages_subscription_spec.rb +++ b/spec/features/merge_request/user_manages_subscription_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' RSpec.describe 'User manages subscription', :js, feature_category: :code_review_workflow do - include CookieHelper - let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let(:user) { create(:user) } @@ -12,7 +10,7 @@ RSpec.describe 'User manages subscription', :js, feature_category: :code_review_ before do stub_feature_flags(moved_mr_sidebar: moved_mr_sidebar_enabled) - set_cookie('new-actions-popover-viewed', 'true') + project.add_maintainer(user) sign_in(user) diff --git a/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb b/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb index 601310cbacf..7cb1c95f6dc 100644 --- a/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb +++ b/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb @@ -4,7 +4,6 @@ require 'spec_helper' RSpec.describe 'Merge request > User opens checkout branch modal', :js, feature_category: :code_review_workflow do include ProjectForksHelper - include CookieHelper let(:project) { create(:project, :public, :repository) } let(:user) { project.creator } @@ -12,7 +11,6 @@ RSpec.describe 'Merge request > User opens checkout branch modal', :js, feature_ before do project.add_maintainer(user) sign_in(user) - set_cookie('new-actions-popover-viewed', 'true') end describe 'for fork' do diff --git a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb index 21c62b0d0d8..ad2ceeb23e2 100644 --- a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb +++ b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' RSpec.describe 'Merge request > User sees check out branch modal', :js, feature_category: :code_review_workflow do - include CookieHelper - let(:project) { create(:project, :public, :repository) } let(:user) { project.creator } let(:merge_request) { create(:merge_request, source_project: project) } @@ -12,7 +10,6 @@ RSpec.describe 'Merge request > User sees check out branch modal', :js, feature_ before do sign_in(user) - set_cookie('new-actions-popover-viewed', 'true') visit project_merge_request_path(project, merge_request) wait_for_requests diff --git a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb index dae28cbb05c..0de59ea21c5 100644 --- a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb +++ b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb @@ -4,7 +4,6 @@ require 'spec_helper' RSpec.describe 'Merge request > User selects branches for new MR', :js, feature_category: :code_review_workflow do include ListboxHelpers - include CookieHelper let(:project) { create(:project, :public, :repository) } let(:user) { project.creator } @@ -18,7 +17,6 @@ RSpec.describe 'Merge request > User selects branches for new MR', :js, feature_ before do project.add_maintainer(user) sign_in(user) - set_cookie('new-actions-popover-viewed', 'true') end it 'selects the source branch sha when a tag with the same name exists' do diff --git a/spec/features/projects/issuable_templates_spec.rb b/spec/features/projects/issuable_templates_spec.rb index 77f88994bfb..adf410ce6e8 100644 --- a/spec/features/projects/issuable_templates_spec.rb +++ b/spec/features/projects/issuable_templates_spec.rb @@ -4,7 +4,6 @@ require 'spec_helper' RSpec.describe 'issuable templates', :js, feature_category: :projects do include ProjectForksHelper - include CookieHelper let(:user) { create(:user) } let(:project) { create(:project, :public, :repository) } @@ -13,7 +12,6 @@ RSpec.describe 'issuable templates', :js, feature_category: :projects do before do project.add_maintainer(user) sign_in user - set_cookie('new-actions-popover-viewed', 'true') end context 'user creates an issue using templates' do diff --git a/spec/features/reportable_note/issue_spec.rb b/spec/features/reportable_note/issue_spec.rb index a18cdf27294..55e7f5897bc 100644 --- a/spec/features/reportable_note/issue_spec.rb +++ b/spec/features/reportable_note/issue_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' RSpec.describe 'Reportable note on issue', :js, feature_category: :team_planning do - include CookieHelper - let(:user) { create(:user) } let(:project) { create(:project) } let(:issue) { create(:issue, project: project) } @@ -13,7 +11,7 @@ RSpec.describe 'Reportable note on issue', :js, feature_category: :team_planning before do project.add_maintainer(user) sign_in(user) - set_cookie('new-actions-popover-viewed', 'true') + visit project_issue_path(project, issue) end diff --git a/spec/frontend/behaviors/quick_submit_spec.js b/spec/frontend/behaviors/quick_submit_spec.js index 8de05f7ac30..81eeb3f153e 100644 --- a/spec/frontend/behaviors/quick_submit_spec.js +++ b/spec/frontend/behaviors/quick_submit_spec.js @@ -61,22 +61,15 @@ describe('Quick Submit behavior', () => { expect(testContext.spies.submit).not.toHaveBeenCalled(); }); - it('disables input of type submit', () => { - const submitButton = $('.js-quick-submit input[type=submit]'); - testContext.textarea.trigger(keydownEvent()); - - expect(submitButton).toBeDisabled(); - }); - - it('disables button of type submit', () => { - const submitButton = $('.js-quick-submit input[type=submit]'); + it('disables submit', () => { + const submitButton = $('.js-quick-submit [type=submit]'); testContext.textarea.trigger(keydownEvent()); expect(submitButton).toBeDisabled(); }); it('only clicks one submit', () => { - const existingSubmit = $('.js-quick-submit input[type=submit]'); + const existingSubmit = $('.js-quick-submit [type=submit]'); // Add an extra submit button const newSubmit = $('<button type="submit">Submit it</button>'); newSubmit.insertAfter(testContext.textarea); diff --git a/spec/frontend/issues/show/components/header_actions_spec.js b/spec/frontend/issues/show/components/header_actions_spec.js index bd8e79a90ec..58ec7387851 100644 --- a/spec/frontend/issues/show/components/header_actions_spec.js +++ b/spec/frontend/issues/show/components/header_actions_spec.js @@ -2,8 +2,6 @@ import Vue, { nextTick } from 'vue'; import { GlDropdownItem, GlLink, GlModal, GlButton } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import Vuex from 'vuex'; -import VueApollo from 'vue-apollo'; -import waitForPromises from 'helpers/wait_for_promises'; import { mockTracking } from 'helpers/tracking_helper'; import { createAlert, VARIANT_SUCCESS } from '~/alert'; import { STATUS_CLOSED, STATUS_OPEN, TYPE_INCIDENT, TYPE_ISSUE } from '~/issues/constants'; @@ -16,22 +14,17 @@ import promoteToEpicMutation from '~/issues/show/queries/promote_to_epic.mutatio import * as urlUtility from '~/lib/utils/url_utility'; import eventHub from '~/notes/event_hub'; import createStore from '~/notes/stores'; -import createMockApollo from 'helpers/mock_apollo_helper'; -import issueReferenceQuery from '~/sidebar/queries/issue_reference.query.graphql'; -import updateIssueMutation from '~/issues/show/queries/update_issue.mutation.graphql'; -import toast from '~/vue_shared/plugins/global_toast'; jest.mock('~/alert'); jest.mock('~/issues/show/event_hub', () => ({ $emit: jest.fn() })); -jest.mock('~/vue_shared/plugins/global_toast'); describe('HeaderActions component', () => { let dispatchEventSpy; + let mutateMock; let wrapper; let visitUrlSpy; Vue.use(Vuex); - Vue.use(VueApollo); const store = createStore(); @@ -52,28 +45,15 @@ describe('HeaderActions component', () => { reportedUserId: 1, reportedFromUrl: 'http://localhost:/gitlab-org/-/issues/32', submitAsSpamPath: 'gitlab-org/gitlab-test/-/issues/32/submit_as_spam', - issuableEmailAddress: null, - fullPath: 'full-path', }; - const updateIssueMutationResponse = { - data: { - updateIssue: { - errors: [], - issuable: { - id: 'gid://gitlab/Issue/511', - state: STATUS_OPEN, - }, - }, - }, - }; + const updateIssueMutationResponse = { data: { updateIssue: { errors: [] } } }; const promoteToEpicMutationResponse = { data: { promoteToEpic: { errors: [], epic: { - id: 'gid://gitlab/Epic/1', webPath: '/groups/gitlab-org/-/epics/1', }, }, @@ -89,20 +69,6 @@ describe('HeaderActions component', () => { }, }; - const mockIssueReferenceData = { - data: { - workspace: { - id: 'gid://gitlab/Project/7', - issuable: { - id: 'gid://gitlab/Issue/511', - reference: 'flightjs/Flight#33', - __typename: 'Issue', - }, - __typename: 'Project', - }, - }, - }; - const findToggleIssueStateButton = () => wrapper.find(`[data-testid="toggle-button"]`); const findEditButton = () => wrapper.find(`[data-testid="edit-button"]`); @@ -111,54 +77,33 @@ describe('HeaderActions component', () => { const findDesktopDropdown = () => findDropdownBy('desktop-dropdown'); const findMobileDropdownItems = () => findMobileDropdown().findAllComponents(GlDropdownItem); const findDesktopDropdownItems = () => findDesktopDropdown().findAllComponents(GlDropdownItem); - const findAbuseCategorySelector = () => wrapper.findComponent(AbuseCategorySelector); - const findReportAbuseSelectorItem = () => wrapper.find(`[data-testid="report-abuse-item"]`); - const findNotificationWidget = () => wrapper.find(`[data-testid="notification-toggle"]`); - const findLockIssueWidget = () => wrapper.find(`[data-testid="lock-issue-toggle"]`); - const findCopyRefenceDropdownItem = () => wrapper.find(`[data-testid="copy-reference"]`); - const findCopyEmailItem = () => wrapper.find(`[data-testid="copy-email"]`); const findModal = () => wrapper.findComponent(GlModal); const findModalLinkAt = (index) => findModal().findAllComponents(GlLink).at(index); - const issueReferenceSuccessHandler = jest.fn().mockResolvedValue(mockIssueReferenceData); - const updateIssueMutationResponseHandler = jest - .fn() - .mockResolvedValue(updateIssueMutationResponse); - const promoteToEpicMutationSuccessResponseHandler = jest - .fn() - .mockResolvedValue(promoteToEpicMutationResponse); - const promoteToEpicMutationErrorHandler = jest - .fn() - .mockResolvedValue(promoteToEpicMutationErrorResponse); - const mountComponent = ({ props = {}, issueState = STATUS_OPEN, blockedByIssues = [], - movedMrSidebarEnabled = false, - promoteToEpicHandler = promoteToEpicMutationSuccessResponseHandler, + mutateResponse = {}, } = {}) => { + mutateMock = jest.fn().mockResolvedValue(mutateResponse); + store.dispatch('setNoteableData', { blocked_by_issues: blockedByIssues, state: issueState, }); - const handlers = [ - [issueReferenceQuery, issueReferenceSuccessHandler], - [updateIssueMutation, updateIssueMutationResponseHandler], - [promoteToEpicMutation, promoteToEpicHandler], - ]; - return shallowMount(HeaderActions, { - apolloProvider: createMockApollo(handlers), store, provide: { ...defaultProps, ...props, - glFeatures: { - movedMrSidebar: movedMrSidebarEnabled, + }, + mocks: { + $apollo: { + mutate: mutateMock, }, }, stubs: { @@ -193,6 +138,7 @@ describe('HeaderActions component', () => { wrapper = mountComponent({ props: { issueType }, issueState, + mutateResponse: updateIssueMutationResponse, }); }); @@ -203,19 +149,23 @@ describe('HeaderActions component', () => { it('calls apollo mutation', () => { findToggleIssueStateButton().vm.$emit('click'); - expect(updateIssueMutationResponseHandler).toHaveBeenCalledWith({ - input: { - iid: defaultProps.iid, - projectPath: defaultProps.projectPath, - stateEvent: newIssueState, - }, - }); + expect(mutateMock).toHaveBeenCalledWith( + expect.objectContaining({ + variables: { + input: { + iid: defaultProps.iid, + projectPath: defaultProps.projectPath, + stateEvent: newIssueState, + }, + }, + }), + ); }); it('dispatches a custom event to update the issue page', async () => { findToggleIssueStateButton().vm.$emit('click'); - await waitForPromises(); + await nextTick(); expect(dispatchEventSpy).toHaveBeenCalledTimes(1); }); @@ -340,25 +290,28 @@ describe('HeaderActions component', () => { describe('when "Promote to epic" button is clicked', () => { describe('when response is successful', () => { - beforeEach(async () => { + beforeEach(() => { visitUrlSpy = jest.spyOn(urlUtility, 'visitUrl').mockReturnValue({}); wrapper = mountComponent({ - promoteToEpicHandler: promoteToEpicMutationSuccessResponseHandler, + mutateResponse: promoteToEpicMutationResponse, }); wrapper.find('[data-testid="promote-button"]').vm.$emit('click'); - - await waitForPromises(); }); it('invokes GraphQL mutation when clicked', () => { - expect(promoteToEpicMutationSuccessResponseHandler).toHaveBeenCalledWith({ - input: { - iid: defaultProps.iid, - projectPath: defaultProps.projectPath, - }, - }); + expect(mutateMock).toHaveBeenCalledWith( + expect.objectContaining({ + mutation: promoteToEpicMutation, + variables: { + input: { + iid: defaultProps.iid, + projectPath: defaultProps.projectPath, + }, + }, + }), + ); }); it('shows a success message and tells the user they are being redirected', () => { @@ -376,16 +329,14 @@ describe('HeaderActions component', () => { }); describe('when response contains errors', () => { - beforeEach(async () => { + beforeEach(() => { visitUrlSpy = jest.spyOn(urlUtility, 'visitUrl').mockReturnValue({}); wrapper = mountComponent({ - promoteToEpicHandler: promoteToEpicMutationErrorHandler, + mutateResponse: promoteToEpicMutationErrorResponse, }); wrapper.find('[data-testid="promote-button"]').vm.$emit('click'); - - await waitForPromises(); }); it('shows an error message', () => { @@ -398,17 +349,21 @@ describe('HeaderActions component', () => { describe('when `toggle.issuable.state` event is emitted', () => { it('invokes a method to toggle the issue state', () => { - wrapper = mountComponent(); + wrapper = mountComponent({ mutateResponse: updateIssueMutationResponse }); eventHub.$emit('toggle.issuable.state'); - expect(updateIssueMutationResponseHandler).toHaveBeenCalledWith({ - input: { - iid: defaultProps.iid, - projectPath: defaultProps.projectPath, - stateEvent: ISSUE_STATE_EVENT_CLOSE, - }, - }); + expect(mutateMock).toHaveBeenCalledWith( + expect.objectContaining({ + variables: { + input: { + iid: defaultProps.iid, + projectPath: defaultProps.projectPath, + stateEvent: ISSUE_STATE_EVENT_CLOSE, + }, + }, + }), + ); }); }); @@ -437,13 +392,17 @@ describe('HeaderActions component', () => { it('calls apollo mutation when primary button is clicked', () => { findModal().vm.$emit('primary'); - expect(updateIssueMutationResponseHandler).toHaveBeenCalledWith({ - input: { - iid: defaultProps.iid.toString(), - projectPath: defaultProps.projectPath, - stateEvent: ISSUE_STATE_EVENT_CLOSE, - }, - }); + expect(mutateMock).toHaveBeenCalledWith( + expect.objectContaining({ + variables: { + input: { + iid: defaultProps.iid.toString(), + projectPath: defaultProps.projectPath, + stateEvent: ISSUE_STATE_EVENT_CLOSE, + }, + }, + }), + ); }); describe.each` @@ -475,6 +434,8 @@ describe('HeaderActions component', () => { }); describe('abuse category selector', () => { + const findAbuseCategorySelector = () => wrapper.findComponent(AbuseCategorySelector); + beforeEach(() => { wrapper = mountComponent({ props: { isIssueAuthor: false } }); }); @@ -484,7 +445,7 @@ describe('HeaderActions component', () => { }); it('opens the drawer', async () => { - findReportAbuseSelectorItem().vm.$emit('click'); + findDesktopDropdownItems().at(2).vm.$emit('click'); await nextTick(); @@ -492,160 +453,10 @@ describe('HeaderActions component', () => { }); it('closes the drawer', async () => { - await findReportAbuseSelectorItem().vm.$emit('click'); + await findDesktopDropdownItems().at(2).vm.$emit('click'); await findAbuseCategorySelector().vm.$emit('close-drawer'); expect(findAbuseCategorySelector().exists()).toEqual(false); }); }); - - describe('notification toggle', () => { - describe('visibility', () => { - describe.each` - movedMrSidebarEnabled | issueType | visible - ${true} | ${TYPE_ISSUE} | ${true} - ${true} | ${TYPE_INCIDENT} | ${true} - ${false} | ${TYPE_ISSUE} | ${false} - ${false} | ${TYPE_INCIDENT} | ${false} - `( - `when movedMrSidebarEnabled flag is "$movedMrSidebarEnabled" with issue type "$issueType"`, - ({ movedMrSidebarEnabled, issueType, visible }) => { - beforeEach(() => { - wrapper = mountComponent({ - props: { - issueType, - }, - movedMrSidebarEnabled, - }); - }); - - it(`${visible ? 'shows' : 'hides'} Notification toggle`, () => { - expect(findNotificationWidget().exists()).toBe(visible); - }); - }, - ); - }); - }); - - describe('lock issue option', () => { - describe('visibility', () => { - describe.each` - movedMrSidebarEnabled | issueType | visible - ${true} | ${TYPE_ISSUE} | ${true} - ${true} | ${TYPE_INCIDENT} | ${false} - ${false} | ${TYPE_ISSUE} | ${false} - ${false} | ${TYPE_INCIDENT} | ${false} - `( - `when movedMrSidebarEnabled flag is "$movedMrSidebarEnabled" with issue type "$issueType"`, - ({ movedMrSidebarEnabled, issueType, visible }) => { - beforeEach(() => { - wrapper = mountComponent({ - props: { - issueType, - }, - movedMrSidebarEnabled, - }); - }); - - it(`${visible ? 'shows' : 'hides'} Lock issue option`, () => { - expect(findLockIssueWidget().exists()).toBe(visible); - }); - }, - ); - }); - }); - - describe('copy reference option', () => { - describe('visibility', () => { - describe.each` - movedMrSidebarEnabled | issueType | visible - ${true} | ${TYPE_ISSUE} | ${true} - ${true} | ${TYPE_INCIDENT} | ${true} - ${false} | ${TYPE_ISSUE} | ${false} - ${false} | ${TYPE_INCIDENT} | ${false} - `( - 'when movedMrSidebarFlagEnabled is "$movedMrSidebarEnabled" with issue type "$issueType"', - ({ movedMrSidebarEnabled, issueType, visible }) => { - beforeEach(() => { - wrapper = mountComponent({ - props: { - issueType, - }, - movedMrSidebarEnabled, - }); - }); - - it(`${visible ? 'shows' : 'hides'} Copy reference option`, () => { - expect(findCopyRefenceDropdownItem().exists()).toBe(visible); - }); - }, - ); - }); - - describe('clicking when visible', () => { - beforeEach(() => { - wrapper = mountComponent({ - props: { - issueType: TYPE_ISSUE, - }, - movedMrSidebarEnabled: true, - }); - }); - - it('shows toast message', () => { - findCopyRefenceDropdownItem().vm.$emit('click'); - - expect(toast).toHaveBeenCalledWith('Reference copied'); - }); - }); - }); - - describe('copy email option', () => { - describe('visibility', () => { - describe.each` - movedMrSidebarEnabled | issueType | issuableEmailAddress | visible - ${true} | ${TYPE_ISSUE} | ${'mock-email-address'} | ${true} - ${true} | ${TYPE_ISSUE} | ${''} | ${false} - ${true} | ${TYPE_INCIDENT} | ${'mock-email-address'} | ${true} - ${true} | ${TYPE_INCIDENT} | ${''} | ${false} - ${false} | ${TYPE_ISSUE} | ${'mock-email-address'} | ${false} - ${false} | ${TYPE_INCIDENT} | ${'mock-email-address'} | ${false} - `( - 'when movedMrSidebarEnabled flag is "$movedMrSidebarEnabled" issue type is "$issueType" and issuableEmailAddress="$issuableEmailAddress"', - ({ movedMrSidebarEnabled, issueType, issuableEmailAddress, visible }) => { - beforeEach(() => { - wrapper = mountComponent({ - props: { - issueType, - issuableEmailAddress, - }, - movedMrSidebarEnabled, - }); - }); - - it(`${visible ? 'shows' : 'hides'} Copy email option`, () => { - expect(findCopyEmailItem().exists()).toBe(visible); - }); - }, - ); - }); - - describe('clicking when visible', () => { - beforeEach(() => { - wrapper = mountComponent({ - props: { - issueType: TYPE_ISSUE, - issuableEmailAddress: 'mock-email-address', - }, - movedMrSidebarEnabled: true, - }); - }); - - it('shows toast message', () => { - findCopyEmailItem().vm.$emit('click'); - - expect(toast).toHaveBeenCalledWith('Email address copied'); - }); - }); - }); }); diff --git a/spec/frontend/issues/show/components/new_header_actions_popover_spec.js b/spec/frontend/issues/show/components/new_header_actions_popover_spec.js deleted file mode 100644 index 71b7a3da1c3..00000000000 --- a/spec/frontend/issues/show/components/new_header_actions_popover_spec.js +++ /dev/null @@ -1,67 +0,0 @@ -import { GlPopover } from '@gitlab/ui'; -import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; -import NewHeaderActionsPopover from '~/issues/show/components/new_header_actions_popover.vue'; -import { NEW_ACTIONS_POPOVER_KEY } from '~/issues/show/constants'; -import { TYPE_ISSUE } from '~/issues/constants'; -import * as utils from '~/lib/utils/common_utils'; - -describe('NewHeaderActionsPopover', () => { - let wrapper; - - const createComponent = ({ issueType = TYPE_ISSUE }) => { - wrapper = shallowMountExtended(NewHeaderActionsPopover, { - propsData: { - issueType, - }, - stubs: { - GlPopover, - }, - }); - }; - - const findPopover = () => wrapper.findComponent(GlPopover); - const findConfirmButton = () => wrapper.findByTestId('confirm-button'); - - describe('without the popover cookie', () => { - beforeEach(() => { - utils.setCookie = jest.fn(); - - createComponent({}); - }); - - it('renders the popover with correct text', () => { - expect(findPopover().exists()).toBe(true); - expect(findPopover().text()).toContain('issue actions'); - }); - - it('does not call setCookie', () => { - expect(utils.setCookie).not.toHaveBeenCalled(); - }); - - describe('when the confirm button is clicked', () => { - beforeEach(() => { - findConfirmButton().vm.$emit('click'); - }); - - it('sets the popover cookie', () => { - expect(utils.setCookie).toHaveBeenCalledWith(NEW_ACTIONS_POPOVER_KEY, true); - }); - - it('hides the popover', () => { - expect(findPopover().exists()).toBe(false); - }); - }); - }); - - describe('with the popover cookie', () => { - beforeEach(() => { - jest.spyOn(utils, 'getCookie').mockReturnValue('true'); - - createComponent({}); - }); - - it('does not render the popover', () => { - expect(findPopover().exists()).toBe(false); - }); - }); -}); diff --git a/spec/frontend/sidebar/components/lock/issuable_lock_form_spec.js b/spec/frontend/sidebar/components/lock/issuable_lock_form_spec.js index 5e766e9a41c..d26ef7298ce 100644 --- a/spec/frontend/sidebar/components/lock/issuable_lock_form_spec.js +++ b/spec/frontend/sidebar/components/lock/issuable_lock_form_spec.js @@ -29,7 +29,6 @@ describe('IssuableLockForm', () => { const findEditForm = () => wrapper.findComponent(EditForm); const findSidebarLockStatusTooltip = () => getBinding(findSidebarCollapseIcon().element, 'gl-tooltip'); - const findIssuableLockClickable = () => wrapper.find('[data-testid="issuable-lock"]'); const initStore = (isLocked) => { if (issuableType === ISSUABLE_TYPE_ISSUE) { @@ -49,7 +48,7 @@ describe('IssuableLockForm', () => { store.getters.getNoteableData.discussion_locked = isLocked; }; - const createComponent = ({ props = {}, movedMrSidebar = false }) => { + const createComponent = ({ props = {} }, movedMrSidebar = false) => { wrapper = shallowMount(IssuableLockForm, { store, provide: { @@ -170,27 +169,11 @@ describe('IssuableLockForm', () => { `('displays $message when merge request is $locked', async ({ locked, message }) => { initStore(locked); - createComponent({ movedMrSidebar: true }); + createComponent({}, true); await wrapper.find('.dropdown-item').trigger('click'); expect(toast).toHaveBeenCalledWith(message); }); }); - - describe('moved_mr_sidebar flag', () => { - describe('when the flag is off', () => { - it('does not show the non editable lock status', () => { - createComponent({ movedMrSidebar: false }); - expect(findIssuableLockClickable().exists()).toBe(false); - }); - }); - - describe('when the flag is on', () => { - it('does not show the non editable lock status', () => { - createComponent({ movedMrSidebar: true }); - expect(findIssuableLockClickable().exists()).toBe(true); - }); - }); - }); }); diff --git a/spec/graphql/types/ci/job_trace_type_spec.rb b/spec/graphql/types/ci/job_trace_type_spec.rb new file mode 100644 index 00000000000..71803aa9ece --- /dev/null +++ b/spec/graphql/types/ci/job_trace_type_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['CiJobTrace'], feature_category: :continuous_integration do + include GraphqlHelpers + + let_it_be(:job) { create(:ci_build) } + + it 'has the correct fields' do + expected_fields = [:html_summary] + + expect(described_class).to have_graphql_fields(*expected_fields) + end + + it 'shows the correct trace contents' do + job.trace.set('BUILD TRACE') + + expect_next_instance_of(Gitlab::Ci::Trace) do |trace| + expect(trace).to receive(:html).with(last_lines: 10).and_call_original + end + + resolved_field = resolve_field(:html_summary, job.trace) + + expect(resolved_field).to eq("<span>BUILD TRACE</span>") + end +end diff --git a/spec/graphql/types/ci/job_type_spec.rb b/spec/graphql/types/ci/job_type_spec.rb index 4eb18574969..7715ccdd075 100644 --- a/spec/graphql/types/ci/job_type_spec.rb +++ b/spec/graphql/types/ci/job_type_spec.rb @@ -55,6 +55,7 @@ RSpec.describe Types::Ci::JobType, feature_category: :continuous_integration do playPath canPlayJob scheduled + trace ] expect(described_class).to have_graphql_fields(*expected_fields) diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index 38cbb5a1d66..d940c696fb3 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' RSpec.describe IssuesHelper do - include Features::MergeRequestHelpers - let_it_be(:project) { create(:project) } let_it_be_with_reload(:issue) { create(:issue, project: project) } @@ -237,13 +235,10 @@ RSpec.describe IssuesHelper do describe '#issue_header_actions_data' do let(:current_user) { create(:user) } - let(:merge_request) { create(:merge_request, :opened, source_project: project, author: current_user) } - let(:issuable_sidebar_issue) { serialize_issuable_sidebar(current_user, project, merge_request) } before do allow(helper).to receive(:current_user).and_return(current_user) allow(helper).to receive(:can?).and_return(true) - allow(helper).to receive(:issuable_sidebar).and_return(issuable_sidebar_issue) end it 'returns expected result' do @@ -262,11 +257,10 @@ RSpec.describe IssuesHelper do report_abuse_path: add_category_abuse_reports_path, reported_user_id: issue.author.id, reported_from_url: issue_url(issue), - submit_as_spam_path: mark_as_spam_project_issue_path(project, issue), - issuable_email_address: issuable_sidebar_issue[:create_note_email] + submit_as_spam_path: mark_as_spam_project_issue_path(project, issue) } - expect(helper.issue_header_actions_data(project, issue, current_user, issuable_sidebar_issue)).to include(expected) + expect(helper.issue_header_actions_data(project, issue, current_user)).to include(expected) end end diff --git a/spec/requests/api/error_tracking/project_settings_spec.rb b/spec/requests/api/error_tracking/project_settings_spec.rb index 3b01dec6f9c..bde90627983 100644 --- a/spec/requests/api/error_tracking/project_settings_spec.rb +++ b/spec/requests/api/error_tracking/project_settings_spec.rb @@ -4,9 +4,9 @@ require 'spec_helper' RSpec.describe API::ErrorTracking::ProjectSettings, feature_category: :error_tracking do let_it_be(:user) { create(:user) } - - let(:setting) { create(:project_error_tracking_setting) } - let(:project) { setting.project } + let_it_be(:project) { create(:project) } + let_it_be(:setting) { create(:project_error_tracking_setting, project: project) } + let_it_be(:project_without_setting) { create(:project) } shared_examples 'returns project settings' do it 'returns correct project settings' do @@ -100,7 +100,8 @@ RSpec.describe API::ErrorTracking::ProjectSettings, feature_category: :error_tra end describe "PATCH /projects/:id/error_tracking/settings" do - let(:params) { { active: false } } + let(:params) { { active: false, integrated: integrated } } + let(:integrated) { false } def make_request patch api("/projects/#{project.id}/error_tracking/settings", user), params: params @@ -111,82 +112,78 @@ RSpec.describe API::ErrorTracking::ProjectSettings, feature_category: :error_tra project.add_maintainer(user) end - context 'patch settings' do - context 'integrated_error_tracking feature enabled' do - it_behaves_like 'returns project settings' - end - - context 'integrated_error_tracking feature disabled' do - before do - stub_feature_flags(integrated_error_tracking: false) - end + context 'with integrated_error_tracking feature enabled' do + it_behaves_like 'returns project settings' + end - it_behaves_like 'returns project settings with false for integrated' + context 'with integrated_error_tracking feature disabled' do + before do + stub_feature_flags(integrated_error_tracking: false) end - it 'updates enabled flag' do - expect(setting).to be_enabled + it_behaves_like 'returns project settings with false for integrated' + end - make_request + it 'updates enabled flag' do + expect(setting).to be_enabled - expect(json_response).to include('active' => false) - expect(setting.reload).not_to be_enabled - end + make_request - context 'active is invalid' do - let(:params) { { active: "randomstring" } } + expect(json_response).to include('active' => false) + expect(setting.reload).not_to be_enabled + end - it 'returns active is invalid if non boolean' do - make_request + context 'when active is invalid' do + let(:params) { { active: "randomstring" } } - expect(response).to have_gitlab_http_status(:bad_request) - expect(json_response['error']) - .to eq('active is invalid') - end + it 'returns active is invalid if non boolean' do + make_request + + expect(response).to have_gitlab_http_status(:bad_request) + expect(json_response['error']) + .to eq('active is invalid') end + end - context 'active is empty' do - let(:params) { { active: '' } } + context 'when active is empty' do + let(:params) { { active: '' } } - it 'returns 400' do - make_request + it 'returns 400' do + make_request - expect(response).to have_gitlab_http_status(:bad_request) - expect(json_response['error']) - .to eq('active is empty') - end + expect(response).to have_gitlab_http_status(:bad_request) + expect(json_response['error']) + .to eq('active is empty') end + end - context 'with integrated param' do - let(:params) { { active: true, integrated: true } } + context 'with integrated param' do + let(:params) { { active: true, integrated: true } } - context 'integrated_error_tracking feature enabled' do - before do - stub_feature_flags(integrated_error_tracking: true) - end + context 'when integrated_error_tracking feature enabled' do + before do + stub_feature_flags(integrated_error_tracking: true) + end - it 'updates the integrated flag' do - expect(setting.integrated).to be_falsey + it 'updates the integrated flag' do + expect(setting.integrated).to be_falsey - make_request + make_request - expect(json_response).to include('integrated' => true) - expect(setting.reload.integrated).to be_truthy - end + expect(json_response).to include('integrated' => true) + expect(setting.reload.integrated).to be_truthy end end end context 'without a project setting' do - let_it_be(:project) { create(:project) } + let(:project) { project_without_setting } before do project.add_maintainer(user) end - context 'patch settings' do - it_behaves_like 'returns no project settings' - end + it_behaves_like 'returns no project settings' end context "when ::Projects::Operations::UpdateService responds with an error" do @@ -210,38 +207,22 @@ RSpec.describe API::ErrorTracking::ProjectSettings, feature_category: :error_tra end end - context 'when authenticated as reporter' do - before do - project.add_reporter(user) - end - - context 'patch request' do - it_behaves_like 'returns 403' - end - end - context 'when authenticated as developer' do before do project.add_developer(user) end - context 'patch request' do - it_behaves_like 'returns 403' - end + it_behaves_like 'returns 403' end context 'when authenticated as non-member' do - context 'patch request' do - it_behaves_like 'returns 404' - end + it_behaves_like 'returns 404' end context 'when unauthenticated' do let(:user) { nil } - context 'patch request' do - it_behaves_like 'returns 401' - end + it_behaves_like 'returns 401' end end @@ -255,43 +236,25 @@ RSpec.describe API::ErrorTracking::ProjectSettings, feature_category: :error_tra project.add_maintainer(user) end - context 'get settings' do - context 'integrated_error_tracking feature enabled' do - before do - stub_feature_flags(integrated_error_tracking: true) - end + it_behaves_like 'returns project settings' - it_behaves_like 'returns project settings' + context 'when integrated_error_tracking feature disabled' do + before do + stub_feature_flags(integrated_error_tracking: false) end - context 'integrated_error_tracking feature disabled' do - before do - stub_feature_flags(integrated_error_tracking: false) - end - - it_behaves_like 'returns project settings with false for integrated' - end + it_behaves_like 'returns project settings with false for integrated' end end context 'without a project setting' do - let(:project) { create(:project) } + let(:project) { project_without_setting } before do project.add_maintainer(user) end - context 'get settings' do - it_behaves_like 'returns no project settings' - end - end - - context 'when authenticated as reporter' do - before do - project.add_reporter(user) - end - - it_behaves_like 'returns 403' + it_behaves_like 'returns no project settings' end context 'when authenticated as developer' do @@ -329,9 +292,8 @@ RSpec.describe API::ErrorTracking::ProjectSettings, feature_category: :error_tra end context "when integrated" do - let(:integrated) { true } - context "with existing setting" do + let(:project) { setting.project } let(:setting) { create(:project_error_tracking_setting, :integrated) } let(:active) { false } @@ -351,8 +313,8 @@ RSpec.describe API::ErrorTracking::ProjectSettings, feature_category: :error_tra end context "without setting" do + let(:project) { project_without_setting } let(:active) { true } - let_it_be(:project) { create(:project) } it "creates a setting" do expect { make_request }.to change { ErrorTracking::ProjectErrorTrackingSetting.count } @@ -362,7 +324,7 @@ RSpec.describe API::ErrorTracking::ProjectSettings, feature_category: :error_tra expect(json_response).to eq( "active" => true, "api_url" => nil, - "integrated" => integrated, + "integrated" => true, "project_name" => nil, "sentry_external_url" => nil ) @@ -382,9 +344,7 @@ RSpec.describe API::ErrorTracking::ProjectSettings, feature_category: :error_tra end end - context "integrated_error_tracking feature disabled" do - let(:integrated) { true } - + context "when integrated_error_tracking feature disabled" do before do stub_feature_flags(integrated_error_tracking: false) end @@ -405,14 +365,6 @@ RSpec.describe API::ErrorTracking::ProjectSettings, feature_category: :error_tra end end - context 'as reporter' do - before do - project.add_reporter(user) - end - - it_behaves_like 'returns 403' - end - context "as developer" do before do project.add_developer(user) @@ -428,7 +380,6 @@ RSpec.describe API::ErrorTracking::ProjectSettings, feature_category: :error_tra context "when unauthorized" do let(:user) { nil } - let(:integrated) { true } it_behaves_like 'returns 401' end diff --git a/spec/requests/jwks_controller_spec.rb b/spec/requests/jwks_controller_spec.rb index c6f5f7c6bea..f756c1758e4 100644 --- a/spec/requests/jwks_controller_spec.rb +++ b/spec/requests/jwks_controller_spec.rb @@ -35,6 +35,15 @@ RSpec.describe JwksController, feature_category: :system_access do expect(ids).to contain_exactly(ci_jwk['kid'], oidc_jwk['kid']) end + it 'includes the OIDC signing key ID' do + get jwks_url + + expect(response).to have_gitlab_http_status(:ok) + + ids = json_response['keys'].map { |jwk| jwk['kid'] } + expect(ids).to include(Doorkeeper::OpenidConnect.signing_key_normalized.symbolize_keys[:kid]) + end + it 'does not leak private key data' do get jwks_url diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml index 15743e6b695..03c35e5774d 100644 --- a/spec/support/rspec_order_todo.yml +++ b/spec/support/rspec_order_todo.yml @@ -8544,7 +8544,6 @@ - './spec/requests/api/environments_spec.rb' - './spec/requests/api/error_tracking/client_keys_spec.rb' - './spec/requests/api/error_tracking/collector_spec.rb' -- './spec/requests/api/error_tracking/project_settings_spec.rb' - './spec/requests/api/events_spec.rb' - './spec/requests/api/feature_flags_spec.rb' - './spec/requests/api/feature_flags_user_lists_spec.rb' |