diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-05 06:13:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-05 06:13:51 +0300 |
commit | c20abe491ceeb1b8e1350f18f0c91e0a31c73cb5 (patch) | |
tree | b8f9c5888b0ec18b24eb49f790a253ddc7905f1a /spec/frontend | |
parent | 35850d3d1643a9e2c5328f45b8a9026ac3d86e35 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/fixtures/merge_requests.rb | 8 | ||||
-rw-r--r-- | spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js | 60 |
2 files changed, 67 insertions, 1 deletions
diff --git a/spec/frontend/fixtures/merge_requests.rb b/spec/frontend/fixtures/merge_requests.rb index a1896a6470b..e8272a1f93a 100644 --- a/spec/frontend/fixtures/merge_requests.rb +++ b/spec/frontend/fixtures/merge_requests.rb @@ -2,7 +2,13 @@ require 'spec_helper' -RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :controller do +RSpec + .describe( + Projects::MergeRequestsController, + '(JavaScript fixtures)', + type: :controller, + feature_category: :code_review_workflow + ) do include JavaScriptFixturesHelpers let(:namespace) { create(:namespace, name: 'frontend-fixtures') } diff --git a/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js b/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js index 2aed037be6f..c81f4328d2a 100644 --- a/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js +++ b/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js @@ -4,6 +4,7 @@ import { GlButton, GlSprintf } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import { createMockSubscription as createMockApolloSubscription } from 'mock-apollo-client'; import approvedByCurrentUser from 'test_fixtures/graphql/merge_requests/approvals/approvals.query.graphql.json'; +import { visitUrl } from '~/lib/utils/url_utility'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import { getIdFromGraphQLId } from '~/graphql_shared/utils'; @@ -28,6 +29,10 @@ jest.mock('~/alert', () => ({ dismiss: mockAlertDismiss, })), })); +jest.mock('~/lib/utils/url_utility', () => ({ + ...jest.requireActual('~/lib/utils/url_utility'), + visitUrl: jest.fn(), +})); const TEST_HELP_PATH = 'help/path'; const testApprovedBy = () => [1, 7, 10].map((id) => ({ id })); @@ -113,6 +118,7 @@ describe('MRWidget approvals', () => { targetProjectFullPath: 'gitlab-org/gitlab', id: 1, iid: '1', + requireSamlAuthToApprove: false, }; jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); @@ -172,6 +178,22 @@ describe('MRWidget approvals', () => { category: 'primary', }); }); + + describe('with SAML auth requried for approval', () => { + beforeEach(async () => { + const response = createCanApproveResponse(); + mr.requireSamlAuthToApprove = true; + createComponent({}, { query: response }); + await waitForPromises(); + }); + it('approve action is rendered with correct text', () => { + expect(findActionData()).toEqual({ + variant: 'confirm', + text: 'Approve with SAML', + category: 'primary', + }); + }); + }); }); describe('and MR is approved', () => { @@ -194,6 +216,25 @@ describe('MRWidget approvals', () => { }); }); + describe('with approvers, with SAML auth requried for approval', () => { + beforeEach(async () => { + canApproveResponse.data.project.mergeRequest.approvedBy.nodes = + approvedByCurrentUser.data.project.mergeRequest.approvedBy.nodes; + canApproveResponse.data.project.mergeRequest.approvedBy.nodes[0].id = 69; + mr.requireSamlAuthToApprove = true; + createComponent({}, { query: canApproveResponse }); + await waitForPromises(); + }); + + it('approve additionally action is rendered with correct text', () => { + expect(findActionData()).toEqual({ + variant: 'confirm', + text: 'Approve additionally with SAML', + category: 'secondary', + }); + }); + }); + describe('with approvers', () => { beforeEach(async () => { canApproveResponse.data.project.mergeRequest.approvedBy.nodes = @@ -215,6 +256,25 @@ describe('MRWidget approvals', () => { }); }); + describe('when SAML auth is required and user clicks Approve with SAML', () => { + const fakeGroupSamlPath = '/example_group_saml'; + + beforeEach(async () => { + mr.requireSamlAuthToApprove = true; + mr.samlApprovalPath = fakeGroupSamlPath; + + createComponent({}, { query: createCanApproveResponse() }); + await waitForPromises(); + }); + + it('redirects the user to the group SAML path', async () => { + const action = findAction(); + action.vm.$emit('click'); + await nextTick(); + expect(visitUrl).toHaveBeenCalledWith(fakeGroupSamlPath); + }); + }); + describe('when approve action is clicked', () => { beforeEach(async () => { createComponent({}, { query: canApproveResponse }); |