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

Conversation

Projects
None yet
4 participants
@georgeclaghorn
Copy link
Member

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

@georgeclaghorn georgeclaghorn force-pushed the georgeclaghorn:actiontext-system-test-helper branch 4 times, most recently from f64833e to 03e1c62 Apr 6, 2019

pull bot pushed a commit to hakusaro/rails that referenced this pull request May 5, 2019

Make generated test work even when using virtual attributes
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

Make generated test work even when using virtual attributes
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.

@georgeclaghorn georgeclaghorn force-pushed the georgeclaghorn:actiontext-system-test-helper branch 4 times, most recently from 2bfffed to 79b1116 May 11, 2019

@rails-bot rails-bot bot added the railties label May 11, 2019

@georgeclaghorn georgeclaghorn requested review from javan and eileencodes May 12, 2019

@georgeclaghorn georgeclaghorn marked this pull request as ready for review May 12, 2019

@georgeclaghorn georgeclaghorn force-pushed the georgeclaghorn:actiontext-system-test-helper branch 3 times, most recently from c1104a8 to a25f6b0 May 12, 2019

@eileencodes
Copy link
Member

left a comment

Looks good 👍

@javan

javan approved these changes May 13, 2019

Copy link
Member

left a comment

💰📝

Show resolved Hide resolved actiontext/CHANGELOG.md

@georgeclaghorn georgeclaghorn force-pushed the georgeclaghorn:actiontext-system-test-helper branch from a25f6b0 to b8b27fe May 13, 2019

@georgeclaghorn georgeclaghorn merged commit b2b6341 into rails:master May 13, 2019

2 checks passed

buildkite/rails Build #61109 passed (13 minutes, 43 seconds)
Details
codeclimate All good!
Details

@georgeclaghorn georgeclaghorn deleted the georgeclaghorn:actiontext-system-test-helper branch May 13, 2019

@twalpole

This comment has been minimized.

Copy link
Contributor

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)

This comment has been minimized.

Copy link
@twalpole

twalpole May 18, 2019

Contributor

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

This comment has been minimized.

Copy link
Member Author

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
You can’t perform that action at this time.