-
-
Notifications
You must be signed in to change notification settings - Fork 638
Replace streaming flaky tests with Playwright E2E tests #1869
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
Changes from 12 commits
67b2ffc
4545805
31bca68
a3727f8
e8bc6f1
5a070b6
94aa944
3668ed4
68d10fc
5ec1071
1840336
c5851aa
6064b02
5d7cfa2
3954ee2
8d4b4c4
182e040
916f7c8
b72d198
57bcf7d
bf0652a
6454b9e
7176d49
f5de26b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| "use client"; | ||
|
|
||
| /* | ||
| * Copyright (c) 2025 Shakacode LLC | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,9 @@ | ||
| # React on Rails Pro license file | ||
| config/react_on_rails_pro_license.key | ||
|
|
||
| # Playwright | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /blob-report/ | ||
| /playwright/.cache/ | ||
| /playwright/.auth/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| - main: | ||
| - heading "A list of items received from Redis:" [level=1] | ||
| - button "Hide Redis Items" | ||
| - list: | ||
| - paragraph: Waiting for the key "Item1" | ||
| - paragraph: Waiting for the key "Item2" | ||
| - paragraph: Waiting for the key "Item3" | ||
| - paragraph: Waiting for the key "Item4" | ||
| - paragraph: Waiting for the key "Item5" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| - main: | ||
| - heading "A list of items received from Redis:" [level=1] | ||
| - button "Hide Redis Items" | ||
| - list: | ||
| - listitem: "Value of \"Item1\": Incremental Value1" | ||
| - paragraph: Waiting for the key "Item2" | ||
| - paragraph: Waiting for the key "Item3" | ||
| - paragraph: Waiting for the key "Item4" | ||
| - paragraph: Waiting for the key "Item5" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| - main: | ||
| - heading "A list of items received from Redis:" [level=1] | ||
| - button "Hide Redis Items" | ||
| - list: | ||
| - listitem: "Value of \"Item1\": Incremental Value1" | ||
| - paragraph: Waiting for the key "Item2" | ||
| - paragraph: Waiting for the key "Item3" | ||
| - listitem: "Value of \"Item4\": Incremental Value4" | ||
| - paragraph: Waiting for the key "Item5" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| - main: | ||
| - heading "A list of items received from Redis:" [level=1] | ||
| - button "Hide Redis Items" | ||
| - list: | ||
| - listitem: "Value of \"Item1\": Incremental Value1" | ||
| - listitem: "Value of \"Item2\": Incremental Value2" | ||
| - paragraph: Waiting for the key "Item3" | ||
| - listitem: "Value of \"Item4\": Incremental Value4" | ||
| - paragraph: Waiting for the key "Item5" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| - main: | ||
| - heading "A list of items received from Redis:" [level=1] | ||
| - button "Hide Redis Items" | ||
| - list: | ||
| - listitem: "Value of \"Item1\": Incremental Value1" | ||
| - listitem: "Value of \"Item2\": Incremental Value2" | ||
| - listitem: "Value of \"Item3\": Incremental Value3" | ||
| - listitem: "Value of \"Item4\": Incremental Value4" | ||
| - paragraph: Waiting for the key "Item5" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| - main: | ||
| - heading "A list of items received from Redis:" [level=1] | ||
| - button "Hide Redis Items" | ||
| - list: | ||
| - listitem: "Value of \"Item1\": Incremental Value1" | ||
| - listitem: "Value of \"Item2\": Incremental Value2" | ||
| - listitem: "Value of \"Item3\": Incremental Value3" | ||
| - listitem: "Value of \"Item4\": Incremental Value4" | ||
| - listitem: "Value of \"Item5\": Incremental Value5" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <%= stream_react_component("RedisReceiver", | ||
| props: { requestId: @request_id, asyncToggleContainer: params[:async_toggle_container] }, | ||
| prerender: true, | ||
| trace: true, | ||
| id: "RedisReceiver-react-component-0") %> | ||
| <hr/> | ||
|
|
||
| <h1>React Rails Server Streaming Redis Receiver</h1> |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||||||||||||||||||||||
| import React, { Suspense } from 'react'; | ||||||||||||||||||||||||||
| import ToggleContainer from '../components/RSCPostsPage/ToggleContainerForServerComponents'; | ||||||||||||||||||||||||||
| import { listenToRequestData } from '../utils/redisReceiver'; | ||||||||||||||||||||||||||
| import { ErrorBoundary } from '../components/ErrorBoundary'; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const RedisItem = async ({ getValue, itemIndex }) => { | ||||||||||||||||||||||||||
| const value = await getValue(`Item${itemIndex}`); | ||||||||||||||||||||||||||
| return <li className={`redis-item${itemIndex}`}>Value of "Item{itemIndex + 1}": {value}</li> | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| const RedisItem = async ({ getValue, itemIndex }) => { | |
| const value = await getValue(`Item${itemIndex}`); | |
| return <li className={`redis-item${itemIndex}`}>Value of "Item{itemIndex + 1}": {value}</li> | |
| } | |
| const RedisItem = async ({ getValue, itemIndex }) => { | |
| const value = await getValue(`Item${itemIndex}`); | |
| return ( | |
| <li className={`redis-item${itemIndex}`}> | |
| {`Value of "Item${itemIndex + 1}": ${String(value)}`} | |
| </li> | |
| ); | |
| } |
🤖 Prompt for AI Agents
In
react_on_rails_pro/spec/dummy/client/app/ror-auto-load-components/RedisReceiver.jsx
around lines 6 to 9, the JSX is rendering the literal text Item{itemIndex + 1}
because the braces are inside a quoted string; change the node so the
interpolation is evaluated — e.g. replace the quoted "Item{itemIndex + 1}" with
a JSX expression such as {`Item${itemIndex + 1}`} or {"Item" + (itemIndex + 1)}
so the correct item number is displayed (keep the rest of the element as-is).
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
AbanoubGhadban marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { test as base } from '@playwright/test'; | ||
|
|
||
| type F = { | ||
| h: string; | ||
| } | ||
|
|
||
| type F2 = { | ||
| h2: string; | ||
| } | ||
|
|
||
| export const test1 = base.extend<F>({ | ||
| h: [async({}, use) => { | ||
| console.log('F1') | ||
| await use('F1'); | ||
| console.log('F1 end'); | ||
| }, { auto: true }] | ||
| }) | ||
|
|
||
| export const testmid = base.extend<F>({ | ||
| h: [async({}, use) => { | ||
| console.log('Fm') | ||
| await use('Fm'); | ||
| console.log('Fm end'); | ||
| }, { auto: true }] | ||
| }) | ||
|
|
||
| export const test2 = testmid.extend<F2>({ | ||
| h2: [async({ h }, use) => { | ||
| console.log('F2') | ||
| await use(h + 'F2'); | ||
| console.log('F2 end'); | ||
| }, { auto: true }] | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // import { test, expect } from '@playwright/test'; | ||
| // import { redisControlledTest } from './fixture'; | ||
|
|
||
| // redisControlledTest('test1', ({ redisRequestId, redisClient }) => { | ||
| // console.log('Test1 request id', redisRequestId); | ||
| // console.log(redisClient); | ||
| // }); | ||
|
|
||
| // redisControlledTest('test2', ({ redisRequestId, redisClient }) => { | ||
| // console.log('Test2 request id', redisRequestId); | ||
| // console.log(redisClient); | ||
| // }); | ||
|
|
||
| import { mergeTests } from '@playwright/test'; | ||
| import { test1, test2 } from './dummt-fixture'; | ||
|
|
||
| const test = mergeTests(test2); | ||
|
|
||
| test('eee', ({ h2 }) => { | ||
| console.log('TEst', h2); | ||
| }) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Refactor to eliminate job duplication via YAML anchors.
The
dummy-app-node-renderer-e2-testsjob is nearly identical torspec-dummy-app-node-renderer(lines 289–344), with only the Redis service addition and test command differing. The TODO comment acknowledges this.Use YAML anchors to extract common steps and compose the jobs to follow DRY principles:
Then define both jobs by extending shared steps with job-specific parameters.