File: user_resolves_wip_mr_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (84 lines) | stat: -rw-r--r-- 2,701 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Merge request > User resolves Draft', :js, feature_category: :code_review_workflow do
  let(:project) { create(:project, :public, :repository) }
  let(:user) { project.creator }
  let(:merge_request) do
    create(
      :merge_request_with_diffs,
      source_project: project,
      author: user,
      title: 'Draft: Bug NS-04',
      merge_params: { force_remove_source_branch: '1' }
    )
  end

  let(:pipeline) do
    create(
      :ci_pipeline,
      project: project,
      sha: merge_request.diff_head_sha,
      ref: merge_request.source_branch,
      head_pipeline_of: merge_request
    )
  end

  before do
    project.add_maintainer(user)
  end

  context 'when there is active pipeline for merge request' do
    let(:feature_flags_state) { true }

    before do
      stub_feature_flags(merge_when_checks_pass: feature_flags_state)

      create(:ci_build, pipeline: pipeline)

      sign_in(user)
      visit project_merge_request_path(project, merge_request)
      wait_for_requests
    end

    it 'retains merge request data after clicking Resolve WIP status' do
      expect(page.find('.ci-widget-content')).to have_content("Pipeline ##{pipeline.id}")
      expect(page).to have_content "Set to auto-merge"

      page.within('.mr-state-widget') do
        click_button('Mark as ready')
      end

      wait_for_requests

      # If we don't disable the wait here, the test will wait until the
      # merge request widget refreshes, which masks missing elements
      # that should already be present.
      expect(page.find('.ci-widget-content', wait: 0)).to have_content("Pipeline ##{pipeline.id}")
      expect(page).to have_content("Set to auto-merge")
    end

    context 'when the new merge_when_checks_pass and merge blocked components are disabled' do
      let(:feature_flags_state) { false }

      it 'retains merge request data after clicking Resolve WIP status' do
        expect(page.find('.ci-widget-content')).to have_content("Pipeline ##{pipeline.id}")
        expect(page).to have_content "Merge blocked: 1 check failed"
        expect(page).to have_content "Merge request must not be draft"

        page.within('.mr-state-widget') do
          click_button('Mark as ready')
        end

        wait_for_requests

        # If we don't disable the wait here, the test will wait until the
        # merge request widget refreshes, which masks missing elements
        # that should already be present.
        expect(page.find('.ci-widget-content', wait: 0)).to have_content("Pipeline ##{pipeline.id}")
        expect(page).not_to have_content("Merge blocked")
      end
    end
  end
end