Refactoring: Migrated Capybara system tests to folder structure that matches JS app URL path.
This commit is contained in:
parent
82149f463a
commit
ddd49271e2
12 changed files with 157 additions and 145 deletions
|
@ -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
|
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -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
|
|
22
spec/system/channels/email_spec.rb
Normal file
22
spec/system/channels/email_spec.rb
Normal file
|
@ -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
|
42
spec/system/channels/twitter_spec.rb
Normal file
42
spec/system/channels/twitter_spec.rb
Normal file
|
@ -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
|
44
spec/system/manage/calendars_spec.rb
Normal file
44
spec/system/manage/calendars_spec.rb
Normal file
|
@ -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
|
|
@ -2,6 +2,38 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Manage > Trigger', type: :system do
|
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 'Perform' do
|
||||||
|
|
||||||
context 'Tags' do
|
context 'Tags' do
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
require 'rails_helper'
|
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
|
before { visit 'settings/ticket' }
|
||||||
it 'enable and disable feature' do
|
|
||||||
|
|
||||||
click(:manage)
|
describe 'owner auto-assignment' do
|
||||||
|
|
||||||
|
it 'enables/disables Setting ticket_auto_assignment' do
|
||||||
|
|
||||||
within(:active_content) do
|
within(:active_content) do
|
||||||
click(:href, '#settings/ticket')
|
|
||||||
click(:href, '#auto_assignment')
|
click(:href, '#auto_assignment')
|
||||||
expect(page).to have_field('ticket_auto_assignment', checked: false, visible: false)
|
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)
|
expect(page).to have_field('ticket_auto_assignment', checked: true, visible: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
refresh
|
refresh
|
||||||
|
|
||||||
within(:active_content) do
|
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)
|
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)
|
expect(page).to have_field('ticket_auto_assignment', checked: false, visible: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,10 +1,11 @@
|
||||||
require 'rails_helper'
|
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
|
it 'switch maintenance_login on' do
|
||||||
Setting.set 'maintenance_login', false
|
Setting.set 'maintenance_login', false
|
||||||
|
|
||||||
open_page
|
visit 'system/maintenance'
|
||||||
|
refresh # ensure changed Setting is loaded
|
||||||
|
|
||||||
find('.js-loginSetting label').click
|
find('.js-loginSetting label').click
|
||||||
find('.js-loginSetting input', visible: :all).check # required for chrome
|
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
|
it 'switch maintenance_login off' do
|
||||||
Setting.set 'maintenance_login', true
|
Setting.set 'maintenance_login', true
|
||||||
|
|
||||||
open_page
|
visit 'system/maintenance'
|
||||||
|
refresh # ensure changed Setting is loaded
|
||||||
|
|
||||||
find('.js-loginSetting label').click
|
find('.js-loginSetting label').click
|
||||||
find('.js-loginSetting input', visible: :all).uncheck # required for chrome
|
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
|
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
|
expect(find('.js-loginPreview [data-name="message"]')).to have_text message
|
||||||
end
|
end
|
||||||
|
@ -39,7 +42,8 @@ RSpec.describe 'Admin > Maintenance login message', type: :system do
|
||||||
|
|
||||||
Setting.set 'maintenance_login_message', message_prefix
|
Setting.set 'maintenance_login_message', message_prefix
|
||||||
|
|
||||||
open_page
|
visit 'system/maintenance'
|
||||||
|
refresh # ensure changed Setting is loaded
|
||||||
|
|
||||||
within(:active_content) do
|
within(:active_content) do
|
||||||
elem = find('#maintenance-message.hero-unit')
|
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}" }
|
wait(10).until { expect(Setting.get('maintenance_login_message')).to eq "#{message_prefix}#{message_suffix}" }
|
||||||
end
|
end
|
||||||
|
|
||||||
def open_page
|
|
||||||
refresh # make sure initial Setting are applied
|
|
||||||
|
|
||||||
click(:manage)
|
|
||||||
click(:href, '#system/maintenance')
|
|
||||||
end
|
|
||||||
end
|
end
|
Loading…
Reference in a new issue