Skip to content

Add comprehensive --rsc-pro generator tests#3098

Merged
justin808 merged 3 commits intomainfrom
jg/2793-rsc-pro-generator
Apr 12, 2026
Merged

Add comprehensive --rsc-pro generator tests#3098
justin808 merged 3 commits intomainfrom
jg/2793-rsc-pro-generator

Conversation

@justin808
Copy link
Copy Markdown
Member

@justin808 justin808 commented Apr 9, 2026

Summary

  • Add missing test assertions for the --rsc-pro generator context to match the thoroughness of the --rsc tests
  • Verifies node-renderer.js creation, RSC bundle watcher in Procfile.dev, HelloServer replacing HelloWorld (controller + routes + components), hello_server and rsc_payload routes, and rscWebpackConfig.js

The --rsc-pro generator mode implementation was completed in #2822, but the test coverage was incomplete — only version pinning and DEFAULT_ROUTE were verified. This closes the gap by adding route, component, Procfile, and webpack config assertions.

Closes #2793

Test plan

  • bundle exec rspec react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb -e "with --rsc-pro" — 12 examples, 0 failures
  • bundle exec rubocop — no offenses

🤖 Generated with Claude Code


Note

Low Risk
Low risk: only adds RSpec assertions around generator output, with no production code changes. Main risk is increased test brittleness if templates evolve.

Overview
Strengthens test coverage for the react_on_rails:install --rsc-pro path by asserting generation of client/node-renderer.js, the RSC bundle watcher entry in Procfile.dev, and the switch from HelloWorld scaffolding to HelloServer.

Adds checks that config/routes.rb includes both hello_server and rsc_payload, and verifies RSC-specific webpack artifacts (config/webpack/rscWebpackConfig.js plus RSCWebpackPlugin usage and the rscBundle parameter in serverWebpackConfig).

Reviewed by Cursor Bugbot for commit 1b5b1d1. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for installation configuration validation, including scaffold setup and configuration file generation checks.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 9, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b41ba5be-be74-46b1-9019-1b9f7920dfbf

📥 Commits

Reviewing files that changed from the base of the PR and between 4d143df and 1b5b1d1.

📒 Files selected for processing (1)
  • react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb
🚧 Files skipped from review as they are similar to previous changes (1)
  • react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb

Walkthrough

New test assertions were added to install_generator_spec.rb validating the --rsc-pro generator mode. The tests confirm generation of RSC webpack configurations, HelloServer scaffold components, Procfile.dev watcher entries, node-renderer bootstrapping, and route mappings.

Changes

Cohort / File(s) Summary
--rsc-pro Generator Mode Tests
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb
Added 59 lines of integration test assertions verifying --rsc-pro mode generates: node-renderer with Pro bootstrap, RSC bundle watcher in Procfile.dev, HelloServer scaffold replacing HelloWorld, webpack RSC and server configs with proper plugin imports and parameter handling, and expected route entries.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A rabbit hops through test files with glee,
Asserting that bundles and configs agree—
RSC Pro mode now proven and true,
With webpack and routes and HelloServer too!
Tests pass like clover, abundant and green,
The finest generator assertions I've seen! 🌱

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding comprehensive test assertions for the --rsc-pro generator mode.
Linked Issues check ✅ Passed The PR fulfills the test coverage requirement from #2793 by adding comprehensive RSpec assertions for the --rsc-pro generator to match --rsc test coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to adding test assertions for --rsc-pro generator mode; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg/2793-rsc-pro-generator

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 9, 2026

Greptile Summary

Closes the --rsc-pro generator test gap by adding 7 new it blocks that mirror the existing --rsc assertions: node-renderer.js creation, Procfile.dev RSC bundle watcher entries, HelloServer scaffold (no HelloWorld), routes for hello_server and rsc_payload, rscWebpackConfig.js wiring, and serverWebpackConfig.js RSCWebpackPlugin/rscBundle checks. Also converts scriptSanitizedVal from an anonymous arrow-function export to a named function export — functionally identical.

