Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2024-02-26 09:07:12 +00:00
parent 70bdd3498f
commit c59437fc4a
25 changed files with 243 additions and 87 deletions

View File

@ -16,7 +16,6 @@ header-style: # MD003
hr-style: # MD035
style: "---"
line-length: false # MD013
link-fragments: false # MD051
no-duplicate-heading: # MD024
siblings_only: true
no-emphasis-as-heading: false # MD036

View File

@ -1,18 +1,8 @@
---
Capybara/TestidFinders:
Exclude:
- 'spec/features/merge_request/user_interacts_with_batched_mr_diffs_spec.rb'
- 'spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb'
- 'spec/features/projects/settings/registry_settings_spec.rb'
- 'spec/features/projects/show/user_sees_collaboration_links_spec.rb'
- 'spec/features/projects/sub_group_issuables_spec.rb'
- 'spec/features/projects/terraform_spec.rb'
- 'spec/features/projects/tree/create_directory_spec.rb'
- 'spec/features/projects/tree/create_file_spec.rb'
- 'spec/features/projects/work_items/work_item_children_spec.rb'
- 'spec/features/projects/work_items/work_item_spec.rb'
- 'spec/features/protected_branches_spec.rb'
- 'spec/features/runners_spec.rb'
- 'spec/features/search/user_searches_for_code_spec.rb'
- 'spec/features/search/user_searches_for_issues_spec.rb'
- 'spec/features/search/user_searches_for_merge_requests_spec.rb'

View File

