Maintenance: Port old integration tests to capybara.

This commit is contained in:
Bola Ahmed Buari 2021-11-11 07:47:39 +03:00 committed by Martin Gruner
parent a9f014c700
commit 80e76fc43d
6 changed files with 319 additions and 346 deletions

View file

@ -45,7 +45,6 @@ if [ "$LEVEL" == '1' ]; then
rm test/browser/agent_user_profile_test.rb rm test/browser/agent_user_profile_test.rb
rm test/browser/customer_ticket_create_test.rb rm test/browser/customer_ticket_create_test.rb
rm test/browser/first_steps_test.rb rm test/browser/first_steps_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
# test/browser/manage_test.rb # test/browser/manage_test.rb
# test/browser/swich_to_user_test.rb # test/browser/swich_to_user_test.rb
@ -94,7 +93,6 @@ elif [ "$LEVEL" == '2' ]; then
rm test/browser/agent_user_profile_test.rb rm test/browser/agent_user_profile_test.rb
rm test/browser/customer_ticket_create_test.rb rm test/browser/customer_ticket_create_test.rb
rm test/browser/first_steps_test.rb rm test/browser/first_steps_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/manage_test.rb rm test/browser/manage_test.rb
rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_session_test.rb
@ -142,7 +140,6 @@ elif [ "$LEVEL" == '3' ]; then
rm test/browser/agent_user_profile_test.rb rm test/browser/agent_user_profile_test.rb
rm test/browser/customer_ticket_create_test.rb rm test/browser/customer_ticket_create_test.rb
rm test/browser/first_steps_test.rb rm test/browser/first_steps_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/manage_test.rb rm test/browser/manage_test.rb
rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_session_test.rb
@ -190,7 +187,6 @@ elif [ "$LEVEL" == '4' ]; then
rm test/browser/agent_user_profile_test.rb rm test/browser/agent_user_profile_test.rb
# test/browser/customer_ticket_create_test.rb # test/browser/customer_ticket_create_test.rb
rm test/browser/first_steps_test.rb rm test/browser/first_steps_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/manage_test.rb rm test/browser/manage_test.rb
rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_session_test.rb
@ -237,7 +233,6 @@ elif [ "$LEVEL" == '5' ]; then
# test/browser/agent_user_profile_test.rb # test/browser/agent_user_profile_test.rb
rm test/browser/customer_ticket_create_test.rb rm test/browser/customer_ticket_create_test.rb
rm test/browser/first_steps_test.rb rm test/browser/first_steps_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/manage_test.rb rm test/browser/manage_test.rb
rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_session_test.rb
@ -287,7 +282,6 @@ elif [ "$LEVEL" == '6' ]; then
rm test/browser/agent_user_profile_test.rb rm test/browser/agent_user_profile_test.rb
rm test/browser/customer_ticket_create_test.rb rm test/browser/customer_ticket_create_test.rb
# test/browser/first_steps_test.rb # test/browser/first_steps_test.rb
# test/browser/integration_test.rb
# test/browser/keyboard_shortcuts_test.rb # test/browser/keyboard_shortcuts_test.rb
rm test/browser/manage_test.rb rm test/browser/manage_test.rb
rm test/browser/taskbar_session_test.rb rm test/browser/taskbar_session_test.rb

View file

@ -0,0 +1,88 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'rails_helper'
RSpec.describe 'Manage > Integration > Clearbit', type: :system do
let(:api_key) { 'some_api_key' }
let(:source) { 'source1' }
let(:destination) { 'destination1' }
before do
visit 'system/integration/clearbit'
# enable clearbit
check 'setting-switch', { allow_label_click: true }
end
context 'for clearbit config' do
before do
within :active_content, '.main' do
fill_in 'api_key', with: api_key
within '.js-userSync .js-new' do
fill_in 'source', with: source
fill_in 'destination', with: destination
click '.js-add'
end
click_button
end
end
shared_examples 'showing set config' do
it 'shows the set api_key' do
within :active_content, '.main' do
expect(page).to have_field('api_key', with: api_key)
end
end
it 'shows the set source' do
within :active_content, '.main .js-userSync' do
expect(page).to have_field('source', with: source)
end
end
it 'shows the set destination' do
within :active_content, '.main .js-userSync' do
expect(page).to have_field('destination', with: destination)
end
end
end
context 'when added' do
it_behaves_like 'showing set config'
end
context 'when page is re-navigated back to integration page' do
before do
visit 'dashboard'
visit 'system/integration/clearbit'
end
it_behaves_like 'showing set config'
end
context 'when page is reloaded' do
before { refresh }
it_behaves_like 'showing set config'
end
context 'when disabled with changed config' do
before do
# disable clearbit
uncheck 'setting-switch', { allow_label_click: true }
end
let(:api_key) { '-empty-' }
it_behaves_like 'showing set config'
it 'does not have the old api key' do
within :active_content, '.main' do
expect(page).to have_no_field('api_key', with: 'some_api_key')
end
end
end
end
end