Confidence Score: 5/5

Safe to merge — test-only additions with a no-op source refactor.

All changes are either new RSpec assertions (no production impact) or a semantically equivalent function-declaration refactor. The previous P1 gap around rscWebpackConfig.js assertions was resolved in commit 199d0cb before this review. No remaining findings rise above P2.

No files require special attention.

Important Files Changed

Filename Overview
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb Adds 7 new it blocks inside the with --rsc-pro context, bringing coverage in line with the --rsc counterpart; assertions for node-renderer.js, Procfile.dev RSC watcher, HelloServer component scaffold, routes, and both webpack config files all look correct.
packages/react-on-rails/src/scriptSanitizedVal.ts No-op refactor: converts anonymous arrow-function default export to named function default export; runtime behavior and module API are identical.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["run_generator_test_with_args(--rsc-pro)"] --> B["before(:all) – single generator run"]
    B --> C["include_examples rsc_common_files"]
    B --> D["include_examples rsc_hello_server_files"]
    B --> E["it: pins Pro dependencies"]
    B --> F["it: creates node-renderer.js NEW"]
    B --> G["it: adds RSC bundle watcher to Procfile.dev NEW"]
    B --> H["it: creates HelloServer instead of HelloWorld NEW"]
    B --> I["it: adds HelloServer route and RSC payload route NEW"]
    B --> J["it: creates rscWebpackConfig.js NEW"]
    B --> K["it: serverWebpackConfig includes RSCWebpackPlugin NEW"]
    B --> L["it: serverWebpackConfig has rscBundle parameter NEW"]
    B --> M["it: sets DEFAULT_ROUTE to hello_server in bin/dev"]
    C --> C1["Procfile.dev exists\nPro initializer content\nLayout content"]
    D --> D1["HelloServer controller layout\nHelloServer view stream_react_component"]
    J --> J1["serverWebpackModule require\nserverWebpackConfig(true)\nrsc-bundle / react-server"]
    K --> K1["RSCWebpackPlugin import\nreact-on-rails-rsc/WebpackPlugin"]
    L --> L1["configureServer=(rscBundle=false)\nif (!rscBundle) guard"]
Loading

Reviews (2): Last reviewed commit: "Add missing serverWebpackConfig.js asser..." | Re-trigger Greptile

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 9, 2026

Review: Add comprehensive --rsc-pro generator tests

Good addition — this PR closes a real coverage gap. The 5 new assertions faithfully parallel the --rsc context and the test run confirms 12 passing examples. A couple of observations:

Weak assertions on rscWebpackConfig.js

The new creates rscWebpackConfig.js test only checks for rsc-bundle and react-server, whereas the equivalent --rsc test (line 1577) verifies 5 content strings including the full require path and function call:

expect(content).to include("const serverWebpackModule = require('./serverWebpackConfig')")
expect(content).to include("const serverWebpackConfig = serverWebpackModule.default || serverWebpackModule")
expect(content).to include("serverWebpackConfig(true)")
expect(content).to include("rsc-bundle")
expect(content).to include("react-server")

If --rsc-pro intentionally generates a different rscWebpackConfig.js (e.g. the Pro-flavoured version from rsc_generator_spec.rb which checks for rscConfig), the test should document that difference with more specific assertions — otherwise it is under-specified and unlikely to catch regressions. If the content is the same as --rsc, the full assertion set should be copied.

Duplication potential (minor, not blocking)

The tests for node-renderer.js, RSC bundle watcher, HelloServer files, and routes are byte-for-byte identical to the --rsc context. If these checks apply to every RSC mode (which seems likely), they might be better expressed as shared examples (similar to rsc_hello_server_files). This would avoid the same assertions drifting out of sync across contexts over time. Not a blocker, but worth considering if more RSC modes are added.

@justin808
Copy link
Copy Markdown
Member Author

Review feedback addressed

Addressed:

  • Added missing rscWebpackConfig.js assertions to the --rsc-pro test (199d0cb). Both modes use the same template, so the 5-assertion set now matches the --rsc counterpart.

