aboutsummaryrefslogtreecommitdiffstats
path: root/actiontext/lib
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2019-05-19 01:54:08 -0400
committerGeorge Claghorn <george@basecamp.com>2019-05-19 01:55:53 -0400
commit339be65d669c83fd4c64541a9e82086dc5e64682 (patch)
tree63dd1e3b1d16958cbc0ccd66c64a245b5b95b173 /actiontext/lib
parenta0b102999afeec902ac45d1dcaeffcfa6c2ff2a0 (diff)
downloadrails-339be65d669c83fd4c64541a9e82086dc5e64682.tar.gz
rails-339be65d669c83fd4c64541a9e82086dc5e64682.tar.bz2
rails-339be65d669c83fd4c64541a9e82086dc5e64682.zip
Allow filling in the only rich-text area without a locator
Diffstat (limited to 'actiontext/lib')
-rw-r--r--actiontext/lib/action_text/system_test_helper.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/actiontext/lib/action_text/system_test_helper.rb b/actiontext/lib/action_text/system_test_helper.rb
index 7b01c4f0b7..77fc9eb50b 100644
--- a/actiontext/lib/action_text/system_test_helper.rb
+++ b/actiontext/lib/action_text/system_test_helper.rb
@@ -24,7 +24,7 @@ module ActionText
# # <input id="trix_input_1" name="message[content]" type="hidden">
# # <trix-editor input="trix_input_1"></trix-editor>
# fill_in_rich_text_area "message[content]", with: "Hello <em>world!</em>"
- def fill_in_rich_text_area(locator, with:)
+ def fill_in_rich_text_area(locator = nil, with:)
find(:rich_text_area, locator).execute_script("this.editor.loadHTML(arguments[0])", with.to_s)
end
end
@@ -33,12 +33,16 @@ end
Capybara.add_selector :rich_text_area do
label "rich-text area"
xpath do |locator|
- input_located_by_name = XPath.anywhere(:input).where(XPath.attr(:name) == locator).attr(:id)
+ if locator.nil?
+ XPath.descendant(:"trix-editor")
+ else
+ input_located_by_name = XPath.anywhere(:input).where(XPath.attr(:name) == locator).attr(:id)
- XPath.descendant(:"trix-editor").where \
- XPath.attr(:id).equals(locator) |
- XPath.attr(:placeholder).equals(locator) |
- XPath.attr(:"aria-label").equals(locator) |
- XPath.attr(:input).equals(input_located_by_name)
+ XPath.descendant(:"trix-editor").where \
+ XPath.attr(:id).equals(locator) |
+ XPath.attr(:placeholder).equals(locator) |
+ XPath.attr(:"aria-label").equals(locator) |
+ XPath.attr(:input).equals(input_located_by_name)
+ end
end
end