Check CKEditor is filled properly in tests
It looks like sometimes, particularly when the first thing we do after loading a page is filling the CKEditor fields and submitting the form, CKEditor doesn't have enough time to format the text, and so it's sent as plain text instead of HTML. This behaviour can be reproduced on my local machine after upgrading to Rails 5.1, with the test "Admin Active polls Add" failing 100% of the time. Checking CKEditor has been filled in correctly solves the issue.
This commit is contained in:
@@ -264,10 +264,7 @@ describe "Admin collaborative legislation" do
|
|||||||
expect(page).not_to have_link "Remove language"
|
expect(page).not_to have_link "Remove language"
|
||||||
expect(page).not_to have_field "translation_locale"
|
expect(page).not_to have_field "translation_locale"
|
||||||
|
|
||||||
within(".translatable-fields[data-locale='en']") do
|
fill_in_ckeditor "Summary", with: "There is still a long journey ahead of us"
|
||||||
fill_in_ckeditor find("textarea", visible: false)[:id],
|
|
||||||
with: "There is still a long journey ahead of us"
|
|
||||||
end
|
|
||||||
|
|
||||||
click_button "Update Process"
|
click_button "Update Process"
|
||||||
|
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ end
|
|||||||
|
|
||||||
def documentable_fill_new_valid_dashboard_action
|
def documentable_fill_new_valid_dashboard_action
|
||||||
fill_in :dashboard_action_title, with: "Dashboard title"
|
fill_in :dashboard_action_title, with: "Dashboard title"
|
||||||
fill_in_ckeditor :dashboard_action_description, with: "Dashboard description"
|
fill_in_ckeditor "Description", with: "Dashboard description"
|
||||||
end
|
end
|
||||||
|
|
||||||
def documentable_fill_new_valid_budget_investment
|
def documentable_fill_new_valid_budget_investment
|
||||||
|
|||||||
@@ -44,10 +44,9 @@ module Verifications
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param [String] locator label text for the textarea or textarea id
|
def fill_in_ckeditor(text, params = {})
|
||||||
def fill_in_ckeditor(locator, params = {})
|
locator = find("label", text: text)[:for]
|
||||||
# Find out ckeditor id at runtime using its label
|
|
||||||
locator = find("label", text: locator)[:for] if page.has_css?("label", text: locator)
|
|
||||||
# Fill the editor content
|
# Fill the editor content
|
||||||
page.execute_script <<-SCRIPT
|
page.execute_script <<-SCRIPT
|
||||||
var ckeditor = CKEDITOR.instances.#{locator}
|
var ckeditor = CKEDITOR.instances.#{locator}
|
||||||
@@ -55,5 +54,7 @@ module Verifications
|
|||||||
ckeditor.focus()
|
ckeditor.focus()
|
||||||
ckeditor.updateElement()
|
ckeditor.updateElement()
|
||||||
SCRIPT
|
SCRIPT
|
||||||
|
|
||||||
|
expect(page).to have_ckeditor text, with: params[:with]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user