Maintenance: Port old reporting profile tests to capybara.

This commit is contained in:
Bola Ahmed Buari 2021-09-15 22:31:29 +01:00 committed by Dominik Klein
parent a4fb56400e
commit bbbb923119
4 changed files with 85 additions and 50 deletions

View file

@ -68,7 +68,6 @@ if [ "$LEVEL" == '1' ]; then
rm test/browser/preferences_language_test.rb rm test/browser/preferences_language_test.rb
rm test/browser/preferences_permission_check_test.rb rm test/browser/preferences_permission_check_test.rb
rm test/browser/preferences_token_access_test.rb rm test/browser/preferences_token_access_test.rb
rm test/browser/reporting_test.rb
# test/browser/swich_to_user_test.rb # test/browser/swich_to_user_test.rb
# test/browser/taskbar_session_test.rb # test/browser/taskbar_session_test.rb
# test/browser/taskbar_task_test.rb # test/browser/taskbar_task_test.rb
@ -139,7 +138,6 @@ elif [ "$LEVEL" == '2' ]; then
rm test/browser/preferences_language_test.rb rm test/browser/preferences_language_test.rb
rm test/browser/preferences_permission_check_test.rb rm test/browser/preferences_permission_check_test.rb
rm test/browser/preferences_token_access_test.rb rm test/browser/preferences_token_access_test.rb
rm test/browser/reporting_test.rb
rm test/browser/switch_to_user_test.rb rm test/browser/switch_to_user_test.rb
rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_session_test.rb
rm test/browser/taskbar_task_test.rb rm test/browser/taskbar_task_test.rb
@ -210,7 +208,6 @@ elif [ "$LEVEL" == '3' ]; then
rm test/browser/preferences_language_test.rb rm test/browser/preferences_language_test.rb
rm test/browser/preferences_permission_check_test.rb rm test/browser/preferences_permission_check_test.rb
rm test/browser/preferences_token_access_test.rb rm test/browser/preferences_token_access_test.rb
rm test/browser/reporting_test.rb
rm test/browser/switch_to_user_test.rb rm test/browser/switch_to_user_test.rb
rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_session_test.rb
rm test/browser/taskbar_task_test.rb rm test/browser/taskbar_task_test.rb
@ -281,7 +278,6 @@ elif [ "$LEVEL" == '4' ]; then
rm test/browser/preferences_language_test.rb rm test/browser/preferences_language_test.rb
rm test/browser/preferences_permission_check_test.rb rm test/browser/preferences_permission_check_test.rb
rm test/browser/preferences_token_access_test.rb rm test/browser/preferences_token_access_test.rb
rm test/browser/reporting_test.rb
rm test/browser/switch_to_user_test.rb rm test/browser/switch_to_user_test.rb
rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_session_test.rb
rm test/browser/taskbar_task_test.rb rm test/browser/taskbar_task_test.rb
@ -351,7 +347,6 @@ elif [ "$LEVEL" == '5' ]; then
rm test/browser/preferences_language_test.rb rm test/browser/preferences_language_test.rb
rm test/browser/preferences_permission_check_test.rb rm test/browser/preferences_permission_check_test.rb
rm test/browser/preferences_token_access_test.rb rm test/browser/preferences_token_access_test.rb
rm test/browser/reporting_test.rb
rm test/browser/switch_to_user_test.rb rm test/browser/switch_to_user_test.rb
rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_session_test.rb
rm test/browser/taskbar_task_test.rb rm test/browser/taskbar_task_test.rb
@ -424,7 +419,6 @@ elif [ "$LEVEL" == '6' ]; then
# test/browser/preferences_language_test.rb # test/browser/preferences_language_test.rb
# test/browser/preferences_permission_check_test.rb # test/browser/preferences_permission_check_test.rb
# test/browser/preferences_token_access_test.rb # test/browser/preferences_token_access_test.rb
# test/browser/reporting_test.rb
rm test/browser/switch_to_user_test.rb rm test/browser/switch_to_user_test.rb
rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_session_test.rb
rm test/browser/taskbar_task_test.rb rm test/browser/taskbar_task_test.rb

View file

@ -7,4 +7,53 @@ RSpec.describe 'Manage > Report Profiles', type: :system do
context 'ajax pagination' do context 'ajax pagination' do
include_examples 'pagination', model: :report_profile, klass: Report::Profile, path: 'manage/report_profiles' include_examples 'pagination', model: :report_profile, klass: Report::Profile, path: 'manage/report_profiles'
end end
context 'for reporting profiles' do
before do
Report::Profile.destroy_all
visit '#manage/report_profiles'
within :active_content do
click 'a[data-type=new]'
within '.modal' do
fill_in 'name', with: name
select profile_active, from: 'active'
click_button
end
end
end
context 'when creating an inactive profile' do
let(:name) { 'inactive profile' }
let(:profile_active) { 'inactive' }
it 'creates an inactive profile report' do
within :active_content do
within '.page-content' do
expect(page).to have_selector('tr.item.is-inactive')
.and have_text(name)
end
end
end
end
context 'when creating an active profile' do
let(:name) { 'active profile' }
let(:profile_active) { 'active' }
it 'creates an active profile report on the ui' do
within :active_content do
within '.page-content' do
expect(page).to have_no_selector('tr.item.is-inactive')
.and have_text(name)
end
end
end
it 'creates an active profile report in the backend' do
expect(Report::Profile.count).to be(1)
end
end
end
end end

View file

@ -0,0 +1,36 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'rails_helper'
RSpec.describe 'Report', type: :system, searchindex: true do
before do
configure_elasticsearch(required: true, rebuild: true)
end
context 'with ticket search result' do
let(:label) { find('.content ul.checkbox-list') }
before do
create(:report_profile, name: report_profile_name, active: active)
visit 'report'
end
context 'with an active report profile' do
let(:report_profile_name) { 'active report profile' }
let(:active) { true }
it 'shows active report profile' do
expect(label).to have_text(report_profile_name)
end
end
context 'with an inactive report profile' do
let(:report_profile_name) { 'inactive report profile' }
let(:active) { false }
it 'does not show inactive report profile' do
expect(label).to have_no_text(report_profile_name)
end
end
end
end

View file

@ -1,44 +0,0 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'browser_test_helper'
class ReportingTest < TestCase
def test_only_show_active_reporting_profiles
@browser = browser_instance
login(
username: 'admin@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all
report_profile_create(
data: {
name: 'active_report_profile',
active: true,
}
)
report_profile_create(
data: {
name: 'inactive_report_profile',
active: false,
}
)
click(
css: 'a[href="#manage"]',
)
click(
css: '.content.active a[href="#manage/report_profiles"]',
)
click(
css: 'a[href="#report"]',
)
watch_for(
css: '.content ul.checkbox-list',
)
labels = @browser.find_elements(css: '.content ul.checkbox-list .label-text').map(&:text)
assert_equal labels, %w[-all- active_report_profile]
end
end