Merge pull request #3968 from consul/fix_flaky_ckeditor_spec

Fix flaky spec: Admin Active polls Add
This commit is contained in:
Javier Martín
2020-04-10 17:47:49 +02:00
committed by GitHub
4 changed files with 8 additions and 16 deletions

View File

@@ -14,8 +14,8 @@ describe "Admin budget phases" do
fill_in "start_date", with: Date.current + 1.day
fill_in "end_date", with: Date.current + 12.days
fill_in_translatable_ckeditor "summary", :en, with: "New summary of the phase."
fill_in_translatable_ckeditor "description", :en, with: "New description of the phase."
fill_in_ckeditor "Summary", with: "New summary of the phase."
fill_in_ckeditor "Description", with: "New description of the phase."
uncheck "budget_phase_enabled"
click_button "Save changes"

View File

@@ -264,10 +264,7 @@ describe "Admin collaborative legislation" do
expect(page).not_to have_link "Remove language"
expect(page).not_to have_field "translation_locale"
within(".translatable-fields[data-locale='en']") do
fill_in_ckeditor find("textarea", visible: false)[:id],
with: "There is still a long journey ahead of us"
end
fill_in_ckeditor "Summary", with: "There is still a long journey ahead of us"
click_button "Update Process"

View File

@@ -351,7 +351,7 @@ end
def documentable_fill_new_valid_dashboard_action
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
def documentable_fill_new_valid_budget_investment

View File

@@ -44,16 +44,9 @@ module Verifications
end
end
def fill_in_translatable_ckeditor(field, locale, params = {})
selector = ".translatable-fields[data-locale='#{locale}'] textarea[id$='_#{field}']"
locator = find(selector, visible: false)[:id]
fill_in_ckeditor(locator, params)
end
def fill_in_ckeditor(text, params = {})
locator = find("label", text: text)[:for]
# @param [String] locator label text for the textarea or textarea id
def fill_in_ckeditor(locator, params = {})
# 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
page.execute_script <<-SCRIPT
var ckeditor = CKEDITOR.instances.#{locator}
@@ -61,5 +54,7 @@ module Verifications
ckeditor.focus()
ckeditor.updateElement()
SCRIPT
expect(page).to have_ckeditor text, with: params[:with]
end
end