Skipped (rationale):

  • CodeRabbit summary — Bot status post, no action needed.
  • Greptile summary — Bot status post; the P2 it flagged was addressed above.
  • Shared examples suggestion (@claude[bot]) — Valid observation about test duplication across RSC modes, but this is a style preference and not blocking. The current structure keeps each context self-contained and easy to read. Worth revisiting if more RSC modes are added.

All review threads resolved. Tests pass (19 examples, 0 failures).

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 10, 2026

Review: Add comprehensive --rsc-pro generator tests

The direction is right — the gap between --rsc and --rsc-pro test coverage was real and worth closing. A few observations:

Missing: serverWebpackConfig.js assertions

The --rsc context has two tests for config/webpack/serverWebpackConfig.js that aren't in this PR:

  • "serverWebpackConfig includes RSCWebpackPlugin import" — verifies RSCWebpackPlugin and react-on-rails-rsc/WebpackPlugin
  • "serverWebpackConfig has rscBundle parameter" — verifies the configureServer = (rscBundle = false) signature and the if (!rscBundle) guard

Since --rsc-pro generates the same serverWebpackConfig.js shape, leaving these out means the coverage gap isn't fully closed despite the PR description's goal of matching --rsc thoroughness. See the inline comment for the exact test bodies to add.

Structural concern: copy-paste will drift again

