Skip to content

Commit b729316

Browse files
justin808claude
andcommitted
Add comprehensive --rsc-pro generator tests for routes, components, and configs
The --rsc-pro test context was missing several important assertions that the --rsc context had. This adds tests verifying that --rsc-pro mode correctly: - Creates node-renderer.js for Pro SSR - Adds RSC bundle watcher to Procfile.dev - Replaces HelloWorld with HelloServer (controller, routes, components) - Adds hello_server and rsc_payload routes - Creates rscWebpackConfig.js Closes #2793 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 45ac79d commit b729316

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,48 @@ class ActiveSupport::TestCase
17321732
end
17331733
end
17341734

1735+
it "creates node-renderer.js" do
1736+
assert_file "client/node-renderer.js" do |content|
1737+
expect(content).to include("reactOnRailsProNodeRenderer")
1738+
expect(content).to include("require('react-on-rails-pro-node-renderer')")
1739+
end
1740+
end
1741+
1742+
it "adds RSC bundle watcher to Procfile.dev" do
1743+
assert_file "Procfile.dev" do |content|
1744+
expect(content).to include("RSC_BUNDLE_ONLY=true")
1745+
expect(content).to include("rsc-bundle:")
1746+
expect(content).to include("bin/shakapacker-watch --watch")
1747+
end
1748+
end
1749+
1750+
it "creates HelloServer instead of HelloWorld" do
1751+
assert_no_file "app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx"
1752+
assert_no_file "app/javascript/src/HelloWorld/ror_components/HelloWorld.server.jsx"
1753+
assert_no_file "app/controllers/hello_world_controller.rb"
1754+
assert_file "config/routes.rb" do |content|
1755+
expect(content).not_to include("hello_world")
1756+
end
1757+
1758+
assert_file "app/javascript/src/HelloServer/ror_components/HelloServer.jsx"
1759+
assert_file "app/javascript/src/HelloServer/components/HelloServer.jsx"
1760+
assert_file "app/javascript/src/HelloServer/components/LikeButton.jsx"
1761+
end
1762+
1763+
it "adds HelloServer route and RSC payload route" do
1764+
assert_file "config/routes.rb" do |content|
1765+
expect(content).to include("hello_server")
1766+
expect(content).to include("rsc_payload")
1767+
end
1768+
end
1769+
1770+
it "creates rscWebpackConfig.js" do
1771+
assert_file "config/webpack/rscWebpackConfig.js" do |content|
1772+
expect(content).to include("rsc-bundle")
1773+
expect(content).to include("react-server")
1774+
end
1775+
end
1776+
17351777
it "sets DEFAULT_ROUTE to hello_server in bin/dev" do
17361778
assert_file "bin/dev" do |content|
17371779
expect(content).to include('DEFAULT_ROUTE = "hello_server"')

0 commit comments

Comments
 (0)