View file

@ -0,0 +1,70 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'rails_helper'
RSpec.describe 'Manage > Integration > Icinga', type: :system do
let(:icinga_sender) { 'some@othersender.com' }
let(:icinga_auto_close) { 'no' }
before do
visit 'system/integration/icinga'
# enable icinga
check 'setting-switch', { allow_label_click: true }
end
context 'for icinga config' do
before do
within :active_content, '.main' do
fill_in 'icinga_sender', with: icinga_sender
select icinga_auto_close, from: 'icinga_auto_close'
click_button
end
end
shared_examples 'showing set config' do
it 'shows the set icinga_sender' do
within :active_content, '.main' do
expect(page).to have_field('icinga_sender', with: icinga_sender)
end
end
it 'shows the set icinga_auto_close' do
within :active_content, '.main' do
expect(page).to have_field('icinga_auto_close', type: 'select', text: icinga_auto_close)
end
end
end
context 'when added' do
it_behaves_like 'showing set config'
end
context 'when page is re-navigated back to integration page' do
before do
visit 'dashboard'
visit 'system/integration/icinga'
end
it_behaves_like 'showing set config'
end
context 'when page is reloaded' do
before { refresh }
it_behaves_like 'showing set config'
end
context 'when disabled with changed config' do
before do
# disable icinga
uncheck 'setting-switch', { allow_label_click: true }
end
let(:icinga_sender) { 'icinga@monitoring.example.com' }
let(:icinga_auto_close) { 'yes' }
it_behaves_like 'showing set config'
end
end
end

View file

@ -0,0 +1,95 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'rails_helper'
RSpec.describe 'Manage > Integration > sipgate.io', type: :system do
let(:caller_id) { '0411234567' }
let(:note) { 'block spam caller id' }
before do
visit 'system/integration/sipgate'
# enable sipgate
check 'setting-switch', { allow_label_click: true }
end
context 'for Blocked caller ids based on sender caller id' do
before do
within :active_content, '.main .js-inboundBlockCallerId' do
fill_in 'caller_id', with: caller_id
fill_in 'note', with: note
click '.js-add'
end
click_button
end
shared_examples 'showing added caller id details' do
it 'shows the blocked caller id' do
within :active_content, '.main .js-inboundBlockCallerId' do
expect(page).to have_field('caller_id', with: caller_id)
end
end
it 'shows the blocked caller id note' do
within :active_content, '.main .js-inboundBlockCallerId' do
expect(page).to have_field('note', with: note)
end
end
end
context 'when added' do
it_behaves_like 'showing added caller id details'
end
context 'when page is re-navigated back to integration page' do
before do
visit 'dashboard'
visit 'system/integration/sipgate'
end
it_behaves_like 'showing added caller id details'
end
context 'when page is reloaded' do
before { refresh }
it_behaves_like 'showing added caller id details'
end
context 'when removed' do
before do
within :active_content, '.main .js-inboundBlockCallerId' do
click '.js-remove'
end
click_button
end
shared_examples 'not showing removed caller id details' do
it 'does not show the blocked caller id' do
within :active_content, '.main .js-inboundBlockCallerId' do
expect(page).to have_no_field('caller_id', with: caller_id)
end
end
it 'does not show the blocked caller id note' do
within :active_content, '.main .js-inboundBlockCallerId' do
expect(page).to have_no_field('note', with: note)
end
end
end
it_behaves_like 'not showing removed caller id details'
context 'when page is re-navigated back to integration page' do
before do
visit 'dashboard'
visit 'system/integration/sipgate'
end
it_behaves_like 'not showing removed caller id details'
end
end
end
end

View file

