Added upload tests.
This commit is contained in:
parent
8b7c787c42
commit
601ef5eeac
5 changed files with 43 additions and 27 deletions
|
@ -1,11 +0,0 @@
|
|||
class App.TestHelper
|
||||
@attachmentUploadFake: ( selector ) ->
|
||||
|
||||
fileTemplate = '''<div class="attachment horizontal">
|
||||
<div class="attachment-name u-highlight">fake.file</div>
|
||||
<div class="attachment-size">30 KB</div>
|
||||
<div class="attachment-delete js-delete align-right u-clickable" data-id="33009">
|
||||
<div class="delete icon"></div>Delete File
|
||||
</div>
|
||||
</div>'''
|
||||
$(selector).append(fileTemplate)
|
|
@ -39,7 +39,10 @@ class AgentTicketActionLevel6Test < TestCase
|
|||
#alert = alert.text
|
||||
|
||||
# add attachment, attachment check should quiet
|
||||
@browser.execute_script( "App.TestHelper.attachmentUploadFake('.active .richtext .attachments')" )
|
||||
file_upload(
|
||||
css: '.active .attachmentPlaceholder-inputHolder input',
|
||||
files: ['test/fixtures/upload2.jpg', 'test/fixtures/upload1.txt'],
|
||||
)
|
||||
|
||||
# submit form
|
||||
click( css: '.content.active .js-submit' )
|
||||
|
@ -48,10 +51,18 @@ class AgentTicketActionLevel6Test < TestCase
|
|||
# no warning
|
||||
#alert = @browser.switch_to.alert
|
||||
|
||||
# check if ticket is shown
|
||||
# check if ticket is shown and attachment exists
|
||||
location_check( url: '#ticket/zoom/' )
|
||||
sleep 2
|
||||
ticket_number = @browser.find_elements( { css: '.active .ticketZoom-header .ticket-number' } )[0].text
|
||||
match(
|
||||
css: '.active .ticket-article-item:nth-child(1) .attachments',
|
||||
value: 'upload2.jpg',
|
||||
)
|
||||
match(
|
||||
css: '.active .ticket-article-item:nth-child(1) .attachments',
|
||||
value: 'upload1.txt',
|
||||
)
|
||||
|
||||
#
|
||||
# attachment checks - update ticket
|
||||
|
@ -76,7 +87,10 @@ class AgentTicketActionLevel6Test < TestCase
|
|||
alert.dismiss()
|
||||
|
||||
# add attachment, attachment check should quiet
|
||||
@browser.execute_script( "App.TestHelper.attachmentUploadFake('.active .article-add .textBubble .attachments')" )
|
||||
file_upload(
|
||||
css: '.active .attachmentPlaceholder-inputHolder input',
|
||||
files: ['test/fixtures/upload1.txt'],
|
||||
)
|
||||
|
||||
# submit form
|
||||
click(
|
||||
|
@ -106,9 +120,20 @@ class AgentTicketActionLevel6Test < TestCase
|
|||
css: '.active div.ticket-article',
|
||||
value: 'test 6 - ticket 1-1',
|
||||
)
|
||||
match_not(
|
||||
css: '.active .ticket-article-item:nth-child(2) .attachments',
|
||||
value: 'upload2.jpg',
|
||||
)
|
||||
match(
|
||||
css: '.active .ticket-article-item:nth-child(2) .attachments',
|
||||
value: 'upload1.txt',
|
||||
)
|
||||
|
||||
# add attachment without body
|
||||
@browser.execute_script( "App.TestHelper.attachmentUploadFake('.active .article-add .textBubble .attachments')" )
|
||||
file_upload(
|
||||
css: '.active .attachmentPlaceholder-inputHolder input',
|
||||
files: ['test/fixtures/upload2.jpg', 'test/fixtures/upload1.txt'],
|
||||
)
|
||||
|
||||
# submit form
|
||||
click(
|
||||
|
@ -150,7 +175,14 @@ class AgentTicketActionLevel6Test < TestCase
|
|||
body: '',
|
||||
},
|
||||
)
|
||||
|
||||
match(
|
||||
css: '.active .ticket-article-item:nth-child(3) .attachments',
|
||||
value: 'upload2.jpg',
|
||||
)
|
||||
match(
|
||||
css: '.active .ticket-article-item:nth-child(3) .attachments',
|
||||
value: 'upload1.txt',
|
||||
)
|
||||
#
|
||||
# ticket customer change checks
|
||||
#
|
||||
|
|
|
@ -881,8 +881,8 @@ class TestCase < Test::Unit::TestCase
|
|||
|
||||
file_upload(
|
||||
browser: browser1,
|
||||
css: '#content .text-1',
|
||||
value: 'some text',
|
||||
css: '.active .attachmentPlaceholder-inputHolder input'
|
||||
files: ['path/in/home/some_file.ext'], # 'test/fixtures/test1.pdf'
|
||||
)
|
||||
|
||||
=end
|
||||
|
@ -893,15 +893,9 @@ class TestCase < Test::Unit::TestCase
|
|||
|
||||
instance = params[:browser] || @browser
|
||||
|
||||
filename = 'some-file.txt'
|
||||
file = File.join(Dir.pwd, filename)
|
||||
#file = 'some test lalal'
|
||||
|
||||
instance.find_elements({ css: params[:css] })[0].send_keys file
|
||||
#instance.find_elements({ :css => params[:css] })[0]
|
||||
#element
|
||||
#@driver.find_element(id: 'file-submit').click
|
||||
|
||||
params[:files].each {|file|
|
||||
instance.find_elements({ css: params[:css] })[0].send_keys "#{Rails.root}/#{file}"
|
||||
}
|
||||
end
|
||||
|
||||
=begin
|
||||
|
|
1
test/fixtures/upload1.txt
vendored
Normal file
1
test/fixtures/upload1.txt
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
some content äöüß
|
BIN
test/fixtures/upload2.jpg
vendored
Normal file
BIN
test/fixtures/upload2.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 MiB |
Loading…
Reference in a new issue