Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-02-05 21:09:19 +00:00
parent a83bc624e4
commit 854956bd52
32 changed files with 383 additions and 397 deletions

View File

@ -1,5 +1,6 @@
import Vue from 'vue';
import store from '~/mr_notes/stores';
import initCherryPickCommitModal from '~/projects/commit/init_cherry_pick_commit_modal';
import initRevertCommitModal from '~/projects/commit/init_revert_commit_modal';
import initDiffsApp from '../diffs';
import discussionCounter from '../notes/components/discussion_counter.vue';
@ -22,6 +23,7 @@ export default function initMrNotes() {
document.addEventListener('merged:UpdateActions', () => {
initRevertCommitModal();
initCherryPickCommitModal();
});
// eslint-disable-next-line no-new

View File

@ -1,12 +1,11 @@
<script>
import { GlIcon } from '@gitlab/ui';
import projectFeatureToggle from '~/vue_shared/components/toggle_button.vue';
import { GlIcon, GlToggle } from '@gitlab/ui';
import { featureAccessLevelNone } from '../constants';
export default {
components: {
GlIcon,
projectFeatureToggle,
GlToggle,
},
model: {
prop: 'value',
@ -78,11 +77,11 @@ export default {
class="project-feature-controls gl-display-flex gl-align-items-center gl-my-3 gl-mx-0"
>
<input v-if="name" :name="name" :value="value" type="hidden" />
<project-feature-toggle
<gl-toggle
v-if="showToggle"
class="gl-flex-grow-0 gl-mr-3"
class="gl-mr-3"
:value="featureEnabled"
:disabled-input="disabledInput"
:disabled="disabledInput"
@change="toggleFeature"
/>
<div class="select-wrapper gl-flex-fill-1">

View File

@ -1,9 +1,8 @@
<script>
import { GlIcon, GlSprintf, GlLink, GlFormCheckbox } from '@gitlab/ui';
import { GlIcon, GlSprintf, GlLink, GlFormCheckbox, GlToggle } from '@gitlab/ui';
import settingsMixin from 'ee_else_ce/pages/projects/shared/permissions/mixins/settings_pannel_mixin';
import { s__ } from '~/locale';
import projectFeatureToggle from '~/vue_shared/components/toggle_button.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import {
visibilityOptions,
@ -22,12 +21,12 @@ const PAGE_FEATURE_ACCESS_LEVEL = s__('ProjectSettings|Everyone');
export default {
components: {
projectFeatureSetting,
projectFeatureToggle,
projectSettingRow,
GlIcon,
GlSprintf,
GlLink,
GlFormCheckbox,
GlToggle,
},
mixins: [settingsMixin, glFeatureFlagsMixin()],
@ -483,9 +482,10 @@ export default {
)
}}
</div>
<project-feature-toggle
<gl-toggle
v-model="containerRegistryEnabled"
:disabled-input="!repositoryEnabled"
class="gl-my-2"
:disabled="!repositoryEnabled"
name="project[container_registry_enabled]"
/>
</project-setting-row>
@ -498,9 +498,10 @@ export default {
s__('ProjectSettings|Manages large files such as audio, video, and graphics files.')
"
>
<project-feature-toggle
<gl-toggle
v-model="lfsEnabled"
:disabled-input="!repositoryEnabled"
class="gl-my-2"
:disabled="!repositoryEnabled"
name="project[lfs_enabled]"
/>
<p v-if="!lfsEnabled && lfsObjectsExist">
@ -530,9 +531,10 @@ export default {
s__('ProjectSettings|Every project can have its own space to store its packages.')
"
>
<project-feature-toggle
<gl-toggle
v-model="packagesEnabled"
:disabled-input="!repositoryEnabled"
class="gl-my-2"
:disabled="!repositoryEnabled"
name="project[packages_enabled]"
/>
</project-setting-row>

View File

@ -1,5 +1,5 @@
<script>
import { GlButton, GlIcon, GlModal, GlModalDirective } from '@gitlab/ui';
import { GlButton, GlModal, GlModalDirective } from '@gitlab/ui';
import RequestWarning from './request_warning.vue';
export default {
@ -7,7 +7,6 @@ export default {
RequestWarning,
GlButton,
GlModal,
GlIcon,
},
directives: {
'gl-modal': GlModalDirective,
@ -97,7 +96,7 @@ export default {
<span class="gl-text-blue-300 gl-font-weight-bold">{{ metricDetailsLabel }}</span>
</gl-button>
<gl-modal :modal-id="modalId" :title="header" size="lg" footer-class="d-none" scrollable>
<table class="table">
<table class="table gl-table">
<template v-if="detailsList.length">
<tr v-for="(item, index) in detailsList" :key="index">
<td>
@ -110,20 +109,22 @@ export default {
<div
v-for="(key, keyIndex) in keys"
:key="key"
class="break-word"
class="break-word gl-text-black-normal"
:class="{ 'mb-3 bold': keyIndex == 0 }"
>
{{ item[key] }}
<gl-button
v-if="keyIndex == 0 && item.backtrace"
class="btn-sm gl-ml-3"
class="gl-ml-3 button-ellipsis-horizontal"
data-testid="backtrace-expand-btn"
type="button"
category="primary"
variant="default"
icon="ellipsis_h"
size="small"
:selected="itemHasOpenedBacktrace(index)"
:aria-label="__('Toggle backtrace')"
@click="toggleBacktrace(index)"
>
<gl-icon :size="12" name="ellipsis_h" />
</gl-button>
/>
</div>
<pre v-if="itemHasOpenedBacktrace(index)" class="backtrace-row mt-2">{{
item.backtrace

View File

@ -78,6 +78,7 @@ export default {
:name="branch"
:is-checked="isSelected(branch)"
is-check-item
data-testid="dropdown-item"
@click="selectBranch(branch)"
>
{{ branch }}

View File

@ -5,7 +5,7 @@ import { deprecatedCreateFlash as Flash } from '~/flash';
import { s__, __ } from '~/locale';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import modalEventHub from '~/projects/commit/event_hub';
import { OPEN_REVERT_MODAL } from '~/projects/commit/constants';
import { OPEN_REVERT_MODAL, OPEN_CHERRY_PICK_MODAL } from '~/projects/commit/constants';
import MrWidgetAuthorTime from '../mr_widget_author_time.vue';
import statusIcon from '../mr_widget_status_icon.vue';
import eventHub from '../../event_hub';
@ -106,6 +106,9 @@ export default {
openRevertModal() {
modalEventHub.$emit(OPEN_REVERT_MODAL);
},
openCherryPickModal() {
modalEventHub.$emit(OPEN_CHERRY_PICK_MODAL);
},
},
};
</script>
@ -148,9 +151,7 @@ export default {
v-gl-tooltip.hover
:title="cherryPickTitle"
size="small"
href="#modal-cherry-pick-commit"
data-toggle="modal"
data-container="body"
@click="openCherryPickModal"
>
{{ cherryPickLabel }}
</gl-button>

View File

@ -18,7 +18,7 @@ export default {
},
i18n: {
failedMessage: s__(
`mrWidget|The pipeline for this merge request did not complete. Push a new commit to fix the failure or check the %{linkStart}troubleshooting documentation%{linkEnd} to see other possible actions.`,
`mrWidget|The pipeline for this merge request did not complete. Push a new commit to fix the failure, or check the %{linkStart}troubleshooting documentation%{linkEnd} to see other possible actions.`,
),
},
};

View File

@ -143,3 +143,17 @@
flex-direction: column !important;
}
}
// Will be moved to @gitlab/ui in https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1165
.gl-xs-mb-4 {
@media (max-width: $breakpoint-sm) {
margin-bottom: $gl-spacing-scale-4;
}
}
// Same as above
.gl-xs-mb-4\! {
@media (max-width: $breakpoint-sm) {
margin-bottom: $gl-spacing-scale-4 !important;
}
}

View File

@ -1,35 +1,24 @@
- case type.to_s
- when 'revert'
- label = s_('ChangeTypeAction|Revert')
- branch_label = s_('ChangeTypeActionLabel|Revert in branch')
- revert_merge_request = _('Revert this merge request')
- revert_commit = _('Revert this commit')
- description = s_('ChangeTypeAction|This will create a new commit in order to revert the existing changes.')
- title = commit.merged_merge_request(current_user) ? revert_merge_request : revert_commit
- if defined?(pajamas)
.js-revert-commit-modal{ data: { title: title,
endpoint: revert_namespace_project_commit_path(commit, namespace_id: @project.namespace.full_path, project_id: @project),
branch: @project.default_branch,
push_code: can?(current_user, :push_code, @project).to_s,
branch_collaboration: @project.branch_allows_collaboration?(current_user, selected_branch).to_s,
existing_branch: ERB::Util.html_escape(selected_branch),
branches_endpoint: project_branches_path(@project) } }
- else
= render "projects/commit/commit_modal", title: title, type: type, commit: commit, branch_label: branch_label, description: description, label: label
.js-revert-commit-modal{ data: { title: title,
endpoint: revert_namespace_project_commit_path(commit, namespace_id: @project.namespace.full_path, project_id: @project),
branch: @project.default_branch,
push_code: can?(current_user, :push_code, @project).to_s,
branch_collaboration: @project.branch_allows_collaboration?(current_user, selected_branch).to_s,
existing_branch: ERB::Util.html_escape(selected_branch),
branches_endpoint: project_branches_path(@project) } }
- when 'cherry-pick'
- label = s_('ChangeTypeAction|Cherry-pick')
- branch_label = s_('ChangeTypeActionLabel|Pick into branch')
- title = commit.merged_merge_request(current_user) ? _('Cherry-pick this merge request') : _('Cherry-pick this commit')
- if defined?(pajamas)
.js-cherry-pick-commit-modal{ data: { title: title,
endpoint: cherry_pick_namespace_project_commit_path(commit, namespace_id: @project.namespace.full_path, project_id: @project),
branch: @project.default_branch,
push_code: can?(current_user, :push_code, @project).to_s,
branch_collaboration: @project.branch_allows_collaboration?(current_user, selected_branch).to_s,
existing_branch: ERB::Util.html_escape(selected_branch),
branches_endpoint: project_branches_path(@project) } }
- else
= render "projects/commit/commit_modal", title: title, type: type, commit: commit, branch_label: branch_label, description: description, label: label
.js-cherry-pick-commit-modal{ data: { title: title,
endpoint: cherry_pick_namespace_project_commit_path(commit, namespace_id: @project.namespace.full_path, project_id: @project),
branch: @project.default_branch,
push_code: can?(current_user, :push_code, @project).to_s,
branch_collaboration: @project.branch_allows_collaboration?(current_user, selected_branch).to_s,
existing_branch: ERB::Util.html_escape(selected_branch),
branches_endpoint: project_branches_path(@project) } }

View File

@ -1,26 +0,0 @@
.modal{ id: "modal-#{type}-commit", tabindex: -1 }
.modal-dialog
.modal-content
.modal-header
%h3.page-title= title
%button.close{ type: "button", "data-dismiss": "modal", "aria-label" => _('Close') }
%span{ "aria-hidden": true } &times;
.modal-body
- if description
%p= description
= form_tag [type.underscore, @project, commit], method: :post, remote: false, class: "js-#{type}-form js-requires-input" do
.form-group.branch
= label_tag 'start_branch', branch_label, class: 'label-bold'
= hidden_field_tag :start_branch, @project.default_branch, id: 'start_branch'
= dropdown_tag(@project.default_branch, options: { title: s_("BranchSwitcherTitle|Switch branch"), filter: true, placeholder: s_("BranchSwitcherPlaceholder|Search branches"), toggle_class: 'js-project-refs-dropdown dynamic', dropdown_class: 'dropdown-menu-selectable', data: { field_name: "start_branch", selected: @project.default_branch, start_branch: @project.default_branch, refs_url: project_branches_path(@project), submit_form_on_click: false } })
- if can?(current_user, :push_code, @project)
= render 'shared/new_merge_request_checkbox'
- else
= hidden_field_tag 'create_merge_request', 1, id: nil
.form-actions
= submit_tag label, class: 'gl-button btn btn-success'
= link_to _("Cancel"), '#', class: "gl-button btn btn-cancel", "data-dismiss" => "modal"
= render 'shared/projects/edit_information'

View File

@ -6,5 +6,5 @@
= render 'projects/commit/pipelines_list', endpoint: pipelines_project_commit_path(@project, @commit.id)
- if can_collaborate_with_project?(@project)
= render "projects/commit/change", type: 'revert', commit: @commit, pajamas: true
= render "projects/commit/change", type: 'cherry-pick', commit: @commit, pajamas: true
= render "projects/commit/change", type: 'revert', commit: @commit
= render "projects/commit/change", type: 'cherry-pick', commit: @commit

View File

@ -17,5 +17,5 @@
.limited-width-notes
= render "shared/notes/notes_with_form", :autocomplete => true
- if can_collaborate_with_project?(@project)
= render "projects/commit/change", type: 'revert', commit: @commit, pajamas: true
= render "projects/commit/change", type: 'cherry-pick', commit: @commit, pajamas: true
= render "projects/commit/change", type: 'revert', commit: @commit
= render "projects/commit/change", type: 'cherry-pick', commit: @commit

View File

@ -103,8 +103,8 @@
= render 'shared/issuable/sidebar', issuable_sidebar: @issuable_sidebar, assignees: @merge_request.assignees, reviewers: @merge_request.reviewers, source_branch: @merge_request.source_branch
- if @merge_request.can_be_reverted?(current_user)
= render "projects/commit/change", type: 'revert', commit: @merge_request.merge_commit, pajamas: true
= render "projects/commit/change", type: 'revert', commit: @merge_request.merge_commit
- if @merge_request.can_be_cherry_picked?
= render "projects/commit/change", type: 'cherry-pick', commit: @merge_request.merge_commit, title: @merge_request.title
= render "projects/commit/change", type: 'cherry-pick', commit: @merge_request.merge_commit
#js-review-bar

View File

@ -1,4 +1,4 @@
- if @merge_request.can_be_reverted?(current_user)
= render "projects/commit/change", type: 'revert', commit: @merge_request.merge_commit, pajamas: true
= render "projects/commit/change", type: 'revert', commit: @merge_request.merge_commit
- if @merge_request.can_be_cherry_picked?
= render "projects/commit/change", type: 'cherry-pick', commit: @merge_request.merge_commit, title: @merge_request.title
= render "projects/commit/change", type: 'cherry-pick', commit: @merge_request.merge_commit

View File

@ -0,0 +1,5 @@
---
title: "[MR Page] Migrate to GlModal for Cherry-pick MR"
merge_request: 53169
author:
type: other

View File

@ -0,0 +1,5 @@
---
title: Migrate project settings to use GlToggle
merge_request: 52729
author:
type: changed

View File

@ -0,0 +1,5 @@
---
title: Update table and ellipsis button in performance bar metrics modal
merge_request: 52762
author: Yogi (@yo)
type: other

View File

@ -632,6 +632,25 @@ for redundancy.
The current version of the build images can be found in the
["Used by GitLab section"](https://gitlab.com/gitlab-org/gitlab-build-images/blob/master/.gitlab-ci.yml).
### Dependency Proxy
Some of the jobs are using images from Docker Hub, where we also use
`${GITLAB_DEPENDENCY_PROXY}` as a prefix to the image path, so that we pull
images from our [Dependency Proxy](../user/packages/dependency_proxy/index.md).
`${GITLAB_DEPENDENCY_PROXY}` is a group variable defined in
[`gitlab-org`](https://gitlab.com/gitlab-org) as
`${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/`. This means when we use an image
defined as:
```yaml
image: ${GITLAB_DEPENDENCY_PROXY}alpine:edge
```
Projects in the `gitlab-org` group pull from the Dependency Proxy, while
forks that reside on any other personal namespaces or groups fall back to
Docker Hub unless `${GITLAB_DEPENDENCY_PROXY}` is also defined there.
### Default variables
In addition to the [predefined variables](../ci/variables/predefined_variables.md),

View File

@ -9,9 +9,8 @@ info: To determine the technical writer assigned to the Stage/Group associated w
WARNING:
This [Closed Beta](https://about.gitlab.com/handbook/product/gitlab-the-product/#sts=Closed%20Beta) feature is being re-evaluated in favor of a different
[identity model](https://gitlab.com/groups/gitlab-org/-/epics/4345) that does not require separate accounts.
We recommend that group owners who haven't yet implemented this feature wait for
the new solution.
[approach](https://gitlab.com/groups/gitlab-org/-/epics/4786) that aligns more closely with our [Subscription Agreement](https://about.gitlab.com/handbook/legal/subscription-agreement/).
We recommend that group owners who haven't yet implemented this feature wait for the new solution.
> - [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/709) in GitLab 12.1.
> - It's deployed behind a feature flag, disabled by default.

View File

@ -4734,12 +4734,6 @@ msgstr ""
msgid "Branch not loaded - %{branchId}"
msgstr ""
msgid "BranchSwitcherPlaceholder|Search branches"
msgstr ""
msgid "BranchSwitcherTitle|Switch branch"
msgstr ""
msgid "Branches"
msgstr ""
@ -5037,6 +5031,26 @@ msgstr ""
msgid "CI/CD settings"
msgstr ""
msgid "CICDAnalytics|%{percent}%{percentSymbol}"
msgstr ""
msgid "CICDAnalytics|All time"
msgstr ""
msgid "CICDAnalytics|Projects with releases"
msgstr ""
msgid "CICDAnalytics|Release"
msgid_plural "CICDAnalytics|Releases"
msgstr[0] ""
msgstr[1] ""
msgid "CICDAnalytics|Releases"
msgstr ""
msgid "CICDAnalytics|Something went wrong while fetching release statistics"
msgstr ""
msgid "CICD|Add a %{base_domain_link_start}base domain%{link_end} to your %{kubernetes_cluster_link_start}Kubernetes cluster%{link_end} for your deployment strategy to work."
msgstr ""
@ -5325,12 +5339,6 @@ msgstr ""
msgid "ChangeReviewer|Unassigned"
msgstr ""
msgid "ChangeTypeActionLabel|Pick into branch"
msgstr ""
msgid "ChangeTypeActionLabel|Revert in branch"
msgstr ""
msgid "ChangeTypeAction|A new branch will be created in your fork and a new merge request will be started."
msgstr ""
@ -34848,7 +34856,7 @@ msgstr ""
msgid "mrWidget|The changes will be merged into"
msgstr ""
msgid "mrWidget|The pipeline for this merge request did not complete. Push a new commit to fix the failure or check the %{linkStart}troubleshooting documentation%{linkEnd} to see other possible actions."
msgid "mrWidget|The pipeline for this merge request did not complete. Push a new commit to fix the failure, or check the %{linkStart}troubleshooting documentation%{linkEnd} to see other possible actions."
msgstr ""
msgid "mrWidget|The source branch HEAD has recently changed. Please reload the page and review the changes before merging"

View File

@ -26,7 +26,7 @@ module QA
Flow::Login.sign_in
end
it 'pushes code to the repository via SSH', :smoke, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/969' do
it 'pushes code to the repository via SSH', :smoke, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1678' do
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
push.ssh_key = @key
@ -41,7 +41,8 @@ module QA
end
end
it 'pushes multiple branches and tags together', :smoke, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/970' do
it 'pushes multiple branches and tags together', :smoke, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1679
' do
branches = []
tags = []
Git::Repository.perform do |repository|

View File

@ -57,7 +57,7 @@ RSpec.describe 'Merge request > User merges only if pipeline succeeds', :js do
wait_for_requests
expect(page).to have_css('button[disabled="disabled"]', text: 'Merge')
expect(page).to have_content('The pipeline for this merge request did not complete. Push a new commit to fix the failure or check the troubleshooting documentation to see other possible actions.')
expect(page).to have_content('The pipeline for this merge request did not complete. Push a new commit to fix the failure, or check the troubleshooting documentation to see other possible actions.')
end
end
@ -70,7 +70,7 @@ RSpec.describe 'Merge request > User merges only if pipeline succeeds', :js do
wait_for_requests
expect(page).not_to have_button 'Merge'
expect(page).to have_content('The pipeline for this merge request did not complete. Push a new commit to fix the failure or check the troubleshooting documentation to see other possible actions.')
expect(page).to have_content('The pipeline for this merge request did not complete. Push a new commit to fix the failure, or check the troubleshooting documentation to see other possible actions.')
end
end

View File

@ -32,7 +32,7 @@ RSpec.describe 'Merge request > User cherry-picks', :js do
it 'does not show a Cherry-pick button' do
visit project_merge_request_path(project, merge_request)
expect(page).not_to have_link 'Cherry-pick'
expect(page).not_to have_button 'Cherry-pick'
end
end
@ -40,7 +40,7 @@ RSpec.describe 'Merge request > User cherry-picks', :js do
it 'shows a Cherry-pick button' do
visit project_merge_request_path(project, merge_request)
expect(page).to have_link 'Cherry-pick'
expect(page).to have_button 'Cherry-pick'
end
it 'hides the cherry pick button for an archived project' do
@ -48,7 +48,7 @@ RSpec.describe 'Merge request > User cherry-picks', :js do
visit project_merge_request_path(project, merge_request)
expect(page).not_to have_link 'Cherry-pick'
expect(page).not_to have_button 'Cherry-pick'
end
end
@ -56,18 +56,12 @@ RSpec.describe 'Merge request > User cherry-picks', :js do
before do
visit project_merge_request_path(project, merge_request)
click_link('Cherry-pick')
click_button('Cherry-pick')
end
it 'shows the cherry-pick modal' do
expect(page).to have_content('Cherry-pick this merge request')
end
it 'closes the cherry-pick modal with escape keypress' do
find('#modal-cherry-pick-commit').send_keys(:escape)
expect(page).not_to have_content('Start a new merge request with these changes')
end
end
end
end

View File

@ -77,15 +77,26 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
end
it 'allows me to merge, see cherry-pick modal and load branches list', :sidekiq_might_not_need_inline do
modal_selector = '[data-testid="modal-commit"]'
wait_for_requests
click_button 'Merge'
wait_for_requests
click_link 'Cherry-pick'
page.find('.js-project-refs-dropdown').click
wait_for_requests
expect(page.all('.js-cherry-pick-form .dropdown-content li').size).to be > 1
click_button 'Cherry-pick'
page.within(modal_selector) do
click_button 'master'
end
page.within("#{modal_selector} .dropdown-menu") do
find('[data-testid="dropdown-search-box"]').set('')
wait_for_requests
expect(page.all('[data-testid="dropdown-item"]').size).to be > 1
end
end
end

View File

@ -187,7 +187,7 @@ RSpec.describe 'Edit Project Settings' do
click_button "Save changes"
end
expect(find(".sharing-permissions")).to have_selector(".project-feature-toggle.is-disabled", count: 4)
expect(find(".sharing-permissions")).to have_selector(".gl-toggle.is-disabled", minimum: 4)
end
it "shows empty features project homepage" do
@ -282,10 +282,10 @@ RSpec.describe 'Edit Project Settings' do
end
def toggle_feature_off(feature_name)
find(".project-feature-controls[data-for=\"#{feature_name}\"] .project-feature-toggle.is-checked").click
find(".project-feature-controls[data-for=\"#{feature_name}\"] .gl-toggle.is-checked").click
end
def toggle_feature_on(feature_name)
find(".project-feature-controls[data-for=\"#{feature_name}\"] .project-feature-toggle:not(.is-checked)").click
find(".project-feature-controls[data-for=\"#{feature_name}\"] .gl-toggle:not(.is-checked)").click
end
end

View File

@ -39,7 +39,7 @@ RSpec.describe 'Projects settings' do
visit edit_project_path(project)
forking_enabled_input = find('input[name="project[project_feature_attributes][forking_access_level]"]', visible: :hidden)
forking_enabled_button = find('input[name="project[project_feature_attributes][forking_access_level]"] + label > button')
forking_enabled_button = find('[data-for="project[project_feature_attributes][forking_access_level]"] .gl-toggle')
expect(forking_enabled_input.value).to eq('20')

View File

@ -51,7 +51,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do
expect(page).to have_content 'All discussions must be resolved'
within('.sharing-permissions-form') do
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click
find('input[value="Save changes"]').send_keys(:return)
end
@ -71,7 +71,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do
expect(page).to have_content 'All discussions must be resolved'
within('.sharing-permissions-form') do
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .gl-toggle').click
find('input[value="Save changes"]').send_keys(:return)
end
@ -92,7 +92,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do
expect(page).not_to have_content 'All discussions must be resolved'
within('.sharing-permissions-form') do
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click
find('input[value="Save changes"]').send_keys(:return)
end

View File

@ -30,7 +30,7 @@ RSpec.describe 'Projects > Settings > Visibility settings', :js do
context 'merge requests select' do
it 'hides merge requests section' do
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click
expect(page).to have_selector('.merge-requests-feature', visible: false)
end
@ -46,7 +46,7 @@ RSpec.describe 'Projects > Settings > Visibility settings', :js do
context 'builds select' do
it 'hides builds select section' do
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .gl-toggle').click
expect(page).to have_selector('.builds-feature', visible: false)
end

View File

@ -1,7 +1,6 @@
import { mount, shallowMount } from '@vue/test-utils';
import projectFeatureSetting from '~/pages/projects/shared/permissions/components/project_feature_setting.vue';
import projectFeatureToggle from '~/vue_shared/components/toggle_button.vue';
import { GlToggle } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import ProjectFeatureSetting from '~/pages/projects/shared/permissions/components/project_feature_setting.vue';
describe('Project Feature Settings', () => {
const defaultProps = {
@ -19,81 +18,76 @@ describe('Project Feature Settings', () => {
};
let wrapper;
const mountComponent = (customProps) => {
const propsData = { ...defaultProps, ...customProps };
return shallowMount(projectFeatureSetting, { propsData });
};
const findHiddenInput = () => wrapper.find(`input[name=${defaultProps.name}]`);
const findToggle = () => wrapper.findComponent(GlToggle);
beforeEach(() => {
wrapper = mountComponent();
});
const mountComponent = (customProps = {}) =>
shallowMount(ProjectFeatureSetting, {
propsData: {
...defaultProps,
...customProps,
},
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
describe('Hidden name input', () => {
it('should set the hidden name input if the name exists', () => {
expect(wrapper.find(`input[name=${defaultProps.name}]`).attributes().value).toBe('1');
wrapper = mountComponent();
expect(findHiddenInput().attributes('value')).toBe('1');
});
it('should not set the hidden name input if the name does not exist', () => {
wrapper.setProps({ name: null });
wrapper = mountComponent({ name: null });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find(`input[name=${defaultProps.name}]`).exists()).toBe(false);
});
expect(findHiddenInput().exists()).toBe(false);
});
});
describe('Feature toggle', () => {
it('should be hidden if "showToggle" is passed false', async () => {
wrapper.setProps({ showToggle: false });
it('should be hidden if "showToggle" is passed false', () => {
wrapper = mountComponent({ showToggle: false });
await wrapper.vm.$nextTick();
expect(wrapper.find(projectFeatureToggle).element).toBeUndefined();
expect(findToggle().exists()).toBe(false);
});
it('should enable the feature toggle if the value is not 0', () => {
expect(wrapper.find(projectFeatureToggle).props().value).toBe(true);
wrapper = mountComponent();
expect(findToggle().props('value')).toBe(true);
});
it('should enable the feature toggle if the value is less than 0', () => {
wrapper.setProps({ value: -1 });
wrapper = mountComponent({ value: -1 });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find(projectFeatureToggle).props().value).toBe(true);
});
expect(findToggle().props('value')).toBe(true);
});
it('should disable the feature toggle if the value is 0', () => {
wrapper.setProps({ value: 0 });
wrapper = mountComponent({ value: 0 });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find(projectFeatureToggle).props().value).toBe(false);
});
expect(findToggle().props('value')).toBe(false);
});
it('should disable the feature toggle if disabledInput is set', () => {
wrapper.setProps({ disabledInput: true });
wrapper = mountComponent({ disabledInput: true });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find(projectFeatureToggle).props().disabledInput).toBe(true);
});
expect(findToggle().props('disabled')).toBe(true);
});
it('should emit a change event when the feature toggle changes', () => {
// Needs to be fully mounted to be able to trigger the click event on the internal button
wrapper = mount(projectFeatureSetting, { propsData: defaultProps });
wrapper = mountComponent({ propsData: defaultProps });
expect(wrapper.emitted().change).toBeUndefined();
wrapper.find(projectFeatureToggle).find('button').trigger('click');
expect(wrapper.emitted('change')).toBeUndefined();
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().change.length).toBe(1);
expect(wrapper.emitted().change[0]).toEqual([0]);
});
findToggle().vm.$emit('change', false);
expect(wrapper.emitted('change')).toHaveLength(1);
expect(wrapper.emitted('change')[0]).toEqual([0]);
});
});
@ -108,26 +102,23 @@ describe('Project Feature Settings', () => {
`(
'should set disabled to $isDisabled when disabledInput is $disabledInput, the value is $value and options are $options',
({ disabledInput, value, options, isDisabled }) => {
wrapper.setProps({ disabledInput, value, options });
wrapper = mountComponent({ disabledInput, value, options });
return wrapper.vm.$nextTick(() => {
if (isDisabled) {
expect(wrapper.find('select').attributes().disabled).toEqual('disabled');
} else {
expect(wrapper.find('select').attributes().disabled).toBeUndefined();
}
});
const expected = isDisabled ? 'disabled' : undefined;
expect(wrapper.find('select').attributes('disabled')).toBe(expected);
},
);
it('should emit the change when a new option is selected', () => {
expect(wrapper.emitted().change).toBeUndefined();
wrapper = mountComponent();
expect(wrapper.emitted('change')).toBeUndefined();
wrapper.findAll('option').at(1).trigger('change');
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().change.length).toBe(1);
expect(wrapper.emitted().change[0]).toEqual([2]);
});
expect(wrapper.emitted('change')).toHaveLength(1);
expect(wrapper.emitted('change')[0]).toEqual([2]);
});
});
});

View File

@ -1,5 +1,5 @@
import { GlToggle } from '@gitlab/ui';
import { shallowMount, mount } from '@vue/test-utils';
import settingsPanel from '~/pages/projects/shared/permissions/components/settings_panel.vue';
import {
featureAccessLevel,
@ -7,7 +7,6 @@ import {
visibilityOptions,
} from '~/pages/projects/shared/permissions/constants';
import projectFeatureSetting from '~/pages/projects/shared/permissions/components/project_feature_setting.vue';
import projectFeatureToggle from '~/vue_shared/components/toggle_button.vue';
const defaultProps = {
currentSettings: {
@ -69,57 +68,61 @@ describe('Settings Panel', () => {
});
};
const overrideCurrentSettings = (
currentSettingsProps,
extraProps = {},
mountFn = shallowMount,
) => {
return mountComponent({ ...extraProps, currentSettings: currentSettingsProps }, mountFn);
};
const findLFSSettingsRow = () => wrapper.find({ ref: 'git-lfs-settings' });
const findLFSSettingsMessage = () => findLFSSettingsRow().find('p');
const findLFSFeatureToggle = () => findLFSSettingsRow().find(projectFeatureToggle);
const findLFSFeatureToggle = () => findLFSSettingsRow().find(GlToggle);
const findRepositoryFeatureProjectRow = () => wrapper.find({ ref: 'repository-settings' });
const findRepositoryFeatureSetting = () =>
findRepositoryFeatureProjectRow().find(projectFeatureSetting);
const findProjectVisibilitySettings = () => wrapper.find({ ref: 'project-visibility-settings' });
const findAnalyticsRow = () => wrapper.find({ ref: 'analytics-settings' });
beforeEach(() => {
wrapper = mountComponent();
});
const findProjectVisibilityLevelInput = () => wrapper.find('[name="project[visibility_level]"]');
const findRequestAccessEnabledInput = () =>
wrapper.find('[name="project[request_access_enabled]"]');
const findMergeRequestsAccessLevelInput = () =>
wrapper.find('[name="project[project_feature_attributes][merge_requests_access_level]"]');
const findForkingAccessLevelInput = () =>
wrapper.find('[name="project[project_feature_attributes][forking_access_level]"]');
const findBuildsAccessLevelInput = () =>
wrapper.find('[name="project[project_feature_attributes][builds_access_level]"]');
const findContainerRegistrySettings = () => wrapper.find({ ref: 'container-registry-settings' });
const findContainerRegistryEnabledInput = () =>
wrapper.find('[name="project[container_registry_enabled]"]');
const findPackageSettings = () => wrapper.find({ ref: 'package-settings' });
const findPackagesEnabledInput = () => wrapper.find('[name="project[packages_enabled]"]');
const findPagesSettings = () => wrapper.find({ ref: 'pages-settings' });
const findEmailSettings = () => wrapper.find({ ref: 'email-settings' });
const findShowDefaultAwardEmojis = () =>
wrapper.find('input[name="project[project_setting_attributes][show_default_award_emojis]"]');
const findMetricsVisibilitySettings = () => wrapper.find({ ref: 'metrics-visibility-settings' });
const findAllowEditingCommitMessages = () =>
wrapper.find({ ref: 'allow-editing-commit-messages' }).exists();
const findOperationsSettings = () => wrapper.find({ ref: 'operations-settings' });
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
describe('Project Visibility', () => {
it('should set the project visibility help path', () => {
expect(wrapper.find({ ref: 'project-visibility-settings' }).props().helpPath).toBe(
wrapper = mountComponent();
expect(findProjectVisibilitySettings().props('helpPath')).toBe(
defaultProps.visibilityHelpPath,
);
});
it('should not disable the visibility level dropdown', () => {
wrapper.setProps({ canChangeVisibilityLevel: true });
wrapper = mountComponent({ canChangeVisibilityLevel: true });
return wrapper.vm.$nextTick(() => {
expect(
wrapper.find('[name="project[visibility_level]"]').attributes().disabled,
).toBeUndefined();
});
expect(findProjectVisibilityLevelInput().attributes('disabled')).toBeUndefined();
});
it('should disable the visibility level dropdown', () => {
wrapper.setProps({ canChangeVisibilityLevel: false });
wrapper = mountComponent({ canChangeVisibilityLevel: false });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find('[name="project[visibility_level]"]').attributes().disabled).toBe(
'disabled',
);
});
expect(findProjectVisibilityLevelInput().attributes('disabled')).toBe('disabled');
});
it.each`
@ -133,56 +136,56 @@ describe('Settings Panel', () => {
`(
'sets disabled to $disabled for the visibility option $option when given $allowedOptions',
({ option, allowedOptions, disabled }) => {
wrapper.setProps({ allowedVisibilityOptions: allowedOptions });
wrapper = mountComponent({ allowedVisibilityOptions: allowedOptions });
return wrapper.vm.$nextTick(() => {
const attributeValue = wrapper
.find(`[name="project[visibility_level]"] option[value="${option}"]`)
.attributes().disabled;
const attributeValue = findProjectVisibilityLevelInput()
.find(`option[value="${option}"]`)
.attributes('disabled');
if (disabled) {
expect(attributeValue).toBe('disabled');
} else {
expect(attributeValue).toBeUndefined();
}
});
const expected = disabled ? 'disabled' : undefined;
expect(attributeValue).toBe(expected);
},
);
it('should set the visibility level description based upon the selected visibility level', () => {
wrapper.find('[name="project[visibility_level]"]').setValue(visibilityOptions.INTERNAL);
wrapper = mountComponent();
expect(wrapper.find({ ref: 'project-visibility-settings' }).text()).toContain(
findProjectVisibilityLevelInput().setValue(visibilityOptions.INTERNAL);
expect(findProjectVisibilitySettings().text()).toContain(
visibilityLevelDescriptions[visibilityOptions.INTERNAL],
);
});
it('should show the request access checkbox if the visibility level is not private', () => {
wrapper = overrideCurrentSettings({ visibilityLevel: visibilityOptions.INTERNAL });
wrapper = mountComponent({
currentSettings: { visibilityLevel: visibilityOptions.INTERNAL },
});
expect(wrapper.find('[name="project[request_access_enabled]"]').exists()).toBe(true);
expect(findRequestAccessEnabledInput().exists()).toBe(true);
});
it('should not show the request access checkbox if the visibility level is private', () => {
wrapper = overrideCurrentSettings({ visibilityLevel: visibilityOptions.PRIVATE });
wrapper = mountComponent({ currentSettings: { visibilityLevel: visibilityOptions.PRIVATE } });
expect(wrapper.find('[name="project[request_access_enabled]"]').exists()).toBe(false);
expect(findRequestAccessEnabledInput().exists()).toBe(false);
});
});
describe('Repository', () => {
it('should set the repository help text when the visibility level is set to private', () => {
wrapper = overrideCurrentSettings({ visibilityLevel: visibilityOptions.PRIVATE });
wrapper = mountComponent({ currentSettings: { visibilityLevel: visibilityOptions.PRIVATE } });
expect(findRepositoryFeatureProjectRow().props().helpText).toBe(
expect(findRepositoryFeatureProjectRow().props('helpText')).toBe(
'View and edit files in this project.',
);
});
it('should set the repository help text with a read access warning when the visibility level is set to non-private', () => {
wrapper = overrideCurrentSettings({ visibilityLevel: visibilityOptions.PUBLIC });
wrapper = mountComponent({ currentSettings: { visibilityLevel: visibilityOptions.PUBLIC } });
expect(findRepositoryFeatureProjectRow().props().helpText).toBe(
expect(findRepositoryFeatureProjectRow().props('helpText')).toBe(
'View and edit files in this project. Non-project members will only have read access.',
);
});
@ -190,175 +193,152 @@ describe('Settings Panel', () => {
describe('Merge requests', () => {
it('should enable the merge requests access level input when the repository is enabled', () => {
wrapper = overrideCurrentSettings({ repositoryAccessLevel: featureAccessLevel.EVERYONE });
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.EVERYONE },
});
expect(
wrapper
.find('[name="project[project_feature_attributes][merge_requests_access_level]"]')
.props().disabledInput,
).toBe(false);
expect(findMergeRequestsAccessLevelInput().props('disabledInput')).toBe(false);
});
it('should disable the merge requests access level input when the repository is disabled', () => {
wrapper = overrideCurrentSettings({ repositoryAccessLevel: featureAccessLevel.NOT_ENABLED });
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.NOT_ENABLED },
});
expect(
wrapper
.find('[name="project[project_feature_attributes][merge_requests_access_level]"]')
.props().disabledInput,
).toBe(true);
expect(findMergeRequestsAccessLevelInput().props('disabledInput')).toBe(true);
});
});
describe('Forks', () => {
it('should enable the forking access level input when the repository is enabled', () => {
wrapper = overrideCurrentSettings({ repositoryAccessLevel: featureAccessLevel.EVERYONE });
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.EVERYONE },
});
expect(
wrapper.find('[name="project[project_feature_attributes][forking_access_level]"]').props()
.disabledInput,
).toBe(false);
expect(findForkingAccessLevelInput().props('disabledInput')).toBe(false);
});
it('should disable the forking access level input when the repository is disabled', () => {
wrapper = overrideCurrentSettings({ repositoryAccessLevel: featureAccessLevel.NOT_ENABLED });
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.NOT_ENABLED },
});
expect(
wrapper.find('[name="project[project_feature_attributes][forking_access_level]"]').props()
.disabledInput,
).toBe(true);
expect(findForkingAccessLevelInput().props('disabledInput')).toBe(true);
});
});
describe('Pipelines', () => {
it('should enable the builds access level input when the repository is enabled', () => {
wrapper = overrideCurrentSettings({ repositoryAccessLevel: featureAccessLevel.EVERYONE });
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.EVERYONE },
});
expect(
wrapper.find('[name="project[project_feature_attributes][builds_access_level]"]').props()
.disabledInput,
).toBe(false);
expect(findBuildsAccessLevelInput().props('disabledInput')).toBe(false);
});
it('should disable the builds access level input when the repository is disabled', () => {
wrapper = overrideCurrentSettings({ repositoryAccessLevel: featureAccessLevel.NOT_ENABLED });
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.NOT_ENABLED },
});
expect(
wrapper.find('[name="project[project_feature_attributes][builds_access_level]"]').props()
.disabledInput,
).toBe(true);
expect(findBuildsAccessLevelInput().props('disabledInput')).toBe(true);
});
});
describe('Container registry', () => {
it('should show the container registry settings if the registry is available', () => {
wrapper.setProps({ registryAvailable: true });
wrapper = mountComponent({ registryAvailable: true });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ ref: 'container-registry-settings' }).exists()).toBe(true);
});
expect(findContainerRegistrySettings().exists()).toBe(true);
});
it('should hide the container registry settings if the registry is not available', () => {
wrapper.setProps({ registryAvailable: false });
wrapper = mountComponent({ registryAvailable: false });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ ref: 'container-registry-settings' }).exists()).toBe(false);
});
expect(findContainerRegistrySettings().exists()).toBe(false);
});
it('should set the container registry settings help path', () => {
wrapper.setProps({ registryAvailable: true });
wrapper = mountComponent({ registryAvailable: true });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ ref: 'container-registry-settings' }).props().helpPath).toBe(
defaultProps.registryHelpPath,
);
});
expect(findContainerRegistrySettings().props('helpPath')).toBe(defaultProps.registryHelpPath);
});
it('should show the container registry public note if the visibility level is public and the registry is available', () => {
wrapper = overrideCurrentSettings(
{ visibilityLevel: visibilityOptions.PUBLIC },
{ registryAvailable: true },
);
wrapper = mountComponent({
currentSettings: { visibilityLevel: visibilityOptions.PUBLIC },
registryAvailable: true,
});
expect(wrapper.find({ ref: 'container-registry-settings' }).text()).toContain(
expect(findContainerRegistrySettings().text()).toContain(
'Note: the container registry is always visible when a project is public',
);
});
it('should hide the container registry public note if the visibility level is private and the registry is available', () => {
wrapper = overrideCurrentSettings(
{ visibilityLevel: visibilityOptions.PRIVATE },
{ registryAvailable: true },
);
wrapper = mountComponent({
currentSettings: { visibilityLevel: visibilityOptions.PRIVATE },
registryAvailable: true,
});
expect(wrapper.find({ ref: 'container-registry-settings' }).text()).not.toContain(
expect(findContainerRegistrySettings().text()).not.toContain(
'Note: the container registry is always visible when a project is public',
);
});
it('should enable the container registry input when the repository is enabled', () => {
wrapper = overrideCurrentSettings(
{ repositoryAccessLevel: featureAccessLevel.EVERYONE },
{ registryAvailable: true },
);
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.EVERYONE },
registryAvailable: true,
});
expect(
wrapper.find('[name="project[container_registry_enabled]"]').props().disabledInput,
).toBe(false);
expect(findContainerRegistryEnabledInput().props('disabled')).toBe(false);
});
it('should disable the container registry input when the repository is disabled', () => {
wrapper = overrideCurrentSettings(
{ repositoryAccessLevel: featureAccessLevel.NOT_ENABLED },
{ registryAvailable: true },
);
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.NOT_ENABLED },
registryAvailable: true,
});
expect(
wrapper.find('[name="project[container_registry_enabled]"]').props().disabledInput,
).toBe(true);
expect(findContainerRegistryEnabledInput().props('disabled')).toBe(true);
});
});
describe('Git Large File Storage', () => {
it('should show the LFS settings if LFS is available', () => {
wrapper.setProps({ lfsAvailable: true });
wrapper = mountComponent({ lfsAvailable: true });
return wrapper.vm.$nextTick(() => {
expect(findLFSSettingsRow().exists()).toBe(true);
});
expect(findLFSSettingsRow().exists()).toBe(true);
});
it('should hide the LFS settings if LFS is not available', () => {
wrapper.setProps({ lfsAvailable: false });
wrapper = mountComponent({ lfsAvailable: false });
return wrapper.vm.$nextTick(() => {
expect(findLFSSettingsRow().exists()).toBe(false);
});
expect(findLFSSettingsRow().exists()).toBe(false);
});
it('should set the LFS settings help path', () => {
expect(findLFSSettingsRow().props().helpPath).toBe(defaultProps.lfsHelpPath);
wrapper = mountComponent();
expect(findLFSSettingsRow().props('helpPath')).toBe(defaultProps.lfsHelpPath);
});
it('should enable the LFS input when the repository is enabled', () => {
wrapper = overrideCurrentSettings(
{ repositoryAccessLevel: featureAccessLevel.EVERYONE },
{ lfsAvailable: true },
);
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.EVERYONE },
lfsAvailable: true,
});
expect(findLFSFeatureToggle().props().disabledInput).toBe(false);
expect(findLFSFeatureToggle().props('disabled')).toBe(false);
});
it('should disable the LFS input when the repository is disabled', () => {
wrapper = overrideCurrentSettings(
{ repositoryAccessLevel: featureAccessLevel.NOT_ENABLED },
{ lfsAvailable: true },
);
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.NOT_ENABLED },
lfsAvailable: true,
});
expect(findLFSFeatureToggle().props().disabledInput).toBe(true);
expect(findLFSFeatureToggle().props('disabled')).toBe(true);
});
it('should not change lfsEnabled when disabling the repository', async () => {
@ -373,8 +353,7 @@ describe('Settings Panel', () => {
expect(isToggleButtonChecked(lfsFeatureToggleButton)).toBe(true);
expect(isToggleButtonChecked(repositoryFeatureToggleButton)).toBe(true);
repositoryFeatureToggleButton.trigger('click');
await wrapper.vm.$nextTick();
await repositoryFeatureToggleButton.trigger('click');
expect(isToggleButtonChecked(repositoryFeatureToggleButton)).toBe(false);
// LFS toggle should still be checked
@ -418,47 +397,39 @@ describe('Settings Panel', () => {
describe('Packages', () => {
it('should show the packages settings if packages are available', () => {
wrapper.setProps({ packagesAvailable: true });
wrapper = mountComponent({ packagesAvailable: true });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ ref: 'package-settings' }).exists()).toBe(true);
});
expect(findPackageSettings().exists()).toBe(true);
});
it('should hide the packages settings if packages are not available', () => {
wrapper.setProps({ packagesAvailable: false });
wrapper = mountComponent({ packagesAvailable: false });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ ref: 'package-settings' }).exists()).toBe(false);
});
expect(findPackageSettings().exists()).toBe(false);
});
it('should set the package settings help path', () => {
wrapper.setProps({ packagesAvailable: true });
wrapper = mountComponent({ packagesAvailable: true });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ ref: 'package-settings' }).props().helpPath).toBe(
defaultProps.packagesHelpPath,
);
});
expect(findPackageSettings().props('helpPath')).toBe(defaultProps.packagesHelpPath);
});
it('should enable the packages input when the repository is enabled', () => {
wrapper = overrideCurrentSettings(
{ repositoryAccessLevel: featureAccessLevel.EVERYONE },
{ packagesAvailable: true },
);
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.EVERYONE },
packagesAvailable: true,
});
expect(wrapper.find('[name="project[packages_enabled]"]').props().disabledInput).toBe(false);
expect(findPackagesEnabledInput().props('disabled')).toBe(false);
});
it('should disable the packages input when the repository is disabled', () => {
wrapper = overrideCurrentSettings(
{ repositoryAccessLevel: featureAccessLevel.NOT_ENABLED },
{ packagesAvailable: true },
);
wrapper = mountComponent({
currentSettings: { repositoryAccessLevel: featureAccessLevel.NOT_ENABLED },
packagesAvailable: true,
});
expect(wrapper.find('[name="project[packages_enabled]"]').props().disabledInput).toBe(true);
expect(findPackagesEnabledInput().props('disabled')).toBe(true);
});
});
@ -472,78 +443,66 @@ describe('Settings Panel', () => {
`(
'should $visibility the page settings if pagesAvailable is $pagesAvailable and pagesAccessControlEnabled is $pagesAccessControlEnabled',
({ pagesAvailable, pagesAccessControlEnabled, visibility }) => {
wrapper.setProps({ pagesAvailable, pagesAccessControlEnabled });
wrapper = mountComponent({ pagesAvailable, pagesAccessControlEnabled });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ ref: 'pages-settings' }).exists()).toBe(visibility === 'show');
});
expect(findPagesSettings().exists()).toBe(visibility === 'show');
},
);
it('should set the pages settings help path', () => {
wrapper.setProps({ pagesAvailable: true, pagesAccessControlEnabled: true });
wrapper = mountComponent({ pagesAvailable: true, pagesAccessControlEnabled: true });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ ref: 'pages-settings' }).props().helpPath).toBe(
defaultProps.pagesHelpPath,
);
});
expect(findPagesSettings().props('helpPath')).toBe(defaultProps.pagesHelpPath);
});
});
describe('Email notifications', () => {
it('should show the disable email notifications input if emails an be disabled', () => {
wrapper.setProps({ canDisableEmails: true });
wrapper = mountComponent({ canDisableEmails: true });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ ref: 'email-settings' }).exists()).toBe(true);
});
expect(findEmailSettings().exists()).toBe(true);
});
it('should hide the disable email notifications input if emails cannot be disabled', () => {
wrapper.setProps({ canDisableEmails: false });
wrapper = mountComponent({ canDisableEmails: false });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ ref: 'email-settings' }).exists()).toBe(false);
});
expect(findEmailSettings().exists()).toBe(false);
});
});
describe('Default award emojis', () => {
it('should show the "Show default award emojis" input', () => {
return wrapper.vm.$nextTick(() => {
expect(
wrapper
.find('input[name="project[project_setting_attributes][show_default_award_emojis]"]')
.exists(),
).toBe(true);
});
wrapper = mountComponent();
expect(findShowDefaultAwardEmojis().exists()).toBe(true);
});
});
describe('Metrics dashboard', () => {
it('should show the metrics dashboard access toggle', () => {
return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ ref: 'metrics-visibility-settings' }).exists()).toBe(true);
});
wrapper = mountComponent();
expect(findMetricsVisibilitySettings().exists()).toBe(true);
});
it('should contain help text', () => {
expect(wrapper.find({ ref: 'metrics-visibility-settings' }).props().helpText).toBe(
wrapper = mountComponent();
expect(findMetricsVisibilitySettings().props('helpText')).toBe(
"Visualize the project's performance metrics.",
);
});
it.each`
scenario | selectedOption | selectedOptionLabel
${{ visibilityLevel: visibilityOptions.PRIVATE }} | ${String(featureAccessLevel.PROJECT_MEMBERS)} | ${'Only Project Members'}
${{ operationsAccessLevel: featureAccessLevel.NOT_ENABLED }} | ${String(featureAccessLevel.NOT_ENABLED)} | ${'Enable feature to choose access level'}
scenario | selectedOption | selectedOptionLabel
${{ currentSettings: { visibilityLevel: visibilityOptions.PRIVATE } }} | ${String(featureAccessLevel.PROJECT_MEMBERS)} | ${'Only Project Members'}
${{ currentSettings: { operationsAccessLevel: featureAccessLevel.NOT_ENABLED } }} | ${String(featureAccessLevel.NOT_ENABLED)} | ${'Enable feature to choose access level'}
`(
'should disable the metrics visibility dropdown when #scenario',
({ scenario, selectedOption, selectedOptionLabel }) => {
wrapper = overrideCurrentSettings(scenario, {}, mount);
wrapper = mountComponent(scenario, mount);
const select = wrapper.find({ ref: 'metrics-visibility-settings' }).find('select');
const select = findMetricsVisibilitySettings().find('select');
const option = select.find('option');
expect(select.attributes('disabled')).toBe('disabled');
@ -556,31 +515,29 @@ describe('Settings Panel', () => {
describe('Settings panel with feature flags', () => {
describe('Allow edit of commit message', () => {
it('should show the allow editing of commit messages checkbox', async () => {
it('should show the allow editing of commit messages checkbox', () => {
wrapper = mountComponent({
glFeatures: { allowEditingCommitMessages: true },
});
await wrapper.vm.$nextTick();
expect(wrapper.find({ ref: 'allow-editing-commit-messages' }).exists()).toBe(true);
expect(findAllowEditingCommitMessages()).toBe(true);
});
});
});
describe('Analytics', () => {
it('should show the analytics toggle', async () => {
await wrapper.vm.$nextTick();
it('should show the analytics toggle', () => {
wrapper = mountComponent();
expect(findAnalyticsRow().exists()).toBe(true);
});
});
describe('Operations', () => {
it('should show the operations toggle', async () => {
await wrapper.vm.$nextTick();
it('should show the operations toggle', () => {
wrapper = mountComponent();
expect(wrapper.find({ ref: 'operations-settings' }).exists()).toBe(true);
expect(findOperationsSettings().exists()).toBe(true);
});
});
});

View File

@ -16,7 +16,7 @@ exports[`PipelineFailed should render error message with a disabled merge button
class="bold"
>
<gl-sprintf-stub
message="The pipeline for this merge request did not complete. Push a new commit to fix the failure or check the %{linkStart}troubleshooting documentation%{linkEnd} to see other possible actions."
message="The pipeline for this merge request did not complete. Push a new commit to fix the failure, or check the %{linkStart}troubleshooting documentation%{linkEnd} to see other possible actions."
/>
</span>
</div>

View File

@ -4,7 +4,7 @@ import mountComponent from 'helpers/vue_mount_component_helper';
import mergedComponent from '~/vue_merge_request_widget/components/states/mr_widget_merged.vue';
import eventHub from '~/vue_merge_request_widget/event_hub';
import modalEventHub from '~/projects/commit/event_hub';
import { OPEN_REVERT_MODAL } from '~/projects/commit/constants';
import { OPEN_REVERT_MODAL, OPEN_CHERRY_PICK_MODAL } from '~/projects/commit/constants';
describe('MRWidgetMerged', () => {
let vm;
@ -163,6 +163,14 @@ describe('MRWidgetMerged', () => {
expect(eventHubSpy).toHaveBeenCalledWith(OPEN_REVERT_MODAL);
});
it('emits event to open the cherry-pick modal on cherry-pick button click', () => {
const eventHubSpy = jest.spyOn(modalEventHub, '$emit');
getByRole(vm.$el, 'button', { name: /Cherry-pick/i }).click();
expect(eventHubSpy).toHaveBeenCalledWith(OPEN_CHERRY_PICK_MODAL);
});
it('has merged by information', () => {
expect(vm.$el.textContent).toContain('Merged by');
expect(vm.$el.textContent).toContain('Administrator');