-
Notifications
You must be signed in to change notification settings - Fork 22k
Add ActionDispatch::SystemTestCase#fill_in_rich_text_area #35885
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
Conversation
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.
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.
eileencodes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
javan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💰📝
|
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) |
There was a problem hiding this comment.
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)
...
fill_in_rich_text_arealocates a Trix editor and fills it in with the given HTML: