Skip to content

Make RSC tests await act #1734

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 3 commits into from
Jul 4, 2025
Merged

Make RSC tests await act #1734

merged 3 commits into from
Jul 4, 2025

Conversation

alexeyr-ci2
Copy link
Collaborator

@alexeyr-ci2 alexeyr-ci2 commented Apr 18, 2025

Summary

Tests in node_package/tests/RSCClientRoot.test.jsx were calling act without await, leading to these warnings:

You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);

and

You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one.

Pull Request checklist


This change is Reviewable

Summary by CodeRabbit

  • Chores

    • Updated ESLint configuration for test files to include enhanced DOM testing rules and disabled a specific node access rule.
    • Added and upgraded relevant ESLint and TypeScript dependencies in development setup.
    • Improved script logic for removing ESLint and Testing Library packages during cleanup.
  • Tests

    • Refactored test helper functions for clearer asynchronous handling in server component client tests.
    • Updated test assertions to use more direct and appropriate queries for DOM elements, improving test clarity and reliability.

Copy link
Contributor

coderabbitai bot commented Apr 18, 2025

Walkthrough

This update enhances ESLint configuration for test files by adding the eslint-plugin-testing-library with specific rules, updates relevant dependencies in package.json, refactors test code for explicit async handling, and streamlines a script to remove ESLint and testing-library packages using regex patterns.

Changes

File(s) Change Summary
eslint.config.ts Added eslint-plugin-testing-library config for DOM testing to test file overrides; disabled no-node-access rule.
package.json Added [email protected] and upgraded typescript-eslint to 8.35.0 in devDependencies.
script/convert Consolidated multiple package removals into regex-based removals for ESLint and @testing-library dependencies.
node_package/tests/registerServerComponent.client.test.jsx Refactored test suite: renamed, made render helper async, updated calls to explicitly await rendering.
node_package/tests/SuspenseHydration.test.tsx Updated test assertions to use more direct async/sync queries from testing-library instead of waitFor patterns.

Sequence Diagram(s)

sequenceDiagram
  participant TestFile as Test File
  participant ESLint as ESLint
  participant TestingLibraryPlugin as Testing Library Plugin

  TestFile->>ESLint: Lint test code
  ESLint->>TestingLibraryPlugin: Apply testing-library recommended config
  TestingLibraryPlugin-->>ESLint: Enforce DOM testing rules (except no-node-access)
  ESLint-->>TestFile: Report lint results
Loading
sequenceDiagram
  participant Test as Test Suite
  participant RenderHelper as Render Helper
  participant ReactComponent as React Component

  Test->>RenderHelper: Call async render()
  RenderHelper->>ReactComponent: Render component
  ReactComponent-->>RenderHelper: Rendered output
  RenderHelper-->>Test: Awaited rendered result
Loading

Possibly related PRs

Suggested reviewers

  • Judahmeek

Poem

