Maintenance: Port maintenance session message test to capybara.

This commit is contained in:
Dominik Klein 2021-10-08 12:34:31 +02:00
parent df6fe54b66
commit 22cd8f3376
4 changed files with 85 additions and 190 deletions

View file

@ -49,7 +49,6 @@ if [ "$LEVEL" == '1' ]; then
rm test/browser/first_steps_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb
# test/browser/maintenance_session_message_test.rb
# test/browser/manage_test.rb
# test/browser/monitoring_test.rb
rm test/browser/integration_sipgate_test.rb
@ -105,7 +104,6 @@ elif [ "$LEVEL" == '2' ]; then
rm test/browser/first_steps_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_session_message_test.rb
rm test/browser/manage_test.rb
rm test/browser/monitoring_test.rb
rm test/browser/integration_sipgate_test.rb
@ -161,7 +159,6 @@ elif [ "$LEVEL" == '3' ]; then
rm test/browser/first_steps_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_session_message_test.rb
rm test/browser/manage_test.rb
rm test/browser/monitoring_test.rb
rm test/browser/integration_sipgate_test.rb
@ -217,7 +214,6 @@ elif [ "$LEVEL" == '4' ]; then
rm test/browser/first_steps_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_session_message_test.rb
rm test/browser/manage_test.rb
rm test/browser/monitoring_test.rb
rm test/browser/integration_sipgate_test.rb
@ -272,7 +268,6 @@ elif [ "$LEVEL" == '5' ]; then
rm test/browser/first_steps_test.rb
rm test/browser/integration_test.rb
rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_session_message_test.rb
rm test/browser/manage_test.rb
rm test/browser/monitoring_test.rb
rm test/browser/integration_sipgate_test.rb
@ -330,7 +325,6 @@ elif [ "$LEVEL" == '6' ]; then
# test/browser/first_steps_test.rb
# test/browser/integration_test.rb
# test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_session_message_test.rb
rm test/browser/manage_test.rb
rm test/browser/monitoring_test.rb
# rm test/browser/integration_sipgate_test.rb

View file

@ -2,14 +2,18 @@
require 'rails_helper'
RSpec.describe 'Maintenance App Version', type: :system do
it 'check that new version is present' do
RSpec.describe 'System > Maintenance - App Version', type: :system do
it 'check that new version modal dialog is present' do
page.execute_script 'App.Event.trigger("maintenance", {type:"app_version", app_version:"1234:false"} )'
expect(page).to have_no_text('new version')
page.execute_script 'App.Event.trigger("maintenance", {type:"app_version", app_version:"1234:true"} )'
expect(page).to have_text('new version')
modal_ready(timeout: 10)
within '.modal-dialog' do
expect(page).to have_text('new version')
end
end
end

View file

@ -0,0 +1,78 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'rails_helper'
RSpec.describe 'System > Maintenance - Session Message', type: :system do
let(:agent) { User.find_by(login: 'agent1@example.com') }
let(:session_message_title) { 'Testing <b>Session Message Title</b>' }
let(:session_message_text) { "message <b>1äöüß</b> Session Message Title\n\n\nhttps://zammad.org" }
def check_sesion_message_content(title, text)
expect(page).to have_text(title)
expect(page).to have_text(text)
end
context 'when maintenance session message is used and a open session exists' do
before do
using_session(:second_browser) do
login(
username: agent.login,
password: 'test',
)
end
end
it 'check that the maintenance session message appears' do
visit 'system/maintenance'
within :active_content do
fill_in 'head', with: session_message_title
find('.js-Message .js-textarea[data-name="message"]').send_keys(session_message_text)
click '.js-Message button.js-submit'
end
using_session(:second_browser) do
modal_ready
within '.modal-dialog' do
check_sesion_message_content(session_message_title, session_message_text)
click 'div.modal-header .js-close'
end
modal_disappear
end
within :active_content do
expect(page).to have_no_text(session_message_title)
expect(page).to have_no_text(session_message_text)
end
end
it 'check that the maintenance session message appears with browser reload' do
message_title = "#{session_message_title} #2"
message_text = "#{session_message_text} #2"
visit 'system/maintenance'
within :active_content do
fill_in 'head', with: "#{message_title} #2"
find('.js-Message .js-textarea[data-name="message"]').send_keys("#{message_text} #2")
check 'reload', { allow_label_click: true }
click '.js-Message button.js-submit'
end
using_session(:second_browser) do
modal_ready
within '.modal-dialog' do
check_sesion_message_content(message_title, message_text)
expect(page).to have_text('Continue session')
end
end
end
end
end