Five of the six new tests are verbatim copies of their --rsc equivalents. This is how the gap opened in the first place (#2822 added behavior but not all the mirrored assertions). Extracting those five into a new shared example group (e.g. "rsc_and_rsc_pro_common_files") would make both contexts stay in sync automatically without another gap-closing PR.

Minor naming nit

In --rsc, the parallel test is "creates HelloServer instead of HelloWorld (controller, route, and components)" — the parenthetical is useful documentation. The new --rsc-pro variant drops it, which is slightly less self-describing.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb (1)

1735-1778: Consider extracting duplicated --rsc/--rsc-pro assertions into shared examples.

These new examples mirror the with --rsc block very closely; centralizing common expectations would reduce drift risk.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb`
around lines 1735 - 1778, The tests duplicate many expectations across the `with
--rsc` and `with --rsc-pro` contexts; extract the repeated assertions (the
node-renderer check, Procfile.dev entries, HelloServer file/route assertions,
and rscWebpackConfig checks) into a shared_examples (e.g., shared_examples "rsc
generator behavior") and replace the duplicated blocks with calls to that shared
example (use `it_behaves_like "rsc generator behavior"` or `include_examples`
inside the contexts for `--rsc` and `--rsc-pro`); make sure the shared_examples
contains the assertions referencing the same file checks and strings used now
(e.g., "client/node-renderer.js", "Procfile.dev",
"app/javascript/src/HelloServer", route checks for "hello_server" and
"rsc_payload", and the rscWebpackConfig content expectations) so both contexts
invoke the identical expectations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb`:
- Around line 1735-1778: The tests duplicate many expectations across the `with
--rsc` and `with --rsc-pro` contexts; extract the repeated assertions (the
node-renderer check, Procfile.dev entries, HelloServer file/route assertions,
and rscWebpackConfig checks) into a shared_examples (e.g., shared_examples "rsc
generator behavior") and replace the duplicated blocks with calls to that shared
example (use `it_behaves_like "rsc generator behavior"` or `include_examples`
inside the contexts for `--rsc` and `--rsc-pro`); make sure the shared_examples
contains the assertions referencing the same file checks and strings used now
(e.g., "client/node-renderer.js", "Procfile.dev",
"app/javascript/src/HelloServer", route checks for "hello_server" and
"rsc_payload", and the rscWebpackConfig content expectations) so both contexts
invoke the identical expectations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d4b0c2eb-7646-4fbb-87f1-420d60b017fb

📥 Commits

Reviewing files that changed from the base of the PR and between 5dd639f and 199d0cb.

📒 Files selected for processing (1)
  • react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb

Comment thread packages/react-on-rails/src/scriptSanitizedVal.ts Outdated
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 10, 2026

Review

This is a solid addition — the --rsc-pro coverage gap from #2793 is real and the new tests are well-structured. A few things worth addressing:

Blocking / Correctness

Missing serverWebpackConfig.js coverage (see inline comment on rscWebpackConfig.js): The --rsc context has two tests verifying serverWebpackConfig.js structure (RSCWebpackPlugin import, rscBundle parameter) that are not present in --rsc-pro. If --rsc-pro produces the same file, those tests should be added here; if it produces a different file, --rsc-pro-specific assertions are needed. Without this, the stated goal of making --rsc-pro coverage "comparable to --rsc" is not fully achieved.

Non-blocking

  • Unrelated file: packages/react-on-rails/src/scriptSanitizedVal.ts — arrow function → named function conversion — has no connection to the generator tests. Worth splitting out or at minimum calling out explicitly in the PR description.
  • Test duplication: The node-renderer.js, Procfile.dev, and rscWebpackConfig.js tests are identical to their --rsc counterparts. A shared example would prevent silent divergence if the generator changes in the future.
  • Test description inconsistency: Line 1750's description and the missing clarifying comment — minor, but easy to align with the --rsc version for consistency.

Overall the approach is correct and the tests themselves are well-written. Address the serverWebpackConfig.js gap and this is good to go.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

size-limit report 📦

Path Size
react-on-rails/client bundled (gzip) 62.63 KB (+0.01% 🔺)
react-on-rails/client bundled (gzip) (time) 62.63 KB (+0.01% 🔺)
react-on-rails/client bundled (brotli) 53.74 KB (+0.09% 🔺)
react-on-rails/client bundled (brotli) (time) 53.74 KB (+0.09% 🔺)
react-on-rails-pro/client bundled (gzip) 63.56 KB (+0.01% 🔺)
react-on-rails-pro/client bundled (gzip) (time) 63.56 KB (+0.01% 🔺)
react-on-rails-pro/client bundled (brotli) 54.53 KB (-0.14% 🔽)
react-on-rails-pro/client bundled (brotli) (time) 54.53 KB (-0.14% 🔽)
registerServerComponent/client bundled (gzip) 127.39 KB (+0.01% 🔺)
registerServerComponent/client bundled (gzip) (time) 127.39 KB (+0.01% 🔺)
registerServerComponent/client bundled (brotli) 61.57 KB (+0.08% 🔺)
registerServerComponent/client bundled (brotli) (time) 61.57 KB (+0.08% 🔺)
wrapServerComponentRenderer/client bundled (gzip) 122.02 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) (time) 122.02 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) 56.77 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) (time) 56.77 KB (-0.01% 🔽)

@justin808
Copy link
Copy Markdown
Member Author

Review feedback addressed (round 2)

Addressed:

  • Added missing serverWebpackConfig.js assertions to the --rsc-pro test (4d143df). Both RSCWebpackPlugin import check and rscBundle parameter check now mirror the --rsc counterpart. Tests pass: 14 examples, 0 failures.

Skipped (rationale):

  • Shared examples suggestion (@claude[bot]) — Valid observation about test duplication, but intentionally keeping contexts self-contained for readability. Worth revisiting if more RSC modes are added.
  • Naming nit (@claude[bot]) — Style preference, not blocking.
  • Bot summaries (@coderabbitai[bot], @greptile-apps[bot]) — Status posts, no action needed.

All review threads resolved.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 2026

Tip

For best results, initiate chat on the files or code changes.

@justin808 Thanks for the round 2 follow-up! The additional serverWebpackConfig.js assertions — mirroring the RSCWebpackPlugin import check and rscBundle parameter check from the --rsc context — are a solid improvement that ensures parity between the two modes. The rationale for keeping contexts self-contained is sensible; shared examples can always be introduced later if the number of RSC modes grows.

The PR looks good — all threads resolved and tests green. Approving.

[approve]


