debian-mirror-gitlab/spec/features/projects/settings/project_settings_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

95 lines
2.8 KiB
Ruby
Raw Permalink Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Projects settings', feature_category: :projects do
2020-04-08 14:13:33 +05:30
let_it_be(:project) { create(:project) }
2021-06-08 01:23:25 +05:30
2022-04-04 11:22:00 +05:30
let(:user) { project.first_owner }
2019-07-07 11:18:12 +05:30
let(:panel) { find('.general-settings', match: :first) }
2021-03-11 19:13:27 +05:30
let(:button) { panel.find('.btn.gl-button.js-settings-toggle') }
2019-07-07 11:18:12 +05:30
let(:title) { panel.find('.settings-title') }
before do
sign_in(user)
visit edit_project_path(project)
end
it 'can toggle sections by clicking the title or button', :js do
expect_toggle_state(:expanded)
button.click
expect_toggle_state(:collapsed)
button.click
expect_toggle_state(:expanded)
title.click
expect_toggle_state(:collapsed)
title.click
expect_toggle_state(:expanded)
end
2020-03-13 15:44:24 +05:30
context 'forking enabled', :js do
it 'toggles forking enabled / disabled' do
visit edit_project_path(project)
forking_enabled_input = find('input[name="project[project_feature_attributes][forking_access_level]"]', visible: :hidden)
2021-03-11 19:13:27 +05:30
forking_enabled_button = find('[data-for="project[project_feature_attributes][forking_access_level]"] .gl-toggle')
2020-03-13 15:44:24 +05:30
expect(forking_enabled_input.value).to eq('20')
# disable by clicking toggle
forking_enabled_button.click
page.within('.sharing-permissions') do
2022-03-02 08:16:31 +05:30
find('[data-testid="project-features-save-button"]').click
2020-03-13 15:44:24 +05:30
end
wait_for_requests
expect(forking_enabled_input.value).to eq('0')
end
end
2020-05-24 23:13:21 +05:30
context 'default award emojis', :js do
it 'shows award emojis by default' do
visit edit_project_path(project)
default_award_emojis_input = find('input[name="project[project_setting_attributes][show_default_award_emojis]"]', visible: :hidden)
expect(default_award_emojis_input.value).to eq('true')
end
it 'disables award emojis when the checkbox is toggled off' do
visit edit_project_path(project)
default_award_emojis_input = find('input[name="project[project_setting_attributes][show_default_award_emojis]"]', visible: :hidden)
default_award_emojis_checkbox = find('input[name="project[project_setting_attributes][show_default_award_emojis]"][type=checkbox]')
expect(default_award_emojis_input.value).to eq('true')
default_award_emojis_checkbox.click
expect(default_award_emojis_input.value).to eq('false')
page.within('.sharing-permissions') do
2022-03-02 08:16:31 +05:30
find('[data-testid="project-features-save-button"]').click
2020-05-24 23:13:21 +05:30
end
wait_for_requests
expect(default_award_emojis_input.value).to eq('false')
end
end
2019-07-07 11:18:12 +05:30
def expect_toggle_state(state)
is_collapsed = state == :collapsed
expect(button).to have_content(is_collapsed ? 'Expand' : 'Collapse')
expect(panel[:class]).send(is_collapsed ? 'not_to' : 'to', include('expanded'))
end
end