View file

@ -1,181 +0,0 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'browser_test_helper'
class MaintenanceSessionMessageTest < TestCase
def test_message
string = SecureRandom.uuid
title_html = "test <b>#{string}</b>"
title_text = "test <b>#{string}<\/b>"
message_html = "message <b>1äöüß</b> #{string}\n\n\nhttps://zammad.org"
message_text = "message <b>1äöüß</b> #{string}\n\n\nhttps://zammad.org"
# check #1
browser1 = browser_instance
login(
browser: browser1,
username: 'admin@example.com',
password: 'test',
url: browser_url,
)
browser2 = browser_instance
login(
browser: browser2,
username: 'agent1@example.com',
password: 'test',
url: browser_url,
)
click(
browser: browser1,
css: 'a[href="#manage"]',
)
click(
browser: browser1,
css: 'a[href="#system/maintenance"]',
)
set(
browser: browser1,
css: '.content.active .js-Message input[name="head"]',
value: title_html,
)
set(
browser: browser1,
css: '.content.active .js-Message .js-textarea[data-name="message"]',
value: message_html,
)
click(
browser: browser1,
css: '.content.active .js-Message button.js-submit',
)
modal_ready(browser: browser2)
watch_for(
browser: browser2,
css: '.modal',
value: title_text,
)
watch_for(
browser: browser2,
css: '.modal',
value: message_text,
)
match_not(
browser: browser1,
css: 'body',
value: message_text,
)
click(
browser: browser2,
css: 'div.modal-header .js-close',
)
modal_disappear(browser: browser2)
# check #2
click(
browser: browser1,
css: 'a[href="#manage"]',
)
click(
browser: browser1,
css: 'a[href="#system/maintenance"]',
)
set(
browser: browser1,
css: '.content.active .js-Message input[name="head"]',
value: "#{title_html} #2",
)
set(
browser: browser1,
css: '.content.active .js-Message .js-textarea[data-name="message"]',
value: "#{message_html} #2",
)
click(
browser: browser1,
css: '.content.active .js-Message button.js-submit',
)
modal_ready(browser: browser2)
watch_for(
browser: browser2,
css: '.modal',
value: "#{title_text} #2",
)
watch_for(
browser: browser2,
css: '.modal',
value: "#{message_text} #2",
)
match_not(
browser: browser1,
css: 'body',
value: message_text,
)
click(
browser: browser2,
css: 'div.modal-header .js-close',
)
modal_disappear(browser: browser2)
# check #3
click(
browser: browser1,
css: 'a[href="#manage"]',
)
click(
browser: browser1,
css: 'a[href="#system/maintenance"]',
)
set(
browser: browser1,
css: '.content.active .js-Message input[name="head"]',
value: "#{title_html} #3",
)
set(
browser: browser1,
css: '.content.active .js-Message .js-textarea[data-name="message"]',
value: "#{message_html} #3",
)
click(
browser: browser1,
css: '.content.active .js-Message input[name="reload"]',
)
click(
browser: browser1,
css: '.content.active .js-Message button.js-submit',
)
modal_ready(browser: browser2)
watch_for(
browser: browser2,
css: '.modal',
value: "#{title_text} #3",
)
watch_for(
browser: browser2,
css: '.modal',
value: "#{message_text} #3",
)
watch_for(
browser: browser2,
css: '.modal',
value: 'Continue session',
)
match_not(
browser: browser1,
css: 'body',
value: message_text,
)
end
end