debian-mirror-gitlab/spec/features/merge_request/user_manages_subscription_spec.rb
2022-07-16 19:58:13 +02:00

65 lines
1.6 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User manages subscription', :js do
let(:project) { create(:project, :public, :repository) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:user) { create(:user) }
let(:moved_mr_sidebar_enabled) { false }
before do
stub_feature_flags(moved_mr_sidebar: moved_mr_sidebar_enabled)
project.add_maintainer(user)
sign_in(user)
visit(merge_request_path(merge_request))
end
context 'moved sidebar flag disabled' do
it 'toggles subscription' do
page.within('[data-testid="subscription-toggle"]') do
wait_for_requests
expect(page).to have_css 'button:not(.is-checked)'
find('button:not(.is-checked)').click
wait_for_requests
expect(page).to have_css 'button.is-checked'
find('button.is-checked').click
wait_for_requests
expect(page).to have_css 'button:not(.is-checked)'
end
end
end
context 'moved sidebar flag enabled' do
let(:moved_mr_sidebar_enabled) { true }
it 'toggles subscription' do
wait_for_requests
click_button 'Toggle dropdown'
expect(page).to have_content('Turn on notifications')
click_button 'Turn on notifications'
wait_for_requests
click_button 'Toggle dropdown'
expect(page).to have_content('Turn off notifications')
click_button 'Turn off notifications'
wait_for_requests
click_button 'Toggle dropdown'
expect(page).to have_content('Turn on notifications')
end
end
end