2021-06-01 12:20:20 +00:00
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
2019-01-21 17:17:18 +00:00
require 'rails_helper'
2021-08-25 12:24:42 +00:00
require 'system/examples/core_workflow_examples'
2019-09-02 13:28:39 +00:00
require 'system/examples/text_modules_examples'
2019-07-03 16:14:28 +00:00
2019-01-21 17:17:18 +00:00
RSpec . describe 'Ticket Create' , type : :system do
context 'when applying ticket templates' do
2020-06-19 09:17:18 +00:00
let ( :agent ) { create ( :agent , groups : [ permitted_group ] ) }
2020-04-30 15:38:57 +00:00
let ( :permitted_group ) { create ( :group ) }
let ( :unpermitted_group ) { create ( :group ) }
let! ( :template ) { create ( :template , :dummy_data , group : unpermitted_group , owner : agent ) }
2019-01-21 17:17:18 +00:00
2020-04-30 15:38:57 +00:00
# Regression test for issue #2424 - Unavailable ticket template attributes get applied
2020-06-18 11:51:25 +00:00
it 'unavailable attributes do not get applied' , authenticated_as : :agent do
2019-01-21 17:17:18 +00:00
visit 'ticket/create'
2019-02-04 06:56:18 +00:00
2020-04-30 15:38:57 +00:00
use_template ( template )
2020-08-26 12:31:33 +00:00
expect ( page ) . to have_no_selector 'select[name="group_id"]'
2019-01-21 17:17:18 +00:00
end
end
2019-07-03 16:14:28 +00:00
context 'when using text modules' do
2019-09-02 13:28:39 +00:00
include_examples 'text modules' , path : 'ticket/create'
2019-07-03 16:14:28 +00:00
end
2020-06-02 11:01:16 +00:00
2020-06-15 22:11:29 +00:00
context 'S/MIME' , authenticated_as : :authenticate do
def authenticate
2020-06-02 11:01:16 +00:00
Setting . set ( 'smime_integration' , true )
2020-09-11 06:17:27 +00:00
Setting . set ( 'smime_config' , smime_config ) if defined? ( smime_config )
2020-06-15 22:11:29 +00:00
current_user
2020-06-02 11:01:16 +00:00
end
context 'no certificate present' do
2020-06-15 22:11:29 +00:00
let! ( :template ) { create ( :template , :dummy_data ) }
let ( :current_user ) { true }
2020-06-02 11:01:16 +00:00
it 'has no security selections' do
visit 'ticket/create'
within ( :active_content ) do
use_template ( template )
2020-08-26 12:31:33 +00:00
expect ( page ) . to have_no_css ( 'div.js-securityEncrypt.btn--active' )
expect ( page ) . to have_no_css ( 'div.js-securitySign.btn--active' )
2020-06-02 11:01:16 +00:00
click '.js-submit'
expect ( page ) . to have_css ( '.ticket-article-item' , count : 1 )
open_article_meta
2020-08-26 12:31:33 +00:00
expect ( page ) . to have_no_css ( 'span' , text : 'Signed' )
expect ( page ) . to have_no_css ( 'span' , text : 'Encrypted' )
2020-06-02 11:01:16 +00:00
security_result = Ticket :: Article . last . preferences [ 'security' ]
expect ( security_result [ 'encryption' ] [ 'success' ] ) . to be nil
expect ( security_result [ 'sign' ] [ 'success' ] ) . to be nil
end
end
end
2020-06-15 22:11:29 +00:00
context 'private key configured' do
let ( :current_user ) { agent }
2020-06-02 11:01:16 +00:00
let! ( :template ) { create ( :template , :dummy_data , group : group , owner : agent , customer : customer ) }
let ( :system_email_address ) { 'smime1@example.com' }
let ( :email_address ) { create ( :email_address , email : system_email_address ) }
let ( :group ) { create ( :group , email_address : email_address ) }
let ( :agent_groups ) { [ group ] }
2020-06-19 09:17:18 +00:00
let ( :agent ) { create ( :agent , groups : agent_groups ) }
2020-06-02 11:01:16 +00:00
before do
create ( :smime_certificate , :with_private , fixture : system_email_address )
end
context 'recipient certificate present' do
let ( :recipient_email_address ) { 'smime2@example.com' }
2020-06-19 09:17:18 +00:00
let ( :customer ) { create ( :customer , email : recipient_email_address ) }
2020-06-02 11:01:16 +00:00
before do
create ( :smime_certificate , fixture : recipient_email_address )
end
it 'plain' do
visit 'ticket/create'
within ( :active_content ) do
use_template ( template )
# wait till S/MIME check AJAX call is ready
expect ( page ) . to have_css ( 'div.js-securityEncrypt.btn--active' , wait : 5 )
expect ( page ) . to have_css ( 'div.js-securitySign.btn--active' , wait : 5 )
# deactivate encryption and signing
click '.js-securityEncrypt'
click '.js-securitySign'
click '.js-submit'
expect ( page ) . to have_css ( '.ticket-article-item' , count : 1 )
open_article_meta
2020-08-26 12:31:33 +00:00
expect ( page ) . to have_no_css ( 'span' , text : 'Signed' )
expect ( page ) . to have_no_css ( 'span' , text : 'Encrypted' )
2020-06-02 11:01:16 +00:00
security_result = Ticket :: Article . last . preferences [ 'security' ]
expect ( security_result [ 'encryption' ] [ 'success' ] ) . to be nil
expect ( security_result [ 'sign' ] [ 'success' ] ) . to be nil
end
end
it 'signed' do
visit 'ticket/create'
within ( :active_content ) do
use_template ( template )
# wait till S/MIME check AJAX call is ready
expect ( page ) . to have_css ( 'div.js-securityEncrypt.btn--active' , wait : 5 )
expect ( page ) . to have_css ( 'div.js-securitySign.btn--active' , wait : 5 )
# deactivate encryption
click '.js-securityEncrypt'
click '.js-submit'
expect ( page ) . to have_css ( '.ticket-article-item' , count : 1 )
open_article_meta
expect ( page ) . to have_css ( 'span' , text : 'Signed' )
2020-08-26 12:31:33 +00:00
expect ( page ) . to have_no_css ( 'span' , text : 'Encrypted' )
2020-06-02 11:01:16 +00:00
security_result = Ticket :: Article . last . preferences [ 'security' ]
expect ( security_result [ 'encryption' ] [ 'success' ] ) . to be nil
expect ( security_result [ 'sign' ] [ 'success' ] ) . to be true
end
end
it 'encrypted' do
visit 'ticket/create'
within ( :active_content ) do
use_template ( template )
# wait till S/MIME check AJAX call is ready
expect ( page ) . to have_css ( 'div.js-securityEncrypt.btn--active' , wait : 5 )
expect ( page ) . to have_css ( 'div.js-securitySign.btn--active' , wait : 5 )
# deactivate signing
click '.js-securitySign'
click '.js-submit'
expect ( page ) . to have_css ( '.ticket-article-item' , count : 1 )
open_article_meta
2020-08-26 12:31:33 +00:00
expect ( page ) . to have_no_css ( 'span' , text : 'Signed' )
2020-06-02 11:01:16 +00:00
expect ( page ) . to have_css ( 'span' , text : 'Encrypted' )
security_result = Ticket :: Article . last . preferences [ 'security' ]
expect ( security_result [ 'encryption' ] [ 'success' ] ) . to be true
expect ( security_result [ 'sign' ] [ 'success' ] ) . to be nil
end
end
it 'signed and encrypted' do
visit 'ticket/create'
within ( :active_content ) do
use_template ( template )
# wait till S/MIME check AJAX call is ready
expect ( page ) . to have_css ( 'div.js-securityEncrypt.btn--active' , wait : 5 )
expect ( page ) . to have_css ( 'div.js-securitySign.btn--active' , wait : 5 )
click '.js-submit'
expect ( page ) . to have_css ( '.ticket-article-item' , count : 1 )
open_article_meta
expect ( page ) . to have_css ( 'span' , text : 'Signed' )
expect ( page ) . to have_css ( 'span' , text : 'Encrypted' )
security_result = Ticket :: Article . last . preferences [ 'security' ]
expect ( security_result [ 'encryption' ] [ 'success' ] ) . to be true
expect ( security_result [ 'sign' ] [ 'success' ] ) . to be true
end
end
context 'Group default behavior' do
let ( :smime_config ) { { } }
shared_examples 'security defaults example' do | sign : , encrypt : |
it " security defaults sign: #{ sign } , encrypt: #{ encrypt } " do
within ( :active_content ) do
encrypt_button = find ( '.js-securityEncrypt' , wait : 5 )
sign_button = find ( '.js-securitySign' , wait : 5 )
active_button_class = '.btn--active'
expect ( encrypt_button . matches_css? ( active_button_class , wait : 2 ) ) . to be ( encrypt )
expect ( sign_button . matches_css? ( active_button_class , wait : 2 ) ) . to be ( sign )
end
end
end
shared_examples 'security defaults' do | sign : , encrypt : |
before do
visit 'ticket/create'
within ( :active_content ) do
use_template ( template )
end
end
include_examples 'security defaults example' , sign : sign , encrypt : encrypt
end
shared_examples 'security defaults group change' do | sign : , encrypt : |
before do
visit 'ticket/create'
within ( :active_content ) do
use_template ( template )
select new_group . name , from : 'group_id'
end
end
include_examples 'security defaults example' , sign : sign , encrypt : encrypt
end
context 'not configured' do
it_behaves_like 'security defaults' , sign : true , encrypt : true
end
context 'configuration present' do
let ( :smime_config ) do
{
'group_id' = > group_defaults
}
end
let ( :group_defaults ) do
{
'default_encryption' = > {
group . id . to_s = > default_encryption ,
} ,
'default_sign' = > {
group . id . to_s = > default_sign ,
}
}
end
let ( :default_sign ) { true }
let ( :default_encryption ) { true }
shared_examples 'sign and encrypt variations' do | check_examples_name |
it_behaves_like check_examples_name , sign : true , encrypt : true
context 'no value' do
let ( :group_defaults ) { { } }
it_behaves_like check_examples_name , sign : true , encrypt : true
end
context 'signing disabled' do
let ( :default_sign ) { false }
it_behaves_like check_examples_name , sign : false , encrypt : true
end
context 'encryption disabled' do
let ( :default_encryption ) { false }
it_behaves_like check_examples_name , sign : true , encrypt : false
end
end
context 'same Group' do
it_behaves_like 'sign and encrypt variations' , 'security defaults'
end
context 'Group change' do
let ( :new_group ) { create ( :group , email_address : email_address ) }
let ( :agent_groups ) { [ group , new_group ] }
let ( :group_defaults ) do
{
'default_encryption' = > {
new_group . id . to_s = > default_encryption ,
} ,
'default_sign' = > {
new_group . id . to_s = > default_sign ,
}
}
end
it_behaves_like 'sign and encrypt variations' , 'security defaults group change'
end
end
end
end
end
end
2020-12-11 12:59:40 +00:00
describe 'object manager attributes maxlength' , authenticated_as : :authenticate , db_strategy : :reset do
def authenticate
create :object_manager_attribute_text , name : 'maxtest' , display : 'maxtest' , screens : attributes_for ( :required_screen ) , data_option : {
'type' = > 'text' ,
'maxlength' = > 3 ,
'null' = > true ,
'translate' = > false ,
'default' = > '' ,
'options' = > { } ,
'relation' = > '' ,
}
ObjectManager :: Attribute . migration_execute
true
end
it 'checks ticket create' do
visit 'ticket/create'
within ( :active_content ) do
fill_in 'maxtest' , with : 'hellu'
expect ( page . find_field ( 'maxtest' ) . value ) . to eq ( 'hel' )
end
end
end
2021-03-10 16:11:14 +00:00
2021-06-18 13:06:22 +00:00
describe 'GitLab Integration' , :integration , authenticated_as : :authenticate , required_envs : %w[ GITLAB_ENDPOINT GITLAB_APITOKEN ] do
2021-03-10 16:11:14 +00:00
let ( :customer ) { create ( :customer ) }
let ( :agent ) { create ( :agent , groups : [ Group . find_by ( name : 'Users' ) ] ) }
let! ( :template ) { create ( :template , :dummy_data , group : Group . find_by ( name : 'Users' ) , owner : agent , customer : customer ) }
def authenticate
Setting . set ( 'gitlab_integration' , true )
Setting . set ( 'gitlab_config' , {
api_token : ENV [ 'GITLAB_APITOKEN' ] ,
endpoint : ENV [ 'GITLAB_ENDPOINT' ] ,
} )
true
end
it 'creates a ticket with links' do
visit 'ticket/create'
within ( :active_content ) do
use_template ( template )
# switch to gitlab sidebar
click ( '.tabsSidebar-tab[data-tab=gitlab]' )
click ( '.sidebar-header-headline.js-headline' )
# add issue
click_on 'Link issue'
fill_in 'link' , with : ENV [ 'GITLAB_ISSUE_LINK' ]
click_on 'Submit'
# verify issue
content = find ( '.sidebar-git-issue-content' )
expect ( content ) . to have_text ( '#1 Example issue' )
expect ( content ) . to have_text ( 'critical' )
expect ( content ) . to have_text ( 'special' )
expect ( content ) . to have_text ( 'important milestone' )
expect ( content ) . to have_text ( 'zammad-robot' )
# create Ticket
click '.js-submit'
# check stored data
expect ( Ticket . last . preferences [ :gitlab ] [ :issue_links ] [ 0 ] ) . to eq ( ENV [ 'GITLAB_ISSUE_LINK' ] )
end
end
end
2021-03-10 16:25:26 +00:00
2021-06-18 13:06:22 +00:00
describe 'GitHub Integration' , :integration , authenticated_as : :authenticate , required_envs : %w[ GITHUB_ENDPOINT GITHUB_APITOKEN ] do
2021-03-10 16:25:26 +00:00
let ( :customer ) { create ( :customer ) }
let ( :agent ) { create ( :agent , groups : [ Group . find_by ( name : 'Users' ) ] ) }
let! ( :template ) { create ( :template , :dummy_data , group : Group . find_by ( name : 'Users' ) , owner : agent , customer : customer ) }
def authenticate
Setting . set ( 'github_integration' , true )
Setting . set ( 'github_config' , {
api_token : ENV [ 'GITHUB_APITOKEN' ] ,
endpoint : ENV [ 'GITHUB_ENDPOINT' ] ,
} )
true
end
it 'creates a ticket with links' do
visit 'ticket/create'
within ( :active_content ) do
use_template ( template )
# switch to github sidebar
click ( '.tabsSidebar-tab[data-tab=github]' )
click ( '.sidebar-header-headline.js-headline' )
# add issue
click_on 'Link issue'
fill_in 'link' , with : ENV [ 'GITHUB_ISSUE_LINK' ]
click_on 'Submit'
# verify issue
content = find ( '.sidebar-git-issue-content' )
expect ( content ) . to have_text ( '#1575 GitHub integration' )
expect ( content ) . to have_text ( 'feature backlog' )
expect ( content ) . to have_text ( 'integration' )
expect ( content ) . to have_text ( '4.0' )
expect ( content ) . to have_text ( 'Thorsten' )
# create Ticket
click '.js-submit'
# check stored data
expect ( Ticket . last . preferences [ :github ] [ :issue_links ] [ 0 ] ) . to eq ( ENV [ 'GITHUB_ISSUE_LINK' ] )
end
end
end
2021-05-17 15:12:45 +00:00
2021-08-25 12:24:42 +00:00
describe 'Core Workflow' do
include_examples 'core workflow' do
let ( :object_name ) { 'Ticket' }
let ( :before_it ) do
lambda {
ensure_websocket ( check_if_pinged : false ) do
visit 'ticket/create'
end
}
end
end
end
2021-05-17 15:12:45 +00:00
# https://github.com/zammad/zammad/issues/2669
context 'when canceling new ticket creation' do
it 'closes the dialog' do
visit 'ticket/create'
task_key = find ( :task_active ) [ 'data-key' ]
expect { click ( '.js-cancel' ) } . to change { has_selector? ( :task_with , task_key , wait : 0 ) } . to ( false )
end
it 'asks for confirmation if the dialog was modified' do
visit 'ticket/create'
task_key = find ( :task_active ) [ 'data-key' ]
find ( '[name=title]' ) . fill_in with : 'Title'
click '.js-cancel'
in_modal do
click '.js-submit'
end
expect ( page ) . to have_no_selector ( :task_with , task_key )
end
2021-10-04 19:05:32 +00:00
it 'asks for confirmation if attachment was added' do
visit 'ticket/create'
within :active_content do
page . find ( 'input#fileUpload_1' , visible : :all ) . set ( Rails . root . join ( 'test/data/mail/mail001.box' ) )
await_empty_ajax_queue
find ( '.js-cancel' ) . click
end
in_modal disappears : false do
expect ( page ) . to have_text 'Tab has changed'
end
end
end
context 'when uploading attachment' do
it 'shows an error if server throws an error' do
allow ( Store ) . to receive ( :add ) { raise 'Error' }
visit 'ticket/create'
within :active_content do
page . find ( 'input#fileUpload_1' , visible : :all ) . set ( Rails . root . join ( 'test/data/mail/mail001.box' ) )
end
in_modal disappears : false do
expect ( page ) . to have_text 'Error'
end
end
2021-05-17 15:12:45 +00:00
end
2021-07-28 14:21:23 +00:00
2021-09-27 10:49:55 +00:00
context 'when closing taskbar tab for new ticket creation' do
it 'close task bar entry after some changes in ticket create form' do
visit 'ticket/create'
within ( :active_content ) do
find ( '[name=title]' ) . fill_in with : 'Title'
end
taskbar_tab_close ( find ( :task_active ) [ 'data-key' ] )
end
end
2021-07-28 14:21:23 +00:00
describe 'customer selection to check the field search' do
before do
create ( :customer , active : true )
create ( :customer , active : false )
end
it 'check for inactive customer in customer/organization selection' do
visit 'ticket/create'
within ( :active_content ) do
find ( '[name=customer_id] ~ .user-select.token-input' ) . fill_in with : '**'
expect ( page ) . to have_css ( 'ul.recipientList > li.recipientList-entry' , minimum : 2 )
expect ( page ) . to have_css ( 'ul.recipientList > li.recipientList-entry.is-inactive' , count : 1 )
end
end
end
2021-09-09 12:08:00 +00:00
2021-09-29 15:17:21 +00:00
context 'when agent and customer user login after another' do
let ( :agent ) { create ( :agent , password : 'test' ) }
let ( :customer ) { create ( :customer , password : 'test' ) }
it 'customer user should not have agent object attributes' , authenticated_as : :agent do
2021-10-07 11:20:51 +00:00
# Log out again, so that we can execute the next login.
2021-09-29 15:17:21 +00:00
logout
# Re-create agent session and fetch object attributes.
login (
username : agent . login ,
password : 'test'
)
visit 'ticket/create'
# Re-remove local object attributes bound to the session
# there was an issue (#1856) where the old attribute values
# persisted and were stored as the original attributes.
logout
# Create customer session and fetch object attributes.
login (
username : customer . login ,
password : 'test'
)
visit 'customer_ticket_new'
expect ( page ) . to have_no_css ( '.newTicket input[name="customer_id"]' )
end
end
2021-09-30 13:57:39 +00:00
context 'when state options have a special translation' , authenticated_as : :authenticate do
let ( :admin_de ) { create ( :admin , preferences : { locale : 'de-de' } ) }
context 'when translated state option has a single quote' do
def authenticate
open_tranlation = Translation . where ( locale : 'de-de' , source : 'open' )
open_tranlation . update ( target : " off'en " )
admin_de
end
it 'shows the translated state options correctly' do
visit 'ticket/create'
expect ( page ) . to have_select ( 'state_id' , with_options : [ " off'en " ] )
end
end
end
2021-09-09 12:08:00 +00:00
describe 'It should be possible to show attributes which are configured shown false #3726' , authenticated_as : :authenticate , db_strategy : :reset do
let ( :field_name ) { SecureRandom . uuid }
let ( :field ) do
create :object_manager_attribute_text , name : field_name , display : field_name , screens : {
'create_middle' = > {
'ticket.agent' = > {
'shown' = > false ,
'required' = > false ,
}
}
}
ObjectManager :: Attribute . migration_execute
end
before do
visit 'ticket/create'
end
context 'when field visible' do
let ( :workflow ) do
create ( :core_workflow ,
object : 'Ticket' ,
perform : { " ticket. #{ field_name } " = > { 'operator' = > 'show' , 'show' = > 'true' } } )
end
def authenticate
field
workflow
true
end
it 'does show up the field' do
expect ( page ) . to have_css ( " div[data-attribute-name=' #{ field_name } '] " )
end
end
context 'when field hidden' do
def authenticate
field
true
end
it 'does not show the field' do
2021-10-26 12:18:42 +00:00
expect ( page ) . to have_css ( " div[data-attribute-name=' #{ field_name } '].is-hidden.is-removed " , visible : :hidden )
2021-09-09 12:08:00 +00:00
end
end
end
2021-10-14 11:00:42 +00:00
describe 'Support workflow mechanism to do pending reminder state hide pending time use case #3790' , authenticated_as : :authenticate do
let ( :template ) { create ( :template , :dummy_data ) }
def add_state
Ticket :: State . create_or_update (
name : 'pending customer feedback' ,
state_type : Ticket :: StateType . find_by ( name : 'pending reminder' ) ,
ignore_escalation : true ,
created_by_id : 1 ,
updated_by_id : 1 ,
)
end
def update_screens
attribute = ObjectManager :: Attribute . get (
object : 'Ticket' ,
name : 'state_id' ,
)
attribute . data_option [ :filter ] = Ticket :: State . by_category ( :viewable ) . pluck ( :id )
attribute . screens [ :create_middle ] [ 'ticket.agent' ] [ :filter ] = Ticket :: State . by_category ( :viewable_agent_new ) . pluck ( :id )
attribute . screens [ :create_middle ] [ 'ticket.customer' ] [ :filter ] = Ticket :: State . by_category ( :viewable_customer_new ) . pluck ( :id )
attribute . screens [ :edit ] [ 'ticket.agent' ] [ :filter ] = Ticket :: State . by_category ( :viewable_agent_edit ) . pluck ( :id )
attribute . screens [ :edit ] [ 'ticket.customer' ] [ :filter ] = Ticket :: State . by_category ( :viewable_customer_edit ) . pluck ( :id )
attribute . save!
end
def create_flow
create ( :core_workflow ,
object : 'Ticket' ,
condition_selected : { 'ticket.state_id' = > { 'operator' = > 'is' , 'value' = > Ticket :: State . find_by ( name : 'pending customer feedback' ) . id . to_s } } ,
perform : { 'ticket.pending_time' = > { 'operator' = > 'remove' , 'remove' = > 'true' } } )
end
def authenticate
add_state
update_screens
create_flow
template
true
end
before do
visit 'ticket/create'
use_template ( template )
end
it 'does make it possible to create pending states where the pending time is optional and not visible' do
select 'pending customer feedback' , from : 'state_id'
click '.js-submit'
expect ( current_url ) . to include ( 'ticket/zoom' )
expect ( Ticket . last . state_id ) . to eq ( Ticket :: State . find_by ( name : 'pending customer feedback' ) . id )
expect ( Ticket . last . pending_time ) . to be nil
end
end
2021-10-26 08:08:09 +00:00
2021-11-03 16:13:13 +00:00
context 'default priority' , authenticated_as : :authenticate do
let ( :template ) { create ( :template , :dummy_data ) }
let ( :ticket_priority ) { create ( :ticket_priority , default_create : true ) }
2021-10-26 08:08:09 +00:00
let ( :another_priority ) { Ticket :: Priority . find ( 1 ) }
let ( :priority_field ) { find ( '[name=priority_id]' ) }
2021-11-03 16:13:13 +00:00
def authenticate
template
ticket_priority
true
end
2021-10-26 08:08:09 +00:00
it 'shows default priority on load' do
visit 'ticket/create'
expect ( priority_field . value ) . to eq ticket_priority . id . to_s
end
it 'does not reset to default priority on reload' do
visit 'ticket/create'
taskbar_timestamp = Taskbar . last . updated_at
priority_field . select another_priority . name
wait . until { Taskbar . last . updated_at != taskbar_timestamp }
refresh
expect ( priority_field . reload . value ) . to eq another_priority . id . to_s
end
it 'saves default priority' do
visit 'ticket/create'
use_template template
click '.js-submit'
expect ( Ticket . last ) . to have_attributes ( priority : ticket_priority )
end
it 'saves different priority if overriden' do
visit 'ticket/create'
use_template template
priority_field . select another_priority . name
click '.js-submit'
expect ( Ticket . last ) . to have_attributes ( priority : another_priority )
end
end
2021-10-26 10:14:35 +00:00
describe 'When looking for customers, it is no longer possible to change into organizations #3815' do
before do
visit 'ticket/create'
# modal reaper ;)
sleep 3
end
context 'when less than 10 customers' do
let ( :organization ) { Organization . first }
it 'has no show more option' do
find ( '[name=customer_id_completion]' ) . fill_in with : 'zam'
expect ( page ) . to have_selector ( " li.js-organization[data-organization-id=' #{ organization . id } '] " )
page . find ( " li.js-organization[data-organization-id=' #{ organization . id } '] " ) . click
expect ( page ) . to have_selector ( " ul.recipientList-organizationMembers[organization-id=' #{ organization . id } '] li.js-showMoreMembers.hidden " , visible : :all )
end
end
context 'when more than 10 customers' , authenticated_as : :authenticate do
def authenticate
customers
true
end
let ( :organization ) { create ( :organization , name : 'Zammed' ) }
let ( :customers ) do
create_list ( :customer , 50 , organization : organization )
end
it 'does paginate through organization' do
find ( '[name=customer_id_completion]' ) . fill_in with : 'zam'
expect ( page ) . to have_selector ( " li.js-organization[data-organization-id=' #{ organization . id } '] " )
page . find ( " li.js-organization[data-organization-id=' #{ organization . id } '] " ) . click
wait ( 5 ) . until { page . all ( " ul.recipientList-organizationMembers[organization-id=' #{ organization . id } '] li " , visible : :all ) . count == 12 } # 10 users + back + show more button
expect ( page ) . to have_selector ( " ul.recipientList-organizationMembers[organization-id=' #{ organization . id } '] li.js-showMoreMembers[organization-member-limit='10'] " )
scroll_into_view ( 'li.js-showMoreMembers' )
page . find ( " ul.recipientList-organizationMembers[organization-id=' #{ organization . id } '] li.js-showMoreMembers " ) . click
wait ( 5 ) . until { page . all ( " ul.recipientList-organizationMembers[organization-id=' #{ organization . id } '] li " , visible : :all ) . count == 27 } # 25 users + back + show more button
expect ( page ) . to have_selector ( " ul.recipientList-organizationMembers[organization-id=' #{ organization . id } '] li.js-showMoreMembers[organization-member-limit='25'] " )
scroll_into_view ( 'li.js-showMoreMembers' )
page . find ( " ul.recipientList-organizationMembers[organization-id=' #{ organization . id } '] li.js-showMoreMembers " ) . click
wait ( 5 ) . until { page . all ( " ul.recipientList-organizationMembers[organization-id=' #{ organization . id } '] li " , visible : :all ) . count == 52 } # 50 users + back + show more button
scroll_into_view ( 'li.js-showMoreMembers' )
expect ( page ) . to have_selector ( " ul.recipientList-organizationMembers[organization-id=' #{ organization . id } '] li.js-showMoreMembers.hidden " , visible : :all , wait : 20 )
end
end
end
2021-10-29 12:46:14 +00:00
describe 'Ticket create screen will loose attachments by time #3827' do
before do
visit 'ticket/create'
end
it 'does not loose attachments on rerender of the ui' do
# upload two files
page . find ( 'input#fileUpload_1' , visible : :all ) . set ( Rails . root . join ( 'test/data/mail/mail001.box' ) )
await_empty_ajax_queue
page . find ( 'input#fileUpload_1' , visible : :all ) . set ( Rails . root . join ( 'test/data/mail/mail002.box' ) )
await_empty_ajax_queue
wait ( 5 ) . until { page . all ( 'div.attachment-delete.js-delete' , visible : :all ) . count == 2 }
expect ( page ) . to have_text ( 'mail001.box' )
expect ( page ) . to have_text ( 'mail002.box' )
# remove last file
begin
page . evaluate_script ( " $('div.attachment-delete.js-delete:last').click() " ) # not interactable
rescue # Lint/SuppressedException
# because its not interactable it also
# returns this weird exception for the jquery
# even tho it worked fine
end
await_empty_ajax_queue
wait ( 5 ) . until { page . all ( 'div.attachment-delete.js-delete' , visible : :all ) . count == 1 }
expect ( page ) . to have_text ( 'mail001.box' )
expect ( page ) . to have_no_text ( 'mail002.box' )
# simulate rerender b
page . evaluate_script ( " App.Event.trigger('ui:rerender') " )
expect ( page ) . to have_text ( 'mail001.box' )
expect ( page ) . to have_no_text ( 'mail002.box' )
end
end
2021-11-05 07:36:48 +00:00
describe 'Invalid group and owner list for tickets created via customer profile #3835' do
let ( :invalid_ticket ) { create ( :ticket ) }
before do
visit " # ticket/create/id/ #{ invalid_ticket . id } /customer/ #{ User . find_by ( firstname : 'Nicole' ) . id } "
end
it 'does show an empty list of owners' do
2021-11-05 10:22:41 +00:00
wait ( 5 ) . until { page . all ( 'select[name=owner_id] option' ) . count == 1 }
2021-11-05 07:36:48 +00:00
expect ( page . all ( 'select[name=owner_id] option' ) . count ) . to eq ( 1 )
end
end
2021-11-12 13:35:39 +00:00
# https://github.com/zammad/zammad/issues/3825
describe 'CC token field' do
before do
visit 'ticket/create'
find ( '[data-type=email-out]' ) . click
end
it 'can be cleared by cutting out text' do
add_email 'asd@example.com'
add_email 'def@example.com'
find ( '.token' , text : 'def@example.com' ) . double_click
meta_key = Gem :: Platform . local . os == 'darwin' ? :command : :control
send_keys ( [ meta_key , 'x' ] )
find ( '.token' ) . click # trigger blur
expect ( find ( '[name="cc"]' , visible : :all ) . value ) . to eq 'asd@example.com'
end
def add_email ( input )
fill_in 'Cc' , with : input
send_keys ( :enter ) # trigger blur
find '.token' , text : input # wait for email to tokenize
end
end
2019-01-21 17:17:18 +00:00
end