Skip to content

Conversation

@georgeclaghorn
Copy link
Contributor

@georgeclaghorn georgeclaghorn commented Apr 6, 2019

fill_in_rich_text_area locates a Trix editor and fills it in with the given HTML:

# <trix-editor id="message_content" ...></trix-editor>
fill_in_rich_text_area "message_content", with: "Hello world!"

# <trix-editor placeholder="Your message here" ...></trix-editor>
fill_in_rich_text_area "Your message here", with: "Hello world!"

# <trix-editor aria-label="Message content" ...></trix-editor>
fill_in_rich_text_area "Message content", with: "Hello world!"

# <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 world!"

@rails-bot rails-bot bot added the actiontext label Apr 6, 2019
pull bot pushed a commit to hakusaro/rails that referenced this pull request May 5, 2019
The virtual attributes(`attachment` and `rich_text`) can't set value
with `fill_in`. So avoid using it. Once rails#35885 is merged, will be
modified to use it.

Also, add checking attachment attached or not for avoiding
`DelegationError` when attachment didn't attach.
y-yagi added a commit that referenced this pull request May 5, 2019
The virtual attributes(`attachment` and `rich_text`) can't set value
with `fill_in`. So avoid using it. Once #35885 is merged, will be
modified to use it.

Also, add checking attachment attached or not for avoiding
`DelegationError` when attachment didn't attach.
@rails-bot rails-bot bot added the railties label May 11, 2019
@georgeclaghorn georgeclaghorn marked this pull request as ready for review May 12, 2019 00:13
Copy link
Member

@eileencodes eileencodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Copy link
Contributor

@javan javan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💰📝

@georgeclaghorn georgeclaghorn merged commit b2b6341 into rails:master May 13, 2019
@georgeclaghorn georgeclaghorn deleted the actiontext-system-test-helper branch May 13, 2019 16:44
@twalpole
Copy link
Contributor

Nice to see someone using Capybaras custom selector types. Just to point out that most of Capybaras built-in selectors only apply the locator conditions if it's not nil, which allows for using without the locator if there is only one matching field within the current scope. Might be a useful addition here

# # <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:)
page.execute_script(<<~JS, find(:rich_text_area, locator).native, with.to_s)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no need to call .native here, Capybara will convert to the correct parameter for the driver, and with Capybara 3.2+ you can call execute_script on the element itself which will pass the element as the first argument

page.find(:rich_text_area, locator).execute_script(<<~JS, with.to_s)
  ...

@georgeclaghorn
Copy link
Contributor Author

Thanks, @twalpole! I made those changes in a0b1029 and 339be65.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants