Skip to content

Commit b73ff63

Browse files
Replace streaming flaky tests with Playwright E2E tests (#1869)
Replaces streaming flaky tests at ReactOnRailsPro `integration_spec.rb`, which use hacks to test the streaming behavior using `capybara,` with `Playwright` tests that support streamed page tests without any hacks.
1 parent 2b5bab8 commit b73ff63

File tree

27 files changed

+685
-455
lines changed

27 files changed

+685
-455
lines changed

.circleci/config.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,63 @@ jobs:
338338
path: ~/rspec
339339
- store_artifacts:
340340
path: react_on_rails_pro/spec/dummy/tmp/screenshots
341+
- store_artifacts:
342+
path: react_on_rails_pro/spec/dummy/tmp/capybara
341343
- store_artifacts:
342344
path: react_on_rails_pro/spec/dummy/log/test.log
343345
- store_artifacts:
344346
path: react_on_rails_pro/spec/dummy/yarn-error.log
345347

348+
# TODO: DRY with previous job
349+
dummy-app-node-renderer-e2-tests:
350+
docker:
351+
- image: *docker_image
352+
- image: cimg/redis:6.2.6
353+
steps:
354+
- checkout
355+
- run: *print-system-info
356+
- restore_cache: *restore-package-gem-cache
357+
- restore_cache: *restore-package-node-modules-cache
358+
- restore_cache: *restore-dummy-app-node-modules-cache
359+
- restore_cache: *restore-dummy-app-gem-cache
360+
- run: rm -rf react_on_rails_pro/spec/dummy/public/webpack
361+
- run: rm -rf react_on_rails_pro/spec/dummy/ssr-generated
362+
- restore_cache: *restore-dummy-app-webpack-bundle-cache
363+
- run: *install-dummy-app-ruby-gems
364+
- run: *install-package-node-modules
365+
- run: *install-latest-chrome
366+
- run: *install-dummy-app-node-modules
367+
- run:
368+
name: Generate file-system based entrypoints (Pro)
369+
working_directory: react_on_rails_pro
370+
command: cd spec/dummy && bundle exec rake react_on_rails:generate_packs
371+
- run:
372+
name: Run Pro Node renderer in a background
373+
working_directory: react_on_rails_pro
374+
command: cd spec/dummy && yarn run node-renderer
375+
background: true
376+
- run:
377+
name: run rails server in background (Pro dummy app)
378+
working_directory: react_on_rails_pro
379+
command: cd spec/dummy && RAILS_ENV=test rails server
380+
background: true
381+
- run:
382+
name: wait for rails server to start
383+
command: |
384+
while ! curl -s http://localhost:3000 > /dev/null; do sleep 1; done
385+
- run:
386+
name: install playwright dependencies
387+
working_directory: react_on_rails_pro/spec/dummy
388+
command: yarn playwright install --with-deps
389+
- run:
390+
name: Run playwright tests (Pro dummy app)
391+
working_directory: react_on_rails_pro/spec/dummy
392+
command: yarn e2e-test
393+
- store_test_results:
394+
path: react_on_rails_pro/spec/dummy/test-results/results.xml
395+
- store_artifacts:
396+
path: react_on_rails_pro/spec/dummy/playwright-report
397+
346398
workflows:
347399
version: 2
348400
build-and-test:
@@ -374,3 +426,7 @@ workflows:
374426
requires:
375427
- install-package-ruby-gems
376428
- build-dummy-app-webpack-test-bundles
429+
- dummy-app-node-renderer-e2-tests:
430+
requires:
431+
- install-package-ruby-gems
432+
- build-dummy-app-webpack-test-bundles

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
/// <reference types="react/experimental" />
1616

17+
'use client';
18+
1719
import * as React from 'react';
1820
import { useRSC } from './RSCProvider.tsx';
1921
import { ServerComponentFetchError } from './ServerComponentFetchError.ts';

react_on_rails_pro/eslint.config.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,24 @@ export default defineConfig([
196196
],
197197
},
198198
},
199+
{
200+
files: ['spec/dummy/e2e-tests/*'],
201+
202+
rules: {
203+
'no-empty-pattern': [
204+
'error',
205+
{
206+
allowObjectPatternsAsParameters: true,
207+
},
208+
],
209+
},
210+
},
211+
{
212+
files: ['spec/dummy/e2e-tests/*'],
213+
rules: {
214+
'react-hooks/rules-of-hooks': ['off'],
215+
},
216+
},
199217
// must be the last config in the array
200218
// https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#configuration-new-eslintconfigjs
201219
prettierRecommended,

react_on_rails_pro/package-scripts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ scripts:
1515
script: nps lint && nps format.listDifferent && nps test && nps check-typescript
1616
check-typescript:
1717
description: Check for TypeScript errors
18-
script: nps "build --noEmit" && tsc --project packages/node-renderer/tests && cd spec/dummy && yarn run tsc -p client/tsconfig.json --noEmit
18+
script: nps "build --noEmit" && tsc --project packages/node-renderer/tests && cd spec/dummy && yarn run tsc -p ./tsconfig.json --noEmit
1919
fix:
2020
description: Run all code fixes before committing
2121
script: nps eslint.fix && nps format
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
# React on Rails Pro license file
22
config/react_on_rails_pro_license.key
3+
4+
# Playwright
5+
/test-results/
6+
/playwright-report/
7+
/blob-report/
8+
/playwright/.cache/
9+
/playwright/.auth/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- main:
2+
- heading "A list of items received from Redis:" [level=1]
3+
- button "Hide Redis Items"
4+
- list:
5+
- paragraph: Waiting for the key "Item1"
6+
- paragraph: Waiting for the key "Item2"
7+
- paragraph: Waiting for the key "Item3"
8+
- paragraph: Waiting for the key "Item4"
9+
- paragraph: Waiting for the key "Item5"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- main:
2+
- heading "A list of items received from Redis:" [level=1]
3+
- button "Hide Redis Items"
4+
- list:
5+
- listitem: "Value of \"Item1\": Incremental Value1"
6+
- paragraph: Waiting for the key "Item2"
7+
- paragraph: Waiting for the key "Item3"
8+
- paragraph: Waiting for the key "Item4"
9+
- paragraph: Waiting for the key "Item5"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- main:
2+
- heading "A list of items received from Redis:" [level=1]
3+
- button "Hide Redis Items"
4+
- list:
5+
- listitem: "Value of \"Item1\": Incremental Value1"
6+
- paragraph: Waiting for the key "Item2"
7+
- paragraph: Waiting for the key "Item3"
8+
- listitem: "Value of \"Item4\": Incremental Value4"
9+
- paragraph: Waiting for the key "Item5"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- main:
2+
- heading "A list of items received from Redis:" [level=1]
3+
- button "Hide Redis Items"
4+
- list:
5+
- listitem: "Value of \"Item1\": Incremental Value1"
6+
- listitem: "Value of \"Item2\": Incremental Value2"
7+
- paragraph: Waiting for the key "Item3"
8+
- listitem: "Value of \"Item4\": Incremental Value4"
9+
- paragraph: Waiting for the key "Item5"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- main:
2+
- heading "A list of items received from Redis:" [level=1]
3+
- button "Hide Redis Items"
4+
- list:
5+
- listitem: "Value of \"Item1\": Incremental Value1"
6+
- listitem: "Value of \"Item2\": Incremental Value2"
7+
- listitem: "Value of \"Item3\": Incremental Value3"
8+
- listitem: "Value of \"Item4\": Incremental Value4"
9+
- paragraph: Waiting for the key "Item5"

0 commit comments

Comments
 (0)