Skip to content

Commit 94aa944

Browse files
add streaming tests
1 parent 5a070b6 commit 94aa944

File tree

15 files changed

+244
-68
lines changed

15 files changed

+244
-68
lines changed

packages/react-on-rails-pro/src/RSCRoute.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use client";
2+
13
/*
24
* Copyright (c) 2025 Shakacode LLC
35
*
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- main:
2+
- heading "A list of items received from Redis:" [level=1]
3+
- list:
4+
- paragraph: Waiting for the key "Item1"
5+
- paragraph: Waiting for the key "Item2"
6+
- paragraph: Waiting for the key "Item3"
7+
- paragraph: Waiting for the key "Item4"
8+
- paragraph: Waiting for the key "Item5"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- main:
2+
- heading "A list of items received from Redis:" [level=1]
3+
- list:
4+
- listitem: "Value of \"Item1\": Incremental Value1"
5+
- paragraph: Waiting for the key "Item2"
6+
- paragraph: Waiting for the key "Item3"
7+
- paragraph: Waiting for the key "Item4"
8+
- paragraph: Waiting for the key "Item5"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- main:
2+
- heading "A list of items received from Redis:" [level=1]
3+
- list:
4+
- listitem: "Value of \"Item1\": Incremental Value1"
5+
- paragraph: Waiting for the key "Item2"
6+
- paragraph: Waiting for the key "Item3"
7+
- listitem: "Value of \"Item4\": Incremental Value4"
8+
- paragraph: Waiting for the key "Item5"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- main:
2+
- heading "A list of items received from Redis:" [level=1]
3+
- list:
4+
- listitem: "Value of \"Item1\": Incremental Value1"
5+
- listitem: "Value of \"Item2\": Incremental Value2"
6+
- paragraph: Waiting for the key "Item3"
7+
- listitem: "Value of \"Item4\": Incremental Value4"
8+
- paragraph: Waiting for the key "Item5"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- main:
2+
- heading "A list of items received from Redis:" [level=1]
3+
- list:
4+
- listitem: "Value of \"Item1\": Incremental Value1"
5+
- listitem: "Value of \"Item2\": Incremental Value2"
6+
- listitem: "Value of \"Item3\": Incremental Value3"
7+
- listitem: "Value of \"Item4\": Incremental Value4"
8+
- paragraph: Waiting for the key "Item5"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- main:
2+
- heading "A list of items received from Redis:" [level=1]
3+
- list:
4+
- listitem: "Value of \"Item1\": Incremental Value1"
5+
- listitem: "Value of \"Item2\": Incremental Value2"
6+
- listitem: "Value of \"Item3\": Incremental Value3"
7+
- listitem: "Value of \"Item4\": Incremental Value4"
8+
- listitem: "Value of \"Item5\": Incremental Value5"

react_on_rails_pro/spec/dummy/app/controllers/pages_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def redis_receiver
7676
redis = ::Redis.new
7777
5.times do |index|
7878
sleep 1
79-
redis.xadd("stream:#{@request_id}", { ":Item#{index + 1}" => "Value of Item#{index + 1}".to_json })
79+
redis.xadd("stream:#{@request_id}", { ":Item#{index}" => "Value of Item#{index + 1}".to_json })
8080
end
8181
rescue StandardError => e
8282
Rails.logger.error "Error writing Items to Redis: #{e.message}"

react_on_rails_pro/spec/dummy/app/views/pages/server_router.html.erb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<%= stream_react_component("ServerComponentRouter",
2-
props: @app_props_server_render.merge(artificialDelay: params[:artificial_delay] || 0, postsCount: params[:posts_count] || 2),
2+
props: @app_props_server_render.merge(
3+
artificialDelay: params[:artificial_delay] || 0,
4+
postsCount: params[:posts_count] || 2,
5+
requestId: params[:request_id],
6+
),
37
trace: true,
48
id: "ServerComponentRouter-react-component-0") %>
59
<hr/>

react_on_rails_pro/spec/dummy/client/app/components/ServerComponentRouter.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export default function App({ basePath = '/server_router', ...props }: { basePat
4141
Server Component with visible streaming behavior
4242
</Link>
4343
</li>
44+
<li>
45+
<Link to={`${basePath}/redis-receiver-for-testing`}>
46+
Redis Receiver For Testing
47+
</Link>
48+
</li>
4449
<li>
4550
<Link to={`${basePath}/server-component-with-retry`}>Server Component with Retry</Link>
4651
</li>
@@ -71,6 +76,10 @@ export default function App({ basePath = '/server_router', ...props }: { basePat
7176
/>
7277
<Route path="client-component" element={<EchoProps {...props} />} />
7378
</Route>
79+
<Route
80+
path={`${basePath}/redis-receiver-for-testing`}
81+
element={<RSCRoute componentName="RedisReceiver" componentProps={props} />}
82+
/>
7483
<Route
7584
path={`${basePath}/streaming-server-component`}
7685
element={<RSCRoute componentName="AsyncComponentsTreeForTesting" componentProps={props} />}

0 commit comments

Comments
 (0)