Wait till CKEditor is ready before checking it

With chromedriver >= 80, the tests are freezing sometimes, particularly
when the same editor is loaded again.

We don't know whether it's a CKEditor issue or a chromedriver issue. In
the past we've had some errors related to CKEditor trying to load the
same instance twice and we aren't sure they have been fixed since we
could never reproduce them.

It could be a coincidence, though. If we modify the views so the only
content of the `<body>` tag is a textarea with the `html-area` class,
chromedriver freezes even if we only access the page once. So maybe
we're only detecting the problem on the second visit because the second
request is faster than the first one.

Since chromedriver no longer hangs after this change, we don't have to
force any chromedriver version anymore.
This commit is contained in:
Javi Martín
2020-05-27 20:24:54 +02:00
parent 8408bfdcf0
commit 72c2b87227
2 changed files with 4 additions and 1 deletions

View File

@@ -53,6 +53,5 @@ Capybara.register_driver :headless_chrome do |app|
end end
Capybara.exact = true Capybara.exact = true
Webdrivers::Chromedriver.required_version = "2.38"
OmniAuth.config.test_mode = true OmniAuth.config.test_mode = true

View File

@@ -14,6 +14,10 @@ RSpec::Matchers.define :have_ckeditor do |label, with:|
match do match do
return false unless has_ckeditor? return false unless has_ckeditor?
until page.execute_script("return CKEDITOR.instances.#{textarea_id}.status === 'ready';") do
sleep 0.01
end
page.within(ckeditor_id) do page.within(ckeditor_id) do
within_frame(0) { has_content?(with, exact: true) } within_frame(0) { has_content?(with, exact: true) }
end end