@ -173,7 +173,7 @@ export default {
v-if="commit.description_html"
v-safe-html:[$options.safeHtmlConfig]="commitDescription"
:class="{ 'js-toggle-content': collapsible, 'd-block': !collapsible }"
class="commit-row-description gl-mb-3 gl-text-body gl-white-space-pre-line"
class="commit-row-description gl-mb-3 gl-text-body gl-white-space-pre-wrap"
></pre>
</div>
</li>

View File

@ -133,7 +133,7 @@ export default {
v-if="commitDescription"
v-safe-html:[$options.safeHtmlConfig]="commitDescription"
:class="{ 'gl-display-block!': showDescription }"
class="commit-row-description gl-mb-3 gl-white-space-pre-line"
class="commit-row-description gl-mb-3 gl-white-space-pre-wrap"
></pre>
</div>
<div class="gl-flex-grow-1"></div>

View File

@ -53,7 +53,7 @@
= render_if_exists 'projects/commits/project_namespace', show_project_name: show_project_name, project: project
- if commit.description?
%pre{ class: ["commit-row-description gl-mb-3 gl-white-space-pre-line", (collapsible ? "js-toggle-content" : "d-block")] }
%pre{ class: ["commit-row-description gl-mb-3 gl-white-space-pre-wrap", (collapsible ? "js-toggle-content" : "d-block")] }
= preserve(markdown_field(commit, :description))
.commit-actions.flex-row

View File

@ -3450,6 +3450,15 @@
:weight: 1
:idempotent: true
:tags: []
- :name: merge_requests_process_auto_merge_from_event
:worker_name: MergeRequests::ProcessAutoMergeFromEventWorker
:feature_category: :continuous_delivery
:has_external_dependencies: false
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent: true
:tags: []
- :name: merge_requests_resolve_todos
:worker_name: MergeRequests::ResolveTodosWorker
:feature_category: :code_review_workflow

View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
module MergeRequests
class ProcessAutoMergeFromEventWorker
include Gitlab::EventStore::Subscriber
data_consistency :always
feature_category :continuous_delivery
idempotent!
# The difference with this worker and AutoMergeProcessWorker is that this will
# handle the execution from the event store code
def handle_event(event)
merge_request_id = event.data[:merge_request_id]
merge_request = MergeRequest.find_by_id(merge_request_id)
unless merge_request
logger.info(structured_payload(message: 'Merge request not found.', merge_request_id: merge_request_id))
return
end
return unless Feature.enabled?(:merge_when_checks_pass, merge_request.project, type: :development)
AutoMergeService.new(merge_request.project, merge_request.merge_user)
.process(merge_request)
end
end
end

View File

@ -0,0 +1,8 @@
---
name: merge_when_checks_pass
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/121828
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/412995
milestone: '16.2'
type: development
group: group::code review
default_enabled: false

View File

@ -479,6 +479,8 @@
- 1
- - merge_requests_process_approval_auto_merge
- 1
- - merge_requests_process_auto_merge_from_event
- 1
- - merge_requests_remove_user_approval_rules
- 1
- - merge_requests_resolve_todos

View File

@ -731,12 +731,25 @@ We want to avoid introducing a changelog when features are not accessible by an
Use the flowchart to determine the changelog entry type.
```mermaid
graph LR
A[flag: default off] -->|'added' / 'changed' / 'fixed' / '...'| B(flag: default on)
B -->|'other'| C(remove flag, keep new code)
B -->|'removed' / 'changed'| D(remove flag, keep old code)
A -->|'added' / 'changed' / 'fixed' / '...'| C
A -->|no changelog| D
flowchart LR
FDOFF(Flag is currently\n`default: off`)
FDON(Flag is currently\n`default: on`)
CDO{Change to\n`default: on`}
ACF(added / changed / fixed / '...')
RF{Remove flag}
RF2{Remove flag}
NC(No changelog)
RC(removed / changed)
OTHER(other)
FDOFF -->CDO-->ACF
FDOFF -->RF
RF-->|Keep new code?| ACF
RF-->|Keep old code?| NC
FDON -->RF2
RF2-->|Keep old code?| RC
RF2-->|Keep new code?| OTHER
```
- The changelog for a feature flag should describe the feature and not the

View File

@ -246,7 +246,7 @@ The following Elasticsearch settings are available:
| `Pause Elasticsearch indexing` | Enables or disables temporary indexing pause. This is useful for cluster migration/reindexing. All changes are still tracked, but they are not committed to the Elasticsearch index until resumed. |
| `Search with Elasticsearch enabled` | Enables or disables using Elasticsearch in search. |
| `Requeue indexing workers` | Enable automatic requeuing of indexing workers. This improves non-code indexing throughput by enqueuing Sidekiq jobs until all documents are processed. Requeuing indexing workers is not recommended for smaller instances or instances with few Sidekiq processes. |
| `URL` | The URL of your Elasticsearch instance. Use a comma-separated list to support clustering (for example, `http://host1, https://host2:9200`). If your Elasticsearch instance is password-protected, use the `Username` and `Password` fields described below. Alternatively, use inline credentials such as `http://<username>:<password>@<elastic_host>:9200/`. |
| `URL` | The URL of your Elasticsearch instance. Use a comma-separated list to support clustering (for example, `http://host1, https://host2:9200`). If your Elasticsearch instance is password-protected, use the `Username` and `Password` fields. Alternatively, use inline credentials such as `http://<username>:<password>@<elastic_host>:9200/`. If you use [OpenSearch](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/vpc.html), only connections over ports `80` and `443` are accepted. |
| `Username` | The `username` of your Elasticsearch instance. |
| `Password` | The password of your Elasticsearch instance. |
| `Number of Elasticsearch shards and replicas per index` | Elasticsearch indices are split into multiple shards for performance reasons. In general, you should use at least five shards. Indices with tens of millions of documents should have more shards ([see the guidance](#guidance-on-choosing-optimal-cluster-configuration)). Changes to this value do not take effect until you re-create the index. For more information about scalability and resilience, see the [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/scalability.html). Each Elasticsearch shard can have a number of replicas. These replicas are a complete copy of the shard and can provide increased query performance or resilience against hardware failure. Increasing this value increases the total disk space required by the index. You can set the number of shards and replicas for each of the indices. |

View File

@ -19,3 +19,4 @@ and running quickly.
| <i class="fa fa-youtube-play youtube" aria-hidden="true"></i> [Learn GitLab project walkthrough](https://www.youtube.com/watch?v=-oaI2WEKdI4&list=PL05JrBw4t0KofkHq4GZJ05FnNGa11PQ4d) (59m 2s) | Step through the tutorial-style issues in the **Learn GitLab** project. If you don't have this project, download [the export file](https://gitlab.com/gitlab-org/gitlab/-/blob/master/vendor/project_templates/learn_gitlab_ultimate.tar.gz) and [import it to a new project](../user/project/settings/import_export.md#import-a-project-and-its-data). | |
| <i class="fa fa-youtube-play youtube" aria-hidden="true"></i> [GitLab Continuous Delivery overview](https://www.youtube.com/watch?v=M7rBDZYsx8U&list=PLFGfElNsQthYDx0A_FaNNfUm9NHsK6zED&index=193) (17m 2s) | Learn how to use GitLab features to continuously build, test, and deploy iterative code changes. | |
| [Productivity tips](https://about.gitlab.com/blog/2021/02/18/improve-your-gitlab-productivity-with-these-10-tips/) | Get tips to help make you a productive GitLab user. | |
| <i class="fa fa-youtube-play youtube" aria-hidden="true"></i> [Introducing GitLab Service Desk](https://www.youtube.com/watch?v=LDVQXv3I5rI) (6m 50s) | Learn how GitLab [Service Desk](../user/project/service_desk/index.md) provides an integrated help desk solution to enhance customer support workflows. This video covers key features, such as [custom email addresses](../user/project/service_desk/configure.md#custom-email-address) and [email templates](../user/project/service_desk/configure.md#customize-emails-sent-to-the-requester), ticket management, [comment templates](../user/profile/comment_templates.md), [CRM integration](../user/crm/index.md), automation using `gitlab-triage` in scheduled CI/CD pipelines, and analytics and [insights](../user/project/insights/index.md). | |

View File

@ -38,10 +38,10 @@ class StaticAnalysis
# contain values that a FOSS installation won't find. To work
# around this we will only enable this task on EE installations.
TASKS_WITH_DURATIONS_SECONDS = [
(Gitlab.ee? ? Task.new(%w[bin/rake gettext:updated_check], 360) : nil),
Task.new(%w[yarn run lint:prettier], 200),
Task.new(%w[bin/rake gettext:lint], 105),
Task.new(%W[scripts/license-check.sh #{project_path}], 200),
(Gitlab.ee? ? Task.new(%w[bin/rake gettext:updated_check], 40) : nil),
Task.new(%w[bin/rake lint:static_verification], 40),
Task.new(%w[bin/rake config_lint], 10),
Task.new(%w[bin/rake gitlab:sidekiq:all_queues_yml:check], 15),

View File

@ -15,13 +15,19 @@ RSpec.describe 'Batch diffs', :js, feature_category: :code_review_workflow do
visit diffs_project_merge_request_path(merge_request.project, merge_request)
wait_for_requests
click_diff_line(get_first_diff.find('[data-testid="left-side"]', match: :first))
within(get_first_diff) do
click_diff_line(find_by_testid('left-side', match: :first))
end
page.within get_first_diff.find('.js-discussion-note-form') do
fill_in('note_note', with: 'First Line Comment')
click_button('Add comment now')
end
click_diff_line(get_second_diff.find('[data-testid="left-side"]', match: :first))
within(get_second_diff) do
click_diff_line(find_by_testid('left-side', match: :first))
end
page.within get_second_diff.find('.js-discussion-note-form') do
fill_in('note_note', with: 'Last Line Comment')
click_button('Add comment now')

View File

@ -13,7 +13,7 @@ RSpec.describe 'Projects > Show > Collaboration links', :js, feature_category: :
end
def find_new_menu_toggle
find('[data-testid="base-dropdown-toggle"]', text: 'Create new...')
find_by_testid('base-dropdown-toggle', text: 'Create new...')
end
context 'with developer user' do
@ -39,7 +39,7 @@ RSpec.describe 'Projects > Show > Collaboration links', :js, feature_category: :
# The dropdown above the tree
page.within('.repo-breadcrumb') do
find('[data-testid="add-to-tree"]').click
find_by_testid('add-to-tree').click
aggregate_failures 'dropdown links above the repo tree' do
expect(page).to have_link('New file')

View File

@ -26,7 +26,7 @@ RSpec.describe 'Subgroup Issuables', :js, feature_category: :groups_and_projects
end
def expect_to_have_breadcrumb_links
links = find('[data-testid="breadcrumb-links"]')
links = find_by_testid('breadcrumb-links')
expect(links).to have_content 'group subgroup project'
end

View File

@ -63,14 +63,14 @@ RSpec.describe 'Terraform', :js, feature_category: :package_registry do
expect(page).to have_content(additional_state.name)
find("[data-testid='terraform-state-actions-#{additional_state.name}']").click
find("[data-testid='terraform-state-remove']").click
find_by_testid("terraform-state-actions-#{additional_state.name}").click
find_by_testid('terraform-state-remove').click
fill_in "terraform-state-remove-input-#{additional_state.name}", with: additional_state.name
click_button 'Remove'
expect(page).to have_content("#{additional_state.name} successfully removed")
find("[data-testid='remove-icon']").hover
find_by_testid('remove-icon').hover
expect(page).to have_content("Deletion in progress")
additional_state.reload
@ -84,7 +84,7 @@ RSpec.describe 'Terraform', :js, feature_category: :package_registry do
expect(page).to have_content(terraform_state.name)
page.within("[data-testid='terraform-state-actions-#{terraform_state.name}']") do
within_testid("terraform-state-actions-#{terraform_state.name}") do
click_button class: 'gl-dropdown-toggle'
click_button 'Copy Terraform init command'
end

View File

@ -54,7 +54,7 @@ RSpec.describe 'Multi-file editor new directory', :js, feature_category: :web_id
# (as it is with WEBDRIVER_HEADLESS=0), this initial commit button will exist. Otherwise, if it is
# taller (as it is by default with chrome headless) then the button will not exist.
if page.has_css?('[data-testid="begin-commit-button"]')
find('[data-testid="begin-commit-button"]').click
find_by_testid('begin-commit-button').click
end
fill_in('commit-message', with: 'commit message ide')

View File

@ -43,7 +43,7 @@ RSpec.describe 'Multi-file editor new file', :js, feature_category: :web_ide do
# (as it is with WEBDRIVER_HEADLESS=0), this initial commit button will exist. Otherwise, if it is
# taller (as it is by default with chrome headless) then the button will not exist.
if page.has_css?('[data-testid="begin-commit-button"]')
find('[data-testid="begin-commit-button"]').click
find_by_testid('begin-commit-button').click
end
fill_in('commit-message', with: 'commit message ide')

View File

@ -22,15 +22,15 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
end
it 'are not displayed when issue does not have work item children', :aggregate_failures do
page.within('[data-testid="work-item-links"]') do
expect(find('[data-testid="links-empty"]')).to have_content(_('No child items are currently assigned.'))
within_testid('work-item-links') do
expect(find_by_testid('links-empty')).to have_content(_('No child items are currently assigned.'))
expect(page).not_to have_selector('[data-testid="add-links-form"]')
expect(page).not_to have_selector('[data-testid="links-child"]')
end
end
it 'toggles widget body', :aggregate_failures do
page.within('[data-testid="work-item-links"]') do
within_testid('work-item-links') do
expect(page).to have_selector('[data-testid="widget-body"]')
click_button 'Collapse'
@ -44,7 +44,7 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
end
it 'toggles form', :aggregate_failures do
page.within('[data-testid="work-item-links"]') do
within_testid('work-item-links') do
expect(page).not_to have_selector('[data-testid="add-links-form"]')
click_button 'Add'
@ -59,7 +59,7 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
end
it 'adds a new child task', :aggregate_failures do
page.within('[data-testid="work-item-links"]') do
within_testid('work-item-links') do
click_button 'Add'
click_button 'New task'
@ -72,20 +72,20 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
wait_for_all_requests
expect(find('[data-testid="links-child"]')).to have_content('Task 1')
expect(find_by_testid('links-child')).to have_content('Task 1')
end
end
it 'removes a child task and undoing', :aggregate_failures do
page.within('[data-testid="work-item-links"]') do
within_testid('work-item-links') do
click_button 'Add'
click_button 'New task'
fill_in 'Add a title', with: 'Task 1'
click_button 'Create task'
wait_for_all_requests
expect(find('[data-testid="links-child"]')).to have_content('Task 1')
expect(find('[data-testid="children-count"]')).to have_content('1')
expect(find_by_testid('links-child')).to have_content('Task 1')
expect(find_by_testid('children-count')).to have_content('1')
find_by_testid('links-child').hover
find_by_testid('remove-work-item-link').click
@ -93,7 +93,7 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
wait_for_all_requests
expect(page).not_to have_content('Task 1')
expect(find('[data-testid="children-count"]')).to have_content('0')
expect(find_by_testid('children-count')).to have_content('0')
end
page.within('.gl-toast') do
@ -103,9 +103,9 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
wait_for_all_requests
page.within('[data-testid="work-item-links"]') do
expect(find('[data-testid="links-child"]')).to have_content('Task 1')
expect(find('[data-testid="children-count"]')).to have_content('1')
within_testid('work-item-links') do
expect(find_by_testid('links-child')).to have_content('Task 1')
expect(find_by_testid('children-count')).to have_content('1')
end
end
@ -113,12 +113,12 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
let_it_be(:task) { create(:work_item, :task, project: project) }
it 'adds an existing child task', :aggregate_failures do
page.within('[data-testid="work-item-links"]') do
within_testid('work-item-links') do
click_button 'Add'
click_button 'Existing task'
expect(page).to have_button('Add task', disabled: true)
find('[data-testid="work-item-token-select-input"]').set(task.title)
find_by_testid('work-item-token-select-input').set(task.title)
wait_for_all_requests
click_button task.title
@ -130,7 +130,7 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
wait_for_all_requests
expect(find('[data-testid="links-child"]')).to have_content(task.title)
expect(find_by_testid('links-child')).to have_content(task.title)
end
end
@ -139,12 +139,12 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
let_it_be(:task) { create(:work_item, :confidential, :task, project: project) }
it 'adds an existing child task', :aggregate_failures do
page.within('[data-testid="work-item-links"]') do
within_testid('work-item-links') do
click_button 'Add'
click_button 'Existing task'
expect(page).to have_button('Add task', disabled: true)
find('[data-testid="work-item-token-select-input"]').set(task.title)
find_by_testid('work-item-token-select-input').set(task.title)
wait_for_all_requests
click_button task.title
@ -156,7 +156,7 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
wait_for_all_requests
expect(find('[data-testid="links-child"]')).to have_content(task.title)
expect(find_by_testid('links-child')).to have_content(task.title)
end
end
end
@ -183,11 +183,11 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
end
it 'displays labels, milestone and assignee for work item children', :aggregate_failures do
page.within('[data-testid="work-item-links"]') do
within_testid('work-item-links') do
click_button 'Add'
click_button 'Existing task'
find('[data-testid="work-item-token-select-input"]').set(task.title)
find_by_testid('work-item-token-select-input').set(task.title)
wait_for_all_requests
click_button task.title
@ -198,7 +198,7 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do
wait_for_all_requests
end
page.within('[data-testid="links-child"]') do
within_testid('links-child') do
expect(page).to have_content(task.title)
expect(page).to have_content(label.title)
expect(page).to have_link(user.name)

View File

@ -27,13 +27,13 @@ RSpec.describe 'Work item', :js, feature_category: :team_planning do
end
it 'shows project issues link in breadcrumbs' do
within('[data-testid="breadcrumb-links"]') do
within_testid('breadcrumb-links') do
expect(page).to have_link('Issues', href: project_issues_path(project))
end
end
it 'uses IID path in breadcrumbs' do
within('[data-testid="breadcrumb-current-link"]') do
within_testid('breadcrumb-current-link') do
expect(page).to have_link("##{work_item.iid}", href: work_items_path)
end
end
@ -52,14 +52,14 @@ RSpec.describe 'Work item', :js, feature_category: :team_planning do
it 'reassigns to another user',
quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/413074' do
find('[data-testid="work-item-assignees-input"]').fill_in(with: user.username)
find_by_testid('work-item-assignees-input').fill_in(with: user.username)
wait_for_requests
send_keys(:enter)
find("body").click
wait_for_requests
find('[data-testid="work-item-assignees-input"]').fill_in(with: user2.username)
find_by_testid('work-item-assignees-input').fill_in(with: user2.username)
wait_for_requests
send_keys(:enter)
@ -80,7 +80,7 @@ RSpec.describe 'Work item', :js, feature_category: :team_planning do
it 'reassigns to another user',
quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/413074' do
within('[data-testid="work-item-assignees-with-edit"]') do
within_testid('work-item-assignees-with-edit') do
click_button 'Edit'
end
@ -88,7 +88,7 @@ RSpec.describe 'Work item', :js, feature_category: :team_planning do
wait_for_requests
within('[data-testid="work-item-assignees-with-edit"]') do
within_testid('work-item-assignees-with-edit') do
click_button 'Edit'
end
@ -167,13 +167,13 @@ RSpec.describe 'Work item', :js, feature_category: :team_planning do
end
it 'disabled the assignees input field' do
within('[data-testid="work-item-assignees-input"]') do
within_testid('work-item-assignees-input') do
expect(page).to have_field(type: 'text', disabled: true)
end
end
it 'disables the labels input field' do
within('[data-testid="work-item-labels-input"]') do
within_testid('work-item-labels-input') do
expect(page).to have_field(type: 'text', disabled: true)
end
end
@ -188,13 +188,13 @@ RSpec.describe 'Work item', :js, feature_category: :team_planning do
end
it 'hides the assignees edit button' do
within('[data-testid="work-item-assignees-with-edit"]') do
within_testid('work-item-assignees-with-edit') do
expect(page).not_to have_button('Edit')
end
end
it 'hides the labels edit button' do
within('[data-testid="work-item-labels-with-edit"]') do
within_testid('work-item-labels-with-edit') do
expect(page).not_to have_button('Edit')
end
end

View File

@ -66,11 +66,14 @@ RSpec.describe 'Protected Branches', :js, feature_category: :source_code_managem
expect(page).to have_content('fix')
expect(find('.all-branches')).to have_selector('li', count: 1)
find('[data-testid="branch-more-actions"] button').click
within_testid('branch-more-actions') do
find('button').click
end
wait_for_requests
expect(page).to have_button('Delete protected branch', disabled: false)
find('[data-testid="delete-branch-button"]').click
find_by_testid('delete-branch-button').click
fill_in 'delete_branch_input', with: 'fix'
click_button 'Yes, delete protected branch'

View File

@ -53,7 +53,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'user sees the project runner' do
visit project_runners_path(project)
within '[data-testid="assigned_project_runners"]' do
within_testid 'assigned_project_runners' do
expect(page).to have_content(project_runner.display_name)
end
@ -65,19 +65,19 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'user can pause and resume the project runner' do
visit project_runners_path(project)
within '[data-testid="assigned_project_runners"]' do
within_testid 'assigned_project_runners' do
expect(page).to have_link('Pause')
end
click_on 'Pause'
within '[data-testid="assigned_project_runners"]' do
within_testid 'assigned_project_runners' do
expect(page).to have_link('Resume')
end
click_on 'Resume'
within '[data-testid="assigned_project_runners"]' do
within_testid 'assigned_project_runners' do
expect(page).to have_link('Pause')
end
end
@ -85,7 +85,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'user removes an activated project runner if this is last project for that runners' do
visit project_runners_path(project)
within '[data-testid="assigned_project_runners"]' do
within_testid 'assigned_project_runners' do
click_on 'Remove runner'
end
@ -100,7 +100,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'user edits the runner to be protected' do
visit project_runners_path(project)
within '[data-testid="assigned_project_runners"]' do
within_testid 'assigned_project_runners' do
first('[data-testid="edit-runner-link"]').click
end
@ -120,7 +120,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'user edits runner not to run untagged jobs' do
visit project_runners_path(project)
within '[data-testid="assigned_project_runners"]' do
within_testid 'assigned_project_runners' do
first('[data-testid="edit-runner-link"]').click
end
@ -140,7 +140,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'user sees CI/CD setting page' do
visit project_runners_path(project)
within '[data-testid="available-shared-runners"]' do
within_testid 'available-shared-runners' do
expect(page).to have_content(shared_runner.display_name)
end
end
@ -151,7 +151,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'shows the runner count' do
visit project_runners_path(project)
within '[data-testid="available-shared-runners"]' do
within_testid 'available-shared-runners' do
expect(page).to have_content format(_('Available instance runners: %{count}'), { count: 2 })
end
end
@ -161,7 +161,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
visit project_runners_path(project)
within '[data-testid="available-shared-runners"]' do
within_testid 'available-shared-runners' do
expect(find('.pagination')).not_to be_nil
end
end
@ -192,17 +192,17 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'user enables and disables a project runner' do
visit project_runners_path(project)
within '[data-testid="available_project_runners"]' do
within_testid 'available_project_runners' do
click_on 'Enable for this project'
end
expect(page.find('[data-testid="assigned_project_runners"]')).to have_content(project_runner.display_name)
expect(find_by_testid('assigned_project_runners')).to have_content(project_runner.display_name)
within '[data-testid="assigned_project_runners"]' do
within_testid 'assigned_project_runners' do
click_on 'Disable for this project'
end
expect(page.find('[data-testid="available_project_runners"]')).to have_content(project_runner.display_name)
expect(find_by_testid('available_project_runners')).to have_content(project_runner.display_name)
end
end
@ -218,7 +218,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'user sees shared runners description' do
visit project_runners_path(project)
page.within("[data-testid='shared-runners-description']") do
within_testid('shared-runners-description') do
expect(page).not_to have_content('The same shared runner executes code from multiple projects')
expect(page).to have_content(shared_runners_html)
end
@ -235,7 +235,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'user sees no link' do
visit project_runners_path(project)
page.within("[data-testid='shared-runners-description']") do
within_testid('shared-runners-description') do
expect(page).to have_content('link')
expect(page).not_to have_link('link')
end
@ -252,7 +252,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'user sees image safely' do
visit project_runners_path(project)
page.within("[data-testid='shared-runners-description']") do
within_testid('shared-runners-description') do
expect(page).to have_css('img')
expect(page).not_to have_css('img[onerror]')
end
@ -384,7 +384,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
it 'shows the runner count' do
visit project_runners_path(project)
within '[data-testid="group-runners"]' do
within_testid 'group-runners' do
expect(page).to have_content format(_('Available group runners: %{runners}'), { runners: 2 })
end
end
@ -394,7 +394,7 @@ RSpec.describe 'Runners', feature_category: :fleet_visibility do
visit project_runners_path(project)
within '[data-testid="group-runners"]' do
within_testid 'group-runners' do
expect(find('.pagination')).not_to be_nil
end
end

View File

@ -77,7 +77,7 @@ describe('Repository last commit component', () => {
it('strips the first newline of the description', () => {
expect(findCommitRowDescription().html()).toBe(
'<pre class="commit-row-description gl-mb-3 gl-white-space-pre-line">Update ADOPTERS.md</pre>',
'<pre class="commit-row-description gl-mb-3 gl-white-space-pre-wrap">Update ADOPTERS.md</pre>',
);
});

View File

@ -0,0 +1,97 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe MergeRequests::ProcessAutoMergeFromEventWorker, feature_category: :code_review_workflow do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:merge_request) { create(:merge_request, source_project: project, merge_user: user) }
# rubocop:disable RSpec/VerifiedDoubles -- this is removed once we consume an event
let(:data) { double(data: { current_user_id: user.id, merge_request_id: merge_request.id }) }
# rubocop:enable RSpec/VerifiedDoubles
it 'calls AutoMergeService' do
expect_next_instance_of(
AutoMergeService,
project, user
) do |service|
expect(service).to receive(:process).with(merge_request)
end
described_class.new.handle_event(data)
end
context 'when the merge request does not exist' do
before do
merge_request.destroy!
end
it 'logs and does not call AutoMergeService' do
expect(Sidekiq.logger).to receive(:info).with(
hash_including('message' => 'Merge request not found.', 'merge_request_id' => merge_request.id)
)
expect(AutoMergeService).not_to receive(:new)
expect { described_class.new.handle_event(data) }
.not_to raise_exception
end
end
context 'when feature flag "merge_when_checks_pass" is disabled' do
before do
stub_feature_flags(merge_when_checks_pass: false)
end
it "doesn't call AutoMergeService" do
expect(AutoMergeService).not_to receive(:new)
described_class.new.handle_event(data)
end
end
end
# TODO: replace the spec with this when we consume an event
# let(:approved_event) { MergeRequests::ApprovedEvent.new(data: data) }
# it_behaves_like 'subscribes to event' do
# let(:event) { approved_event }
#
# it 'calls AutoMergeService' do
# expect_next_instance_of(
# AutoMergeService,
# project, user
# ) do |service|
# expect(service).to receive(:process).with(merge_request)
# end
#
# consume_event(subscriber: described_class, event: approved_event)
# end
#
# context 'when the merge request does not exist' do
# before do
# merge_request.destroy!
# end
#
# it 'logs and does not call AutoMergeService' do
# expect(Sidekiq.logger).to receive(:info).with(
# hash_including('message' => 'Merge request not found.', 'merge_request_id' => merge_request.id)
# )
# expect(AutoMergeService).not_to receive(:new)
#
# expect { consume_event(subscriber: described_class, event: approved_event) }
# .not_to raise_exception
# end
# end
#
# context 'when feature flag "merge_when_checks_pass" is disabled' do
# before do
# stub_feature_flags(merge_when_checks_pass: false)
# end
#
# it "doesn't call AutoMergeService" do
# expect(AutoMergeService).not_to receive(:new)
#
# consume_event(subscriber: described_class, event: approved_event)
# end
# end
# end