In the warren of code, a linting breeze,
New rules for tests hop in with ease.
Async awaits, assertions refined,
With regex scripts, old cruft resigned.
Dependencies fresh as morning dew,
A rabbit’s proud—this code is new! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40b5df9 and 1249767.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • eslint.config.ts (2 hunks)
  • node_package/tests/SuspenseHydration.test.tsx (2 hunks)
  • node_package/tests/registerServerComponent.client.test.jsx (5 hunks)
  • package.json (2 hunks)
  • script/convert (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • package.json
  • script/convert
  • eslint.config.ts
  • node_package/tests/registerServerComponent.client.test.jsx
  • node_package/tests/SuspenseHydration.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: dummy-app-integration-tests (newest)
  • GitHub Check: dummy-app-integration-tests (oldest)
  • GitHub Check: rspec-package-tests (oldest)
  • GitHub Check: rspec-package-tests (newest)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@alexeyr-ci alexeyr-ci force-pushed the alexeyr/fix-rsc-tests branch 5 times, most recently from 9ec8d5f to 11d72c2 Compare April 27, 2025 14:57
@alexeyr-ci2 alexeyr-ci2 marked this pull request as ready for review June 6, 2025 11:55
@alexeyr-ci alexeyr-ci force-pushed the alexeyr/fix-rsc-tests branch from e5700dc to a74f298 Compare June 7, 2025 14:27
@alexeyr-ci alexeyr-ci force-pushed the alexeyr/fix-rsc-tests branch 3 times, most recently from 1b743d8 to 40b5df9 Compare June 29, 2025 10:13
Copy link
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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
docs/react-on-rails-pro/react-on-rails-pro.md (1)

19-21: Replace bare URL with markdown-formatted link to satisfy MD034

markdownlint is flagging the bare URL on line 21. Consistently using markdown links keeps the docs lint-clean and matches the surrounding style.

-See https://www.shakacode.com/react-on-rails-pro/docs/.
+See the full documentation [here](https://www.shakacode.com/react-on-rails-pro/docs/).
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89593b1 and 40b5df9.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (7)
  • docs/react-on-rails-pro/react-on-rails-pro.md (1 hunks)
  • docs/react-on-rails-pro/react-server-components.md (1 hunks)
  • eslint.config.ts (2 hunks)
  • node_package/tests/SuspenseHydration.test.tsx (2 hunks)
  • node_package/tests/registerServerComponent.client.test.jsx (5 hunks)
  • package.json (2 hunks)
  • script/convert (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/react-on-rails-pro/react-server-components.md
🚧 Files skipped from review as they are similar to previous changes (5)
  • package.json
  • eslint.config.ts
  • node_package/tests/registerServerComponent.client.test.jsx
  • script/convert
  • node_package/tests/SuspenseHydration.test.tsx
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: alexeyr-ci
PR: shakacode/react_on_rails#1644
File: node_package/src/ReactOnRailsRSC.ts:87-87
Timestamp: 2024-12-12T13:07:09.929Z
Learning: When handling errors in 'node_package/src/ReactOnRailsRSC.ts', include the error stack in error messages in development and test environments to aid debugging.
Learnt from: alexeyr-ci
PR: shakacode/react_on_rails#1687
File: spec/dummy/package.json:0-0
Timestamp: 2025-01-23T18:20:45.824Z
Learning: When adding or updating dependencies in spec/dummy/package.json, maintain version consistency with other package.json files in the codebase to avoid potential version conflicts.
docs/react-on-rails-pro/react-on-rails-pro.md (10)
Learnt from: alexeyr-ci2
PR: shakacode/react_on_rails#1732
File: spec/dummy/client/app-react16/startup/ReduxSharedStoreApp.client.jsx:40-44
Timestamp: 2025-04-26T21:55:55.874Z
Learning: In the react_on_rails project, files under `app-react16` directories are copied/moved to corresponding `/app` directories during the conversion process (removing the `-react16` suffix), which affects their relative import paths at runtime.
Learnt from: Romex91
PR: shakacode/react_on_rails#1697
File: package-scripts.yml:28-28
Timestamp: 2025-02-12T16:38:06.537Z
Learning: The file `node_package/lib/ReactOnRails.full.js` is autogenerated during the build process and should not be present in the repository.
Learnt from: AbanoubGhadban
PR: shakacode/react_on_rails#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: AbanoubGhadban
PR: shakacode/react_on_rails#1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation is handled in deeper level calls of the React on Rails Pro codebase, so it doesn't need to be validated again in the `rsc_payload_react_component` helper method.
Learnt from: AbanoubGhadban
PR: shakacode/react_on_rails#1644
File: node_package/src/clientStartup.ts:18-21
Timestamp: 2025-02-13T16:50:47.848Z
Learning: In the react_on_rails module, the `reactOnRailsPageUnloaded` function in clientStartup.ts is intentionally kept private as it's only used internally as a callback for `onPageUnloaded`.
Learnt from: theforestvn88
PR: shakacode/react_on_rails#1620
File: spec/dummy/client/app/startup/HelloTurboStream.jsx:3-3
Timestamp: 2024-10-08T20:53:47.076Z
Learning: The `RailsContext` import in `spec/dummy/client/app/startup/HelloTurboStream.jsx` is used later in the project, as clarified by the user theforestvn88.
Learnt from: theforestvn88
PR: shakacode/react_on_rails#1620
File: spec/dummy/client/app/startup/HelloTurboStream.jsx:3-3
Timestamp: 2024-07-27T10:08:35.868Z
Learning: The `RailsContext` import in `spec/dummy/client/app/startup/HelloTurboStream.jsx` is used later in the project, as clarified by the user theforestvn88.
Learnt from: AbanoubGhadban
PR: shakacode/react_on_rails#1644
File: node_package/src/turbolinksUtils.ts:34-36
Timestamp: 2025-02-13T16:50:26.861Z
Learning: In React on Rails, when checking for Turbolinks version 5 using `turbolinksVersion5()`, always ensure `Turbolinks` exists first by checking `turbolinksInstalled()` to prevent TypeError when accessing properties.
Learnt from: AbanoubGhadban
PR: shakacode/react_on_rails#1696
File: node_package/src/RSCPayloadContainer.ts:0-0
Timestamp: 2025-04-09T12:56:10.756Z
Learning: In the react_on_rails codebase, RSC payloads are already stringified using `JSON.stringify()` before being processed by the `escapeScript` function, which handles escaping of special characters. The function only needs to handle specific HTML markers like comments and closing script tags.
Learnt from: alexeyr-ci
PR: shakacode/react_on_rails#1644
File: node_package/src/ReactOnRailsRSC.ts:87-87
Timestamp: 2024-12-12T13:07:09.929Z
Learning: When handling errors in 'node_package/src/ReactOnRailsRSC.ts', include the error stack in error messages in development and test environments to aid debugging.
🪛 markdownlint-cli2 (0.17.2)
docs/react-on-rails-pro/react-on-rails-pro.md

21-21: Bare URL used
null

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: dummy-app-integration-tests (oldest)
  • GitHub Check: dummy-app-integration-tests (newest)
  • GitHub Check: rspec-package-tests (newest)
  • GitHub Check: rspec-package-tests (oldest)
  • GitHub Check: build
🔇 Additional comments (1)
docs/react-on-rails-pro/react-on-rails-pro.md (1)

23-24: Spacing tweak looks good

Adding the blank line after the “Pro: React Server Components” header improves readability and keeps heading spacing consistent across the doc.

@alexeyr-ci alexeyr-ci force-pushed the alexeyr/fix-rsc-tests branch from 40b5df9 to 1249767 Compare July 2, 2025 08:25
Copy link
Collaborator

@AbanoubGhadban AbanoubGhadban left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@alexeyr-ci2 alexeyr-ci2 merged commit a918960 into master Jul 4, 2025
11 checks passed
@alexeyr-ci2 alexeyr-ci2 deleted the alexeyr/fix-rsc-tests branch July 4, 2025 06:20
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.

3 participants