Don't use ckeditor.setData in specs

After upgrading to chromedriver 80, tests checking CKEditor's content
were causing chromedriver to hang. That's why we were configuring
webdrivers to use an older chromedriver.

Version 80 of chromedriver introduced several issues regarding frames.
Debugging shows in this case chromedriver froze when we used `setData`
and then `within_frame`. Since adding a `sleep` call made it work, we
think `within_frame` was being executed before `setData` had finished.
The fact that `setData` causes the browser to enter the frame having
CKEditor is probably the reason.

Even though the `setData` method provides a callback when it's finished,
configuring it so the rest of the Ruby code isn't executed until that
happens leads to complex code. Using Capybara's `set` to fill in the
editor is IMHO a bit easier to understand.

After this change, since we're using a method provided by Capybara
instead of executing asynchronous JavaScript code, we don't have to
check CKEditor has been filled anymore. The "Admin Active polls add"
test, which failed on my machine without that check, now passes.
This commit is contained in:
Javi Martín
2020-05-27 18:51:43 +02:00
parent 4d65507cbb
commit 8408bfdcf0

View File

@@ -51,14 +51,8 @@ module Verifications
sleep 0.01
end
# Fill the editor content
page.execute_script <<-SCRIPT
var ckeditor = CKEDITOR.instances.#{locator}
ckeditor.setData("#{with}")
ckeditor.focus()
ckeditor.updateElement()
SCRIPT
expect(page).to have_ckeditor label, with: with
within("#cke_#{locator}") do
within_frame(0) { find("body").set(with) }
end
end
end