🧠 Learnings used
Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: react_on_rails_pro/CLAUDE.md:0-0
Timestamp: 2026-02-24T16:52:47.694Z
Learning: Applies to react_on_rails_pro/packages/react-on-rails-pro/**/*.test.rsc.{ts,tsx} : Pro RSC tests should be run with: `pnpm --filter react-on-rails-pro run test:rsc`

Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: react_on_rails_pro/CLAUDE.md:0-0
Timestamp: 2026-02-24T16:52:47.694Z
Learning: Applies to react_on_rails_pro/spec/dummy/commonWebpackConfig.js : Changes to `commonWebpackConfig.js` affect all three webpack bundles (client, server, and RSC) in the Pro dummy app

Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: react_on_rails_pro/CLAUDE.md:0-0
Timestamp: 2026-02-24T16:52:47.694Z
Learning: Applies to react_on_rails_pro/spec/dummy/*WebpackConfig.js : The Pro dummy app has three separate webpack configs: `clientWebpackConfig.js`, `serverWebpackConfig.js`, and `rscWebpackConfig.js`

Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: react_on_rails_pro/CLAUDE.md:0-0
Timestamp: 2026-02-24T16:52:47.694Z
Learning: Applies to react_on_rails_pro/**/*.ts : When editing RSC-related files, check if a `.rsc.ts` counterpart exists due to conditional package exports using the `react-server` condition

Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: react_on_rails_pro/CLAUDE.md:0-0
Timestamp: 2026-02-24T16:52:47.694Z
Learning: Applies to react_on_rails_pro/packages/react-on-rails-pro/**/*.test.{ts,tsx,js,jsx} : Pro JS tests should be run with: `pnpm --filter react-on-rails-pro run test`

Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: react_on_rails_pro/CLAUDE.md:0-0
Timestamp: 2026-02-24T16:52:47.694Z
Learning: Applies to react_on_rails_pro/spec/react_on_rails_pro/**/*.rb : Pro gem unit tests should be run with: `cd react_on_rails_pro && bundle exec rspec spec/react_on_rails_pro/`

Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation in React on Rails Pro is handled through a chain of validations:
1. Pro version check in `run_stream_inside_fiber`
2. RSC support check during pack generation via `ReactOnRailsPro.configuration.enable_rsc_support`
3. RSC support validation during component registration
This makes additional validation in the helper methods unnecessary.

Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: react_on_rails_pro/CLAUDE.md:0-0
Timestamp: 2026-02-24T16:52:47.694Z
Learning: Applies to react_on_rails_pro/spec/dummy/spec/**/*.rb : Pro integration tests should be run with: `cd react_on_rails_pro/spec/dummy && bundle exec rspec spec/`

Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: react_on_rails_pro/CLAUDE.md:0-0
Timestamp: 2026-02-24T16:52:47.694Z
Learning: Applies to react_on_rails_pro/packages/react-on-rails-pro-node-renderer/**/*.test.{ts,tsx,js,jsx} : Node renderer tests should be run with: `pnpm --filter react-on-rails-pro-node-renderer run test`

Learnt from: justin808
Repo: shakacode/react_on_rails PR: 2610
File: docs/pro/react-server-components/create-without-ssr.md:13-22
Timestamp: 2026-03-24T21:38:26.825Z
Learning: In `docs/pro/react-server-components/create-without-ssr.md`, JS install instructions for React on Rails Pro should only install `react-on-rails-pro` (not `react-on-rails` separately), because the Pro package already includes the base package functionality. Use `--exact` (yarn/pnpm) or `--save-exact` (npm) flags to pin to an exact version for reproducibility.

Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: react_on_rails_pro/CLAUDE.md:0-0
Timestamp: 2026-02-24T16:52:47.694Z
Learning: Applies to react_on_rails_pro/**/*.config.{js,ts} : Pro server bundles are private in `ssr-generated/` directory with `enforce_private_server_bundles = true` setting

Comment thread packages/react-on-rails/src/scriptSanitizedVal.ts Outdated
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 12, 2026

Review

