Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ActionDispatch::SystemTestCase#fill_in_rich_text_area #35885

Merged
merged 1 commit into from May 13, 2019
Merged

Add ActionDispatch::SystemTestCase#fill_in_rich_text_area #35885

merged 1 commit into from May 13, 2019

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 issue 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 issue 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
Copy link
Member

@eileencodes eileencodes left a comment

Looks good 👍

javan
javan approved these changes May 13, 2019
Copy link
Member

@javan javan left a comment

💰📝

actiontext/CHANGELOG.md Show resolved Hide resolved
@georgeclaghorn georgeclaghorn merged commit b2b6341 into rails:master May 13, 2019
2 checks passed
@georgeclaghorn georgeclaghorn deleted the actiontext-system-test-helper branch May 13, 2019
@twalpole
Copy link
Contributor

@twalpole twalpole commented May 18, 2019

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

@twalpole twalpole May 18, 2019

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

@georgeclaghorn georgeclaghorn commented May 19, 2019

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
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants