-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature-test coverage for Rich Text Field
Follow-up to [#2411][] Add Capybara-driven feature test coverage for filling in and rendering the contents of a `<trix-editor>` element. [#2411]: #2411
- Loading branch information
1 parent
010ea1c
commit 881ef61
Showing
2 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Features | ||
if Rails.version >= "6.1" | ||
require "action_text/system_test_helper" | ||
|
||
include ActionText::SystemTestHelper | ||
else | ||
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 | ||
|
||
Capybara.add_selector :rich_text_area do | ||
xpath do |label| | ||
trix_editor = XPath.descendant(:"trix-editor") | ||
|
||
if label.nil? | ||
trix_editor | ||
else | ||
trix_editor.where XPath.attr(:"aria-label").equals(label) | ||
end | ||
end | ||
end | ||
end | ||
end |