2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-04 22:31:34 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'User manages subscription', :js do
|
2017-10-04 22:31:34 +00:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
|
|
|
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
|
|
|
|
let(:user) { create(:user) }
|
2022-05-16 21:09:09 +00:00
|
|
|
let(:moved_mr_sidebar_enabled) { false }
|
2017-10-04 22:31:34 +00:00
|
|
|
|
|
|
|
before do
|
2022-05-16 21:09:09 +00:00
|
|
|
stub_feature_flags(moved_mr_sidebar: moved_mr_sidebar_enabled)
|
|
|
|
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-10-04 22:31:34 +00:00
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(merge_request_path(merge_request))
|
|
|
|
end
|
|
|
|
|
2022-05-16 21:09:09 +00:00
|
|
|
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
|
2020-03-05 21:08:13 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
2022-05-16 21:09:09 +00:00
|
|
|
click_button 'Toggle dropdown'
|
|
|
|
|
|
|
|
expect(page).to have_content('Turn on notifications')
|
|
|
|
click_button 'Turn on notifications'
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2018-01-12 07:40:31 +00:00
|
|
|
wait_for_requests
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2022-05-16 21:09:09 +00:00
|
|
|
click_button 'Toggle dropdown'
|
|
|
|
|
|
|
|
expect(page).to have_content('Turn off notifications')
|
|
|
|
click_button 'Turn off notifications'
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2018-01-12 07:40:31 +00:00
|
|
|
wait_for_requests
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2022-05-16 21:09:09 +00:00
|
|
|
click_button 'Toggle dropdown'
|
|
|
|
|
|
|
|
expect(page).to have_content('Turn on notifications')
|
2018-01-12 07:40:31 +00:00
|
|
|
end
|
2017-10-04 22:31:34 +00:00
|
|
|
end
|
|
|
|
end
|