Overall: This is a straightforward, low-risk addition. The missing test coverage for --rsc-pro is real and worth closing — the generator mode was fully implemented in #2822 but the test file only verified version pinning and DEFAULT_ROUTE. This PR correctly adds assertions for webpack config, node renderer, Procfile, and HelloServer scaffolding.

What looks good

  • All 7 new it blocks are logically correct and test the right output.
  • Assertions are well-scoped (negative + positive checks in the HelloServer test, regex for the rscBundle parameter).
  • scriptSanitizedVal rename is a no-op refactor with a small debugging benefit (named functions appear in stack traces instead of <anonymous>).

One issue worth addressing before more RSC variants land

See the inline comment on lines 1735-1792. Every new it block is a near-verbatim copy of an existing test from the with --rsc context (lines 1552-1629). The tests are functionally correct, but the duplication will multiply as more RSC variants are added (--rsc --rspack already shares some of this territory). Extracting these into a rsc_webpack_and_renderer_files shared example would follow the existing pattern (rsc_common_files, rsc_hello_server_files) and eliminate the copy-paste.

Not blocking — the coverage is better than it was — but worth doing before the pattern spreads further.

justin808 and others added 3 commits April 12, 2026 08:45
…nd 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) <[email protected]>
Both --rsc and --rsc-pro use the same template, so the assertions
should match. Adds the 3 missing checks: require path, default
unwrap, and serverWebpackConfig(true) call.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The --rsc context had two serverWebpackConfig.js tests (RSCWebpackPlugin
import and rscBundle parameter) that weren't carried over to --rsc-pro.
Since both modes generate the same serverWebpackConfig.js, these
assertions should be mirrored to fully close the coverage gap.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@justin808 justin808 force-pushed the jg/2793-rsc-pro-generator branch from 4d143df to 1b5b1d1 Compare April 12, 2026 18:46
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 12, 2026

Review of #3098 — Add comprehensive --rsc-pro generator tests

Good work closing the coverage gap on the --rsc-pro path. The assertions are accurate and the test plan looks solid. One substantive concern worth addressing before merge, plus a minor naming observation.

Code duplication — consider shared examples

Five of the seven new tests are character-for-character identical to tests already present in the --rsc context:

New test (added here) Existing counterpart in --rsc
creates node-renderer.js line 1552–1556
adds RSC bundle watcher to Procfile.dev line 1559–1564
creates rscWebpackConfig.js line 1577–1585
serverWebpackConfig includes RSCWebpackPlugin import line 1587–1591
serverWebpackConfig has rscBundle parameter line 1594–1598

The codebase already does this right via rsc_generator_examples.rbrsc_common_files and rsc_hello_server_files are used in both contexts. These five tests are the same behavioural contract and belong in the same file, perhaps as a new shared example like rsc_webpack_configuration:

# spec/react_on_rails/support/shared_examples/rsc_generator_examples.rb
shared_examples "rsc_webpack_configuration" do
  it "creates node-renderer.js" do ... end
  it "adds RSC bundle watcher to Procfile.dev" do ... end
  it "creates rscWebpackConfig.js" do ... end
  it "serverWebpackConfig includes RSCWebpackPlugin import" do ... end
  it "serverWebpackConfig has rscBundle parameter" do ... end
end

Then both contexts simply call include_examples "rsc_webpack_configuration". Without this, any future template change requires updating the same assertions in two places.

Minor: route test naming inconsistency

The new "adds HelloServer route and RSC payload route" name is actually more accurate than the --rsc counterpart ("adds HelloServer route") because both assert rsc_payload too. It would be worth updating the --rsc test name to match at the same time, or consolidate it into a shared example to enforce parity going forward.

@justin808 justin808 merged commit 7e4b7dc into main Apr 12, 2026
43 checks passed
@justin808 justin808 deleted the jg/2793-rsc-pro-generator branch April 12, 2026 21:50
justin808 added a commit that referenced this pull request Apr 12, 2026
…ages

* origin/main: (44 commits)
  Consolidate CSP nonce sanitization into shared module (#2828)
  Add comprehensive --rsc-pro generator tests (#3098)
  fix: cross-env validation and docs for renderer password (#3090)
  Improve package metadata and Pro upgrade CTAs (#3112)
  docs: standardize warning syntax to GFM alert format (#3115)
  docs: improve react-intl documentation for React Server Components (#3085)
  Fix generator CI SSR regression on main (#3110)
  Refocus GitHub README on docs navigation (#3113)
  Add manual dev environment testing checklist for coding agents (#3074)
  Bump version to 16.6.0
  Update CHANGELOG.md for 16.6.0 (#3078)
  fix: node-renderer diagnostic improvements (#3086)
  fix: pin third-party npm deps in generator to prevent peer dep conflicts (#3083)
  chore(deps): bump lodash from 4.17.23 to 4.18.1 in the npm-security group across 1 directory (#2920)
  fix: refactor formatExceptionMessage to accept generic request context (#2877)
  Bump version to 16.6.0.rc.1
  Update CHANGELOG.md for 16.6.0.rc.1 (#3079)
  Update CHANGELOG.md unreleased section (#3077)
  Fix Content-Length mismatch and null renderingRequest errors in node renderer (#3069)
  Improve memory debugging docs with simpler heap snapshot approach (#3072)
  ...

# Conflicts:
#	docs/pro/home-pro.md
#	docs/pro/react-on-rails-pro.md
#	docs/sidebars.ts
ihabadham added a commit that referenced this pull request Apr 21, 2026
## Summary

#2821 introduced a dedicated `--rsc-pro` install flag. It was closed the
next
day with: "Closing as redundant: current generator semantics already
treat --rsc
as including Pro by design, so introducing --rsc-pro adds an unnecessary
parallel
mode."

The flag then shipped anyway in #2822, which was primarily about the Pro
upgrade
automation (#2626 — Gemfile swap, import rewriter). The --rsc-pro bits
rode along
as a ~10% passenger in that larger PR and were never removed after
#2821's close.

#3098 was then opened to add more tests for the flag, further
entrenching
something that was explicitly called redundant.

This PR completes the intent behind #2821's close: removes the flag and
folds
its useful behaviors into --rsc, where they belong.

## What moves from --rsc-pro to --rsc

- Pro verification checklist now fires on any --rsc install
- Prerelease installation note now fires on any --rsc install with a
prerelease
  gem version
- Exact version pin for the Pro gem now triggers on
`Gem::Version.new(ReactOnRails::VERSION).prerelease?` instead of the
flag —
this is the real reason exact pinning matters (Bundler's `~>` doesn't
match
  prereleases), not a flag-specific behavior

Side effect: plain `--rsc` on a prerelease gem version now installs
correctly
where it previously would have failed against `~>` pinning.

## What is removed

- `class_option :rsc_pro`
- `use_rsc_pro_mode?` helper
- `--rsc-pro` branches in `use_pro?`, `use_rsc?`,
`pro_requirement_flag`,
  `recovery_install_command`
- All `--rsc-pro` test contexts

## What is NOT touched

`pro_generator.rb` and `pro_generator_spec.rb` (the #2626 upgrade
automation —
Gemfile swap, import rewriter) are independent of this flag and
untouched. Bugs
in that code are tracked separately in #3104.

## Closes / supersedes

Supersedes #3098 (its test assertions were inside `context "with
--rsc-pro"`,
which no longer exists).

## Test plan

- `bundle exec rubocop` on all modified files — clean
- CI to run the full rspec suite

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Removed**
  * The Pro-specific install flag `--rsc-pro` has been removed.

* **Changed**
* Pro-related behaviors that previously required `--rsc-pro` now apply
when using `--rsc` (post-install verification checklist, prerelease
install notes, and exact Pro gem pinning for prereleases).

* **Chore**
* Added a URL exclusion to link-checking configuration to skip a
specific domain.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
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.

Track A: add --rsc-pro generator mode with matched Pro/RSC defaults

1 participant