@ -0,0 +1,66 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'rails_helper'
RSpec.describe 'Manage > Integration > Slack', type: :system do
let(:group_ids) { 'Users' }
let(:webhook) { 'http://some_url/webhook/123' }
let(:username) { 'someuser' }
before do
visit 'system/integration/slack'
# enable slack
check 'setting-switch', { allow_label_click: true }
end
context 'for slack config' do
before do
within :active_content, '.main' do
select group_ids, from: 'group_ids'
fill_in 'webhook', with: webhook
fill_in 'username', with: username
click_button
end
end
shared_examples 'showing set config' do
it 'shows the set group_ids' do
within :active_content, '.main' do
expect(page).to have_field('group_ids', type: 'select', text: group_ids)
end
end
it 'shows the set webhook' do
within :active_content, '.main' do
expect(page).to have_field('webhook', with: webhook)
end
end
it 'shows the set username' do
within :active_content, '.main' do
expect(page).to have_field('username', with: username)
end
end
end
context 'when added' do
it_behaves_like 'showing set config'
end
context 'when page is re-navigated back to integration page' do
before do
visit 'dashboard'
visit 'system/integration/slack'
end
it_behaves_like 'showing set config'
end
context 'when page is reloaded' do
before { refresh }
it_behaves_like 'showing set config'
end
end
end

View file

@ -1,340 +0,0 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'browser_test_helper'
class IntegrationTest < TestCase
def test_sipgate
@browser = browser_instance
login(
username: 'admin@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all
# change settings
click(css: 'a[href="#manage"]')
click(css: 'a[href="#system/integration"]')
click(css: 'a[href="#system/integration/sipgate"]')
sleep 2
switch(
css: '.content.active .main .js-switch',
type: 'on',
)
set(
css: '.content.active .main .js-inboundBlockCallerId input[name=caller_id]',
value: '041 1234567',
)
set(
css: '.content.active .main .js-inboundBlockCallerId input[name=note]',
value: 'block spam caller id',
)
click(css: '.content.active .main .js-inboundBlockCallerId .js-add')
click(css: '.content.active .main .js-submit')
exists(
css: '.content.active .main .js-inboundBlockCallerId [value="0411234567"]',
)
exists(
css: '.content.active .main .js-inboundBlockCallerId [value="block spam caller id"]',
)
click(css: 'a[href="#dashboard"]')
click(css: 'a[href="#manage"]')
click(css: 'a[href="#system/integration"]')
click(css: 'a[href="#system/integration/sipgate"]')
exists(
css: '.content.active .main .js-inboundBlockCallerId [value="0411234567"]',
)
exists(
css: '.content.active .main .js-inboundBlockCallerId [value="block spam caller id"]',
)
reload
exists(
css: '.content.active .main .js-inboundBlockCallerId [value="0411234567"]',
)
exists(
css: '.content.active .main .js-inboundBlockCallerId [value="block spam caller id"]',
)
click(css: '.content.active .main .js-inboundBlockCallerId .js-remove')
click(css: '.content.active .main .js-submit')
sleep 6
switch(
css: '.content.active .main .js-switch',
type: 'off',
)
reload
exists_not(
css: '.content.active .main .js-inboundBlockCallerId [value="0411234567"]',
)
exists_not(
css: '.content.active .main .js-inboundBlockCallerId [value="block spam caller id"]',
)
end
def test_slack
@browser = browser_instance
login(
username: 'admin@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all
# change settings
click(css: 'a[href="#manage"]')
click(css: 'a[href="#system/integration"]')
click(css: 'a[href="#system/integration/slack"]')
sleep 2
switch(
css: '.content.active .main .js-switch',
type: 'on',
)
click(css: '.content.active .main .checkbox-replacement')
select(
css: '.content.active .main select[name="group_ids"]',
value: 'Users',
)
set(
css: '.content.active .main input[name="webhook"]',
value: 'http://some_url/webhook/123',
)
set(
css: '.content.active .main input[name="username"]',
value: 'someuser',
)
click(css: '.content.active .main .js-submit')
match(
css: '.content.active .main select[name="group_ids"]',
value: 'Users',
)
match(
css: '.content.active .main input[name="webhook"]',
value: 'http://some_url/webhook/123',
)
match(
css: '.content.active .main input[name="username"]',
value: 'someuser',
)
click(css: 'a[href="#dashboard"]')
click(css: 'a[href="#manage"]')
click(css: 'a[href="#system/integration"]')
click(css: 'a[href="#system/integration/slack"]')
match(
css: '.content.active .main select[name="group_ids"]',
value: 'Users',
)
match(
css: '.content.active .main input[name="webhook"]',
value: 'http://some_url/webhook/123',
)
match(
css: '.content.active .main input[name="username"]',
value: 'someuser',
)
reload
match(
css: '.content.active .main select[name="group_ids"]',
value: 'Users',
)
match(
css: '.content.active .main input[name="webhook"]',
value: 'http://some_url/webhook/123',
)
match(
css: '.content.active .main input[name="username"]',
value: 'someuser',
)
switch(
css: '.content.active .main .js-switch',
type: 'off',
)
end
def test_clearbit
@browser = browser_instance
login(
username: 'admin@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all
# change settings
click(css: 'a[href="#manage"]')
click(css: 'a[href="#system/integration"]')
click(css: 'a[href="#system/integration/clearbit"]')
sleep 2
switch(
css: '.content.active .main .js-switch',
type: 'on',
)
set(
css: '.content.active .main input[name="api_key"]',
value: 'some_api_key',
)
set(
css: '.content.active .main .js-userSync .js-new [name="source"]',
value: 'source1',
)
set(
css: '.content.active .main .js-userSync .js-new [name="destination"]',
value: 'destination1',
)
click(css: '.content.active .main .js-userSync .js-add')
click(css: '.content.active .main .js-submit')
click(css: 'a[href="#dashboard"]')
click(css: 'a[href="#manage"]')
click(css: 'a[href="#system/integration"]')
click(css: 'a[href="#system/integration/clearbit"]')
match(
css: '.content.active .main input[name="api_key"]',
value: 'some_api_key',
)
exists(
css: '.content.active .main .js-userSync [value="source1"]',
)
exists(
css: '.content.active .main .js-userSync [value="destination1"]',
)
reload
match(
css: '.content.active .main input[name="api_key"]',
value: 'some_api_key',
)
exists(
css: '.content.active .main .js-userSync [value="source1"]',
)
exists(
css: '.content.active .main .js-userSync [value="destination1"]',
)
switch(
css: '.content.active .main .js-switch',
type: 'off',
)
set(
css: '.content.active .main input[name="api_key"]',
value: '-empty-',
)
click(css: '.content.active .main .js-submit')
reload
match_not(
css: '.content.active .main input[name="api_key"]',
value: 'some_api_key',
)
match(
css: '.content.active .main input[name="api_key"]',
value: '-empty-',
)
exists(
css: '.content.active .main .js-userSync [value="source1"]',
)
exists(
css: '.content.active .main .js-userSync [value="destination1"]',
)
end
def test_icinga
@browser = browser_instance
login(
username: 'admin@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all
# change settings
click(css: 'a[href="#manage"]')
click(css: 'a[href="#system/integration"]')
click(css: 'a[href="#system/integration/icinga"]')
sleep 2
switch(
css: '.content.active .main .js-switch',
type: 'on',
)
set(
css: '.content.active .main input[name="icinga_sender"]',
value: 'some@othersender.com',
)
select(
css: '.content.active .main select[name="icinga_auto_close"]',
value: 'no',
)
click(css: '.content.active .main .js-submit')
match(
css: '.content.active .main input[name="icinga_sender"]',
value: 'some@othersender.com',
)
match(
css: '.content.active .main select[name="icinga_auto_close"]',
value: 'no',
)
click(css: 'a[href="#dashboard"]')
click(css: 'a[href="#manage"]')
click(css: 'a[href="#system/integration"]')
click(css: 'a[href="#system/integration/icinga"]')
match(
css: '.content.active .main input[name="icinga_sender"]',
value: 'some@othersender.com',
)
match(
css: '.content.active .main select[name="icinga_auto_close"]',
value: 'no',
)
reload
match(
css: '.content.active .main input[name="icinga_sender"]',
value: 'some@othersender.com',
)
match(
css: '.content.active .main select[name="icinga_auto_close"]',
value: 'no',
)
switch(
css: '.content.active .main .js-switch',
type: 'off',
)
set(
css: '.content.active .main input[name="icinga_sender"]',
value: 'icinga@monitoring.example.com',
)
select(
css: '.content.active .main select[name="icinga_auto_close"]',
value: 'yes',
)
click(css: '.content.active .main .js-submit')
match(
css: '.content.active .main input[name="icinga_sender"]',
value: 'icinga@monitoring.example.com',
)
match(
css: '.content.active .main select[name="icinga_auto_close"]',
value: 'yes',
)
end
end