bard-attachment_field 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b56542b6ac4750d33522c0dc996d1ae7f1bb772c29d455a04202f8c2a980a5b2
4
- data.tar.gz: c114839ed9845fe0dd49f72498964bc6f5f88a8fee27c96ba9a77366087bfc84
3
+ metadata.gz: 32a9e349c2ce7715b8a5732e730bbd96efb6c50f542b0f39fd470a1b39b2952e
4
+ data.tar.gz: 1da2861ccab4b81ffc92f0dc6b933c9266b07ba2b96747469d3030de9f44f9f2
5
5
  SHA512:
6
- metadata.gz: 15d3778a7d97bea1e1433e42ceee7df8c31be1b2d1cd2879de577d5468592ead3fe142822a28de716870493bc9bfb869f21dc0ddfc99faa545b62f7a6b9e6323
7
- data.tar.gz: 8d304feeaf8a31f2ef5b3731c58f9e683be9bd9a42039b40dd95c7f573cf969878fd35e8b1b17388b415fca6ccf737c0fe2a1bd9ac6bf2eca2ad6db3b9f542e5
6
+ metadata.gz: 26808a1afc2c0156726a2fb3443a600efb194bdf87ad4d9a284896e0a53ed24ba3cae9170875fa7bb27cc933de8eafa71fc5116669531ab3431329c59ec6c323
7
+ data.tar.gz: 0f48786c5c1eea01995a6e8d04e41f3cb24c5866456b99068d1a4cf6bbedf41e5879df2d02b4f28b02bb5b939f454a9230e2f7bf7e0a49c5a09ef618b200a2cd
@@ -62,6 +62,17 @@ module Bard::AttachmentField::TestHelper
62
62
  end
63
63
  end
64
64
 
65
+ def wait_for_no_files(session, element_id, selector = "attachment-file", timeout: 10)
66
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
67
+ loop do
68
+ count = session.evaluate_script("document.getElementById('#{element_id}').querySelectorAll('#{selector}').length")
69
+ break if count == 0
70
+ elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
71
+ raise "Expected no #{selector} in ##{element_id}, found #{count} after #{timeout}s" if elapsed > timeout
72
+ sleep 0.1
73
+ end
74
+ end
75
+
65
76
  def wait_for_upload(session, element_id, timeout: 30)
66
77
  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
67
78
  loop do
@@ -189,11 +200,7 @@ When "I remove the file from {string}" do |field|
189
200
  removeLink.click();
190
201
  })(arguments[0])
191
202
  JS
192
- # Wait for the file to be removed (refetch element to avoid stale reference)
193
- page.document.synchronize(5, errors: [Capybara::ElementNotFound]) do
194
- fresh_element = page.find("##{element_id}")
195
- expect(fresh_element).to have_no_css("attachment-file")
196
- end
203
+ Bard::AttachmentField::TestHelper.wait_for_no_files(page, element_id)
197
204
  end
198
205
 
199
206
  When "I remove {string} from {string}" do |filename, field|
@@ -208,11 +215,7 @@ When "I remove {string} from {string}" do |filename, field|
208
215
  removeLink.click();
209
216
  })(arguments[0], arguments[1])
210
217
  JS
211
- # Wait for the file to be removed (refetch element to avoid stale reference)
212
- page.document.synchronize(5, errors: [Capybara::ElementNotFound]) do
213
- fresh_element = page.find("##{element_id}")
214
- expect(fresh_element).to have_no_css("attachment-file[filename='#{filename}']")
215
- end
218
+ Bard::AttachmentField::TestHelper.wait_for_no_files(page, element_id, "attachment-file[filename='#{filename}']")
216
219
  end
217
220
 
218
221
  When "I remove {string} from the {string} field" do |filename, field|
@@ -226,10 +229,7 @@ When "I remove {string} from the {string} field" do |filename, field|
226
229
  removeLink.click();
227
230
  })(arguments[0], arguments[1])
228
231
  JS
229
- page.document.synchronize(5, errors: [Capybara::ElementNotFound]) do
230
- fresh_element = page.find("##{element_id}")
231
- expect(fresh_element).to have_no_css("attachment-file[filename='#{filename}']")
232
- end
232
+ Bard::AttachmentField::TestHelper.wait_for_no_files(page, element_id, "attachment-file[filename='#{filename}']")
233
233
  end
234
234
 
235
235
  When "I drag the file {string} onto the {string} attachment field" do |path, field|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bard
4
4
  module AttachmentField
5
- VERSION = "0.2.1"
5
+ VERSION = "0.2.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard-attachment_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel