diff --git a/spec/system/admin/calendars/date_spec.rb b/spec/system/admin/calendars/date_spec.rb deleted file mode 100644 index 9fe97a305..000000000 --- a/spec/system/admin/calendars/date_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'Admin Panel > Calendars date', type: :system, authenticated: true, time_zone: 'America/Sao_Paulo' do - # https://github.com/zammad/zammad/issues/2229 - it 'Show festivities dates correctly far away from UTC' do - visit '/#manage/calendars' - - click '.js-new' - - modal_ready - - within '.modal-dialog' do - fill_in 'name', with: 'test calendar' - - click '.dropdown-toggle' - click '.dropdown-menu [data-value="America/Sao_Paulo"]' - - find('.ical_feed select').select 'Brazil' - - click '.js-submit' - end - - modal_disappear - - container = find('.action') { |elem| elem.find('.action-row h2').text == 'test calendar' } - - container.find('.js-edit').click - - modal_ready - - within '.modal-dialog' do - scroll_to(css: '.modal-dialog', vertical: 'end') - - rows = find_all('.holiday_selector tr') { |elem| elem.has_css?('input.js-summary') && elem.find('input.js-summary').value.starts_with?('Christmas Eve') } - row = rows[0] - - expect(row).to have_text('24') - expect(row).to have_text('12') - end - end -end diff --git a/spec/system/admin/channel/email_spec.rb b/spec/system/admin/channel/email_spec.rb deleted file mode 100644 index fecb405da..000000000 --- a/spec/system/admin/channel/email_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'Admin Panel > Channels > Email', type: :system, authenticated: true do - # https://github.com/zammad/zammad/issues/224 - it 'hides "Edit" links when Channel#preferences[:editable] == false' do - # ensure that the only existing email channel - # has preferences == { editable: false } - Channel.destroy_all - create(:email_channel, preferences: { editable: false }) - - visit '/#channels/email' - expect(page).to have_css('#c-account h3', text: 'Inbound') # Wait for frontend to load - expect(page).to have_css('#c-account h3', text: 'Outbound') # Wait for frontend to load - - expect(page).not_to have_css('.js-editInbound, .js-editOutbound', text: 'Edit') - end -end diff --git a/spec/system/admin/channel/twitter_spec.rb b/spec/system/admin/channel/twitter_spec.rb deleted file mode 100644 index 5d6ca2bbc..000000000 --- a/spec/system/admin/channel/twitter_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'Admin Panel > Channels > Twitter', :authenticated, :use_vcr, type: :system do - context 'with incomplete credentials' do - it 'displays a 401 error modal' do - visit '/#channels/twitter' - within(:active_content) do - find('.js-configApp').click - - modal_ready - fill_in 'Twitter Consumer Key *', with: 'some_key', exact: true - fill_in 'Twitter Consumer Secret *', with: 'some_secret', exact: true - click_on 'Submit' - - expect(page).to have_css('.modal .alert', text: '401 Authorization Required') - end - end - end - - context 'with invalid credentials' do - it 'displays a 401 error modal' do - visit '/#channels/twitter' - within(:active_content) do - find('.js-configApp').click - - modal_ready - fill_in 'Twitter Consumer Key *', with: 'some_key', exact: true - fill_in 'Twitter Consumer Secret *', with: 'some_secret', exact: true - fill_in 'Twitter Access Token *', with: 'some_oauth_token', exact: true - fill_in 'Twitter Access Token Secret *', with: 'some_oauth_token_secret', exact: true - fill_in 'Twitter Dev environment label *', with: 'some_env', exact: true - click_on 'Submit' - - expect(page).to have_css('.modal .alert', text: '401 Authorization Required') - end - end - end -end diff --git a/spec/system/admin/trigger/custom_attribute_as_multiselect_spec.rb b/spec/system/admin/trigger/custom_attribute_as_multiselect_spec.rb deleted file mode 100644 index b462da03d..000000000 --- a/spec/system/admin/trigger/custom_attribute_as_multiselect_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'Admin Panel > Trigger', type: :system do - it 'custom select attribute allows to select multiple values', db_strategy: :reset do - attribute = create_attribute :object_manager_attribute_select, - data_option: { - options: { - 'name 1': 'name 1', - 'name 2': 'name 2', - }, - default: '', - null: false, - relation: '', - maxlength: 255, - nulloption: true, - } - - visit '/#manage/trigger' - click '.page-header-meta .btn--success' - - modal_ready - - within '.modal .ticket_selector' do - find('.js-attributeSelector select').select(attribute.display) - - expect(find('.js-value select')).to be_multiple - end - end -end diff --git a/spec/system/channels/email_spec.rb b/spec/system/channels/email_spec.rb new file mode 100644 index 000000000..7d85d0a25 --- /dev/null +++ b/spec/system/channels/email_spec.rb @@ -0,0 +1,22 @@ +require 'rails_helper' + +RSpec.describe 'Manage > Channels > Email', type: :system do + + context 'non editable' do + + it 'hides "Edit" links' do + # ensure that the only existing email channel + # has preferences == { editable: false } + Channel.destroy_all + create(:email_channel, preferences: { editable: false }) + + visit '/#channels/email' + + # verify page has loaded + expect(page).to have_css('#c-account h3', text: 'Inbound') + expect(page).to have_css('#c-account h3', text: 'Outbound') + + expect(page).not_to have_css('.js-editInbound, .js-editOutbound', text: 'Edit') + end + end +end diff --git a/spec/system/channels/twitter_spec.rb b/spec/system/channels/twitter_spec.rb new file mode 100644 index 000000000..f8acd47fc --- /dev/null +++ b/spec/system/channels/twitter_spec.rb @@ -0,0 +1,42 @@ +require 'rails_helper' + +RSpec.describe 'Manage > Channels > Twitter', :use_vcr, type: :system do + + context 'credentials' do + + before { visit '/#channels/twitter' } + + context 'incomplete' do + it 'displays a 401 error modal' do + within(:active_content) do + find('.js-configApp').click + + modal_ready + fill_in 'Twitter Consumer Key *', with: 'some_key', exact: true + fill_in 'Twitter Consumer Secret *', with: 'some_secret', exact: true + click_on 'Submit' + + expect(page).to have_css('.modal .alert', text: '401 Authorization Required') + end + end + end + + context 'invalid' do + it 'displays a 401 error modal' do + within(:active_content) do + find('.js-configApp').click + + modal_ready + fill_in 'Twitter Consumer Key *', with: 'some_key', exact: true + fill_in 'Twitter Consumer Secret *', with: 'some_secret', exact: true + fill_in 'Twitter Access Token *', with: 'some_oauth_token', exact: true + fill_in 'Twitter Access Token Secret *', with: 'some_oauth_token_secret', exact: true + fill_in 'Twitter Dev environment label *', with: 'some_env', exact: true + click_on 'Submit' + + expect(page).to have_css('.modal .alert', text: '401 Authorization Required') + end + end + end + end +end diff --git a/spec/system/manage/calendars_spec.rb b/spec/system/manage/calendars_spec.rb new file mode 100644 index 000000000..62bf03916 --- /dev/null +++ b/spec/system/manage/calendars_spec.rb @@ -0,0 +1,44 @@ +require 'rails_helper' + +RSpec.describe 'Manage > Calendars', type: :system do + + context 'Date' do + + it 'show festivity dates correctly far away from UTC', time_zone: 'America/Sao_Paulo' do + visit '/#manage/calendars' + + click '.js-new' + + modal_ready + + within '.modal-dialog' do + fill_in 'name', with: 'test calendar' + + click '.dropdown-toggle' + click '.dropdown-menu [data-value="America/Sao_Paulo"]' + + find('.ical_feed select').select 'Brazil' + + click '.js-submit' + end + + modal_disappear + + container = find('.action') { |elem| elem.find('.action-row h2').text == 'test calendar' } + + container.find('.js-edit').click + + modal_ready + + within '.modal-dialog' do + scroll_to(css: '.modal-dialog', vertical: 'end') + + rows = find_all('.holiday_selector tr') { |elem| elem.has_css?('input.js-summary') && elem.find('input.js-summary').value.starts_with?('Christmas Eve') } + row = rows[0] + + expect(row).to have_text('24') + expect(row).to have_text('12') + end + end + end +end diff --git a/spec/system/manage/trigger_spec.rb b/spec/system/manage/trigger_spec.rb index 4e3ca2e8b..e4188b9af 100644 --- a/spec/system/manage/trigger_spec.rb +++ b/spec/system/manage/trigger_spec.rb @@ -2,6 +2,38 @@ require 'rails_helper' RSpec.describe 'Manage > Trigger', type: :system do + context 'Selector' do + + context 'custom attribute', db_strategy: :reset do + + it 'enables selection of multiple values for select attribute' do + attribute = create_attribute :object_manager_attribute_select, + data_option: { + options: { + 'name 1': 'name 1', + 'name 2': 'name 2', + }, + default: '', + null: false, + relation: '', + maxlength: 255, + nulloption: true, + } + + visit '/#manage/trigger' + click '.page-header-meta .btn--success' + + modal_ready + + within '.modal .ticket_selector' do + find('.js-attributeSelector select').select(attribute.display) + + expect(find('.js-value select')).to be_multiple + end + end + end + end + context 'Perform' do context 'Tags' do diff --git a/spec/system/admin/settings/ticket_spec.rb b/spec/system/settings/ticket_spec.rb similarity index 60% rename from spec/system/admin/settings/ticket_spec.rb rename to spec/system/settings/ticket_spec.rb index 83bf9c16a..3acb00c00 100644 --- a/spec/system/admin/settings/ticket_spec.rb +++ b/spec/system/settings/ticket_spec.rb @@ -1,26 +1,26 @@ require 'rails_helper' -RSpec.describe 'Admin > Settings > Ticket', type: :system do +RSpec.describe 'Manage > Settings > Ticket', type: :system do - describe 'owner auto-assignment admin settings' do - it 'enable and disable feature' do + before { visit 'settings/ticket' } - click(:manage) + describe 'owner auto-assignment' do + + it 'enables/disables Setting ticket_auto_assignment' do within(:active_content) do - click(:href, '#settings/ticket') click(:href, '#auto_assignment') expect(page).to have_field('ticket_auto_assignment', checked: false, visible: false) - find('.js-ticketAutoAssignment').click() + find('.js-ticketAutoAssignment').click expect(page).to have_field('ticket_auto_assignment', checked: true, visible: false) end refresh within(:active_content) do - find('a[href="#auto_assignment"]').click() + click(:href, '#auto_assignment') expect(page).to have_field('ticket_auto_assignment', checked: true, visible: false) - find('.js-ticketAutoAssignment').click() + find('.js-ticketAutoAssignment').click expect(page).to have_field('ticket_auto_assignment', checked: false, visible: false) end end diff --git a/spec/system/admin/maintenance/login_message_spec.rb b/spec/system/system/maintenance_spec.rb similarity index 79% rename from spec/system/admin/maintenance/login_message_spec.rb rename to spec/system/system/maintenance_spec.rb index e0550e9a0..4fedd71d8 100644 --- a/spec/system/admin/maintenance/login_message_spec.rb +++ b/spec/system/system/maintenance_spec.rb @@ -1,10 +1,11 @@ require 'rails_helper' -RSpec.describe 'Admin > Maintenance login message', type: :system do +RSpec.describe 'Manage > Maintenance', type: :system do it 'switch maintenance_login on' do Setting.set 'maintenance_login', false - open_page + visit 'system/maintenance' + refresh # ensure changed Setting is loaded find('.js-loginSetting label').click find('.js-loginSetting input', visible: :all).check # required for chrome @@ -15,7 +16,8 @@ RSpec.describe 'Admin > Maintenance login message', type: :system do it 'switch maintenance_login off' do Setting.set 'maintenance_login', true - open_page + visit 'system/maintenance' + refresh # ensure changed Setting is loaded find('.js-loginSetting label').click find('.js-loginSetting input', visible: :all).uncheck # required for chrome @@ -28,7 +30,8 @@ RSpec.describe 'Admin > Maintenance login message', type: :system do Setting.set 'maintenance_login_message', message - open_page + visit 'system/maintenance' + refresh # ensure changed Setting is loaded expect(find('.js-loginPreview [data-name="message"]')).to have_text message end @@ -39,7 +42,8 @@ RSpec.describe 'Admin > Maintenance login message', type: :system do Setting.set 'maintenance_login_message', message_prefix - open_page + visit 'system/maintenance' + refresh # ensure changed Setting is loaded within(:active_content) do elem = find('#maintenance-message.hero-unit') @@ -52,11 +56,4 @@ RSpec.describe 'Admin > Maintenance login message', type: :system do wait(10).until { expect(Setting.get('maintenance_login_message')).to eq "#{message_prefix}#{message_suffix}" } end - - def open_page - refresh # make sure initial Setting are applied - - click(:manage) - click(:href, '#system/maintenance') - end end diff --git a/test/data/vcr_cassettes/system/admin/channel/twitter/with_incomplete_credentials_displays_a_401_error_modal.yml b/test/data/vcr_cassettes/system/channels/twitter/incomplete_displays_a_401_error_modal.yml similarity index 100% rename from test/data/vcr_cassettes/system/admin/channel/twitter/with_incomplete_credentials_displays_a_401_error_modal.yml rename to test/data/vcr_cassettes/system/channels/twitter/incomplete_displays_a_401_error_modal.yml diff --git a/test/data/vcr_cassettes/system/admin/channel/twitter/with_invalid_credentials_displays_a_401_error_modal.yml b/test/data/vcr_cassettes/system/channels/twitter/invalid_displays_a_401_error_modal.yml similarity index 100% rename from test/data/vcr_cassettes/system/admin/channel/twitter/with_invalid_credentials_displays_a_401_error_modal.yml rename to test/data/vcr_cassettes/system/channels/twitter/invalid_displays_a_401_error_modal.yml