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 render_preview test helper #1347

Merged
merged 39 commits into from
May 31, 2022
Merged

add render_preview test helper #1347

merged 39 commits into from
May 31, 2022

Conversation

joelhawksley
Copy link
Member

Summary

I've documented this change thoroughly, see the diff ❤️

@joelhawksley joelhawksley requested review from juanmanuelramallo and a team as code owners May 4, 2022 22:59
docs/CHANGELOG.md Outdated Show resolved Hide resolved
docs/CHANGELOG.md Outdated Show resolved Hide resolved
@@ -41,14 +41,49 @@ def refute_component_rendered
# @param component [ViewComponent::Base, ViewComponent::Collection] The instance of the component to be rendered.
# @return [Nokogiri::HTML]
def render_inline(component, **args, &block)
@rendered_component =
@rendered_content =
Copy link
Contributor

Choose a reason for hiding this comment

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

Super minor, but I wonder if this is being used directly by any libraries/apps and if renaming it would break anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do wonder that too. I'll add a note to the changelog.

Copy link
Contributor

Choose a reason for hiding this comment

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

This indeed is used by lots of people! #1372 and #1373 offer two fixes.

I wonder if we should update the documentation to more explicitly direct people towards writing expectations that use page if they are using RSpec and Capybara?

expect(page).to have_link("Home page", href: root_path)

Copy link
Contributor

Choose a reason for hiding this comment

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

Related issue: #1375

@@ -23,6 +23,8 @@ def index
end

def previews
find_preview
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why was this change necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question. Since we're calling previews directly from render_preview, before_action isn't called. In fact, I think we could inline find_preview here!

Copy link
Contributor

@BlakeWilliams BlakeWilliams left a comment

Choose a reason for hiding this comment

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

I like this a lot!

Similar to how we adopted i18n, slots v2 , and other features, what are your thoughts on extracting the test functionality into it's own namespace and not include it by default? That way we can make breaking changes as/if needed without needing a major release.

joelhawksley added a commit that referenced this pull request May 26, 2022
In working on #1347,
@camertron and I realized that it's a little strange to have our
test suite in two places. In the interest of having our suite
serve as an example for consumers of the framework, we decided
to move everything into the sandbox application.
joelhawksley added a commit that referenced this pull request May 26, 2022
* Move tests into sandbox directory

In working on #1347,
@camertron and I realized that it's a little strange to have our
test suite in two places. In the interest of having our suite
serve as an example for consumers of the framework, we decided
to move everything into the sandbox application.

* use more specific name for test
@joelhawksley joelhawksley merged commit 4bceecf into main May 31, 2022
@joelhawksley joelhawksley deleted the render_preview branch May 31, 2022 21:02
yhirano55 added a commit to yhirano55/view_component that referenced this pull request Jun 1, 2022
In ViewComponent#1347, rendered component has been renamed to rendered content.

But its method name seems to be the same as before.
yhirano55 added a commit to yhirano55/view_component that referenced this pull request Jun 1, 2022
In ViewComponent#1347, rendered component has been renamed to rendered content.

But its method name seems to be the same as before.
joelhawksley added a commit that referenced this pull request Jun 1, 2022
…1372)

* Rename accessor method name: rendered_component => rendered_content

In #1347, rendered component has been renamed to rendered content.

But its method name seems to be the same as before.

* s/rendered_component/rendered_content/ in guide

* Update docs/CHANGELOG.md

* Update docs/CHANGELOG.md

* Update docs/CHANGELOG.md

Co-authored-by: Joel Hawksley <joelhawksley@github.com>
claudiob pushed a commit to claudiob/view_component that referenced this pull request Dec 22, 2023
* Move tests into sandbox directory

In working on ViewComponent#1347,
@camertron and I realized that it's a little strange to have our
test suite in two places. In the interest of having our suite
serve as an example for consumers of the framework, we decided
to move everything into the sandbox application.

* use more specific name for test
claudiob pushed a commit to claudiob/view_component that referenced this pull request Dec 22, 2023
* clean up previews docs

* RSpec not rspec

* always find preview for action

* rename @rendered_component to @rendered_page

* Introduce `render_preview` test helper

* rename rendered_page to rendered_content

* rename benchmark

* copy edits

* re-add lookbook note

* Update docs/CHANGELOG.md

Co-authored-by: Blake Williams <blakewilliams@github.com>

* Update docs/CHANGELOG.md

Co-authored-by: Blake Williams <blakewilliams@github.com>

* update depa

* add note to changelog

* render_preview is opt-in

* fix broken reference in benchmark build

* always load descendants

* add Preview.load_all/load_all!

* how about this?

* remove duplicate before_action

* Ruby 3 changed error formatting!

* don't assert with period

* mdlint

* rename ivar

* always load all previews

* try this

* explicitly load previews

* one more try

* this one?

* load in engine?

* uncomment load_previews call

* remove call in engine

Co-authored-by: Blake Williams <blakewilliams@github.com>
claudiob pushed a commit to claudiob/view_component that referenced this pull request Dec 22, 2023
…iewComponent#1372)

* Rename accessor method name: rendered_component => rendered_content

In ViewComponent#1347, rendered component has been renamed to rendered content.

But its method name seems to be the same as before.

* s/rendered_component/rendered_content/ in guide

* Update docs/CHANGELOG.md

* Update docs/CHANGELOG.md

* Update docs/CHANGELOG.md

Co-authored-by: Joel Hawksley <joelhawksley@github.com>
claudiob pushed a commit to claudiob/view_component that referenced this pull request Jan 3, 2024
* Move tests into sandbox directory

In working on ViewComponent#1347,
@camertron and I realized that it's a little strange to have our
test suite in two places. In the interest of having our suite
serve as an example for consumers of the framework, we decided
to move everything into the sandbox application.

* use more specific name for test
claudiob pushed a commit to claudiob/view_component that referenced this pull request Jan 3, 2024
* clean up previews docs

* RSpec not rspec

* always find preview for action

* rename @rendered_component to @rendered_page

* Introduce `render_preview` test helper

* rename rendered_page to rendered_content

* rename benchmark

* copy edits

* re-add lookbook note

* Update docs/CHANGELOG.md

Co-authored-by: Blake Williams <blakewilliams@github.com>

* Update docs/CHANGELOG.md

Co-authored-by: Blake Williams <blakewilliams@github.com>

* update depa

* add note to changelog

* render_preview is opt-in

* fix broken reference in benchmark build

* always load descendants

* add Preview.load_all/load_all!

* how about this?

* remove duplicate before_action

* Ruby 3 changed error formatting!

* don't assert with period

* mdlint

* rename ivar

* always load all previews

* try this

* explicitly load previews

* one more try

* this one?

* load in engine?

* uncomment load_previews call

* remove call in engine

Co-authored-by: Blake Williams <blakewilliams@github.com>
claudiob pushed a commit to claudiob/view_component that referenced this pull request Jan 3, 2024
…iewComponent#1372)

* Rename accessor method name: rendered_component => rendered_content

In ViewComponent#1347, rendered component has been renamed to rendered content.

But its method name seems to be the same as before.

* s/rendered_component/rendered_content/ in guide

* Update docs/CHANGELOG.md

* Update docs/CHANGELOG.md

* Update docs/CHANGELOG.md

Co-authored-by: Joel Hawksley <joelhawksley@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants