Skip to content

Commit

Permalink
Added upload tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
martini committed Dec 15, 2015
1 parent 8b7c787 commit 601ef5e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 27 deletions.
11 changes: 0 additions & 11 deletions app/assets/javascripts/app/lib/app_post/test_helper.coffee

This file was deleted.

42 changes: 37 additions & 5 deletions test/browser/agent_ticket_actions_level6_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def test_ticket
#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' )
Expand All @@ -48,10 +51,18 @@ def test_ticket
# 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
Expand All @@ -76,7 +87,10 @@ def test_ticket
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(
Expand Down Expand Up @@ -106,9 +120,20 @@ def test_ticket
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(
Expand Down Expand Up @@ -150,7 +175,14 @@ def test_ticket
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
#
Expand Down
16 changes: 5 additions & 11 deletions test/browser_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -881,8 +881,8 @@ def open_task(params = {}, _fallback = false)
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
Expand All @@ -893,15 +893,9 @@ def file_upload(params = {})

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
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/upload1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
some content äöüß
Binary file added test/fixtures/upload2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 601ef5e

Please sign in to comment.