Module: ActionMosaico::SystemTestHelper
- Defined in:
- lib/action_mosaico/system_test_helper.rb
Instance Method Summary collapse
-
#fill_in_rich_text_area(locator = nil, with:) ⇒ Object
Locates a Trix editor and fills it in with the given HTML.
Instance Method Details
#fill_in_rich_text_area(locator = nil, with:) ⇒ Object
Locates a Trix editor and fills it in with the given HTML.
The editor can be found by:
-
its
id
-
its
placeholder
-
the text from its
label
element -
its
aria-label
-
the
name
of its input
Examples:
# <mosaico-editor id="message_content" ...></mosaico-editor>
fill_in_rich_text_area "message_content", with: "Hello <em>world!</em>"
# <mosaico-editor placeholder="Your message here" ...></mosaico-editor>
fill_in_rich_text_area "Your message here", with: "Hello <em>world!</em>"
# <label for="message_content">Message content</label>
# <mosaico-editor id="message_content" ...></mosaico-editor>
fill_in_rich_text_area "Message content", with: "Hello <em>world!</em>"
# <mosaico-editor aria-label="Message content" ...></mosaico-editor>
fill_in_rich_text_area "Message content", with: "Hello <em>world!</em>"
# <input id="mosaico_input_1" name="message[content]" type="hidden">
# <mosaico-editor input="mosaico_input_1"></mosaico-editor>
fill_in_rich_text_area "message[content]", with: "Hello <em>world!</em>"
32 33 34 |
# File 'lib/action_mosaico/system_test_helper.rb', line 32 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 |