From 72c2b87227d502c8a2875492a7480ada4e432884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 27 May 2020 20:24:54 +0200 Subject: [PATCH] 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 `` 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. --- spec/rails_helper.rb | 1 - spec/support/matchers/have_ckeditor.rb | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 28abc03d9..3de8fd85d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -53,6 +53,5 @@ Capybara.register_driver :headless_chrome do |app| end Capybara.exact = true -Webdrivers::Chromedriver.required_version = "2.38" OmniAuth.config.test_mode = true diff --git a/spec/support/matchers/have_ckeditor.rb b/spec/support/matchers/have_ckeditor.rb index e25df236d..6a5a8585d 100644 --- a/spec/support/matchers/have_ckeditor.rb +++ b/spec/support/matchers/have_ckeditor.rb @@ -14,6 +14,10 @@ RSpec::Matchers.define :have_ckeditor do |label, with:| match do 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 within_frame(0) { has_content?(with, exact: true) } end