Browse Source

Maintenance: Try to stabilize the test by waiting for an empty AJAX queue...

Dusan Vuckovic 2 years ago
parent
commit
95b45190bb

+ 1 - 0
app/assets/javascripts/app/lib/app_post/html5_upload.coffee

@@ -27,6 +27,7 @@ class App.Html5Upload extends App.Controller
       data:                   @data
       onFileAdded:            @onFileAdded
     )
+    @inputField.attr('data-initialized', true)
 
   onFileAdded: (file) =>
     file.on(

+ 5 - 8
spec/system/ticket/create_spec.rb

@@ -688,11 +688,8 @@ RSpec.describe 'Ticket Create', type: :system do
       visit 'ticket/create'
 
       within :active_content do
-        page.find('input#fileUpload_1', visible: :all).set(Rails.root.join('test/data/mail/mail001.box'))
-
-        # Wait for the uploaded attachment delete button to show up.
-        page.find('.js-delete', visible: :all)
-
+        page.find('input#fileUpload_1[data-initialized="true"]', visible: :all).set(Rails.root.join('test/data/mail/mail001.box'))
+        await_empty_ajax_queue
         find('.js-cancel').click
       end
 
@@ -708,7 +705,8 @@ RSpec.describe 'Ticket Create', type: :system do
       visit 'ticket/create'
 
       within :active_content do
-        page.find('input#fileUpload_1', visible: :all).set(Rails.root.join('test/data/mail/mail001.box'))
+        page.find('input#fileUpload_1[data-initialized="true"]', visible: :all).set(Rails.root.join('test/data/mail/mail001.box'))
+        await_empty_ajax_queue
       end
 
       in_modal do
@@ -1011,8 +1009,7 @@ RSpec.describe 'Ticket Create', type: :system do
 
     it 'does not loose attachments on rerender of the ui' do
       # upload two files
-      await_empty_ajax_queue
-      page.find('input#fileUpload_1', visible: :all).set(Rails.root.join('test/data/mail/mail001.box'))
+      page.find('input#fileUpload_1[data-initialized="true"]', visible: :all).set(Rails.root.join('test/data/mail/mail001.box'))
       await_empty_ajax_queue
       wait.until { page.all('div.attachment-delete.js-delete', visible: :all).count == 1 }
       expect(page).to have_text('mail001.box')

+ 3 - 2
spec/system/ticket/zoom_spec.rb

@@ -2055,7 +2055,8 @@ RSpec.describe 'Ticket zoom', type: :system do
       end
 
       it 'does not show the ticket as changed after the upload removal' do
-        page.find('input#fileUpload_1', visible: :all).set(Rails.root.join('test/data/mail/mail001.box'))
+        page.find('input#fileUpload_1[data-initialized="true"]', visible: :all).set(Rails.root.join('test/data/mail/mail001.box'))
+        await_empty_ajax_queue
         expect(page.find('.article-new')).to have_text('mail001.box')
         wait_for_upload_present
         begin
@@ -2254,7 +2255,7 @@ RSpec.describe 'Ticket zoom', type: :system do
     end
 
     it 'does open automatically when attachment is given from sidebar' do
-      page.find('input#fileUpload_1', visible: :all).set(Rails.root.join('test/data/mail/mail001.box'))
+      page.find('input#fileUpload_1[data-initialized="true"]', visible: :all).set(Rails.root.join('test/data/mail/mail001.box'))
       wait.until { Taskbar.find_by(key: "Ticket-#{ticket.id}").attributes_with_association_ids['attachments'].present? }
       refresh
       expect(page).to have_selector('form.article-add.is-open')