Skip to content

Improve Action Text System Test coverage #50414

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

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

seanpdoyle
Copy link
Contributor

Motivation / Background

Introduce the ActionText::RichTextEditorTest to exercise Action Text's integration with Active Storage. First, assert that Action Text renders an Active Storage blob preview of the image within the <trix-editor> element prior to persisting the rich-text record. Next, assert that Active Storage renders the uploaded file within the rendered rich-text content.

Detail

In addition to expanding System Test coverage, this commit also alters the existing ActionText::SystemTestHelperTest coverage to utilize Capybara's built-in :element selector as an alternative to CSS. The :element selector supports arbitrary keyword arguments as HTML attribute filters. For example, input: true as a filter translates to asserting the presence of any [input] attribute. Similarly, it enables assertions with Ruby strings instead of interpolating Ruby strings into CSS selectors.

Additional information

Related to #49527 and #46807.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@rails-bot rails-bot bot added the actiontext label Dec 21, 2023
@MatheusRich MatheusRich added the ready PRs ready to merge label Jul 25, 2024
Introduce the `ActionText::RichTextEditorTest` to exercise Action Text's
integration with Active Storage. First, assert that Action Text renders
an Active Storage blob preview of the image within the `<trix-editor>`
element prior to persisting the rich-text record. Next, assert that
Active Storage renders the uploaded file within the rendered rich-text
content.

In addition to expanding System Test coverage, this commit also alters
the existing `ActionText::SystemTestHelperTest` coverage to utilize
Capybara's built-in [:element][] selector as an alternative to CSS. The
`:element` selector supports arbitrary keyword arguments as HTML
attribute filters. For example, `input: true` as a filter translates to
asserting the presence of any `[input]` attribute. Similarly, it enables
assertions with Ruby strings instead of interpolating Ruby strings
**into** CSS selectors.

[:element]: https://rubydoc.info/github/teamcapybara/capybara/master/Capybara/Selector
@rafaelfranca rafaelfranca force-pushed the action-text-upload-system-test branch from 3dfec10 to a763678 Compare August 21, 2024 20:27
@rafaelfranca rafaelfranca merged commit 2044084 into rails:main Aug 21, 2024
2 of 3 checks passed
@seanpdoyle seanpdoyle deleted the action-text-upload-system-test branch August 21, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actiontext ready PRs ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants