Skip to content

Commit

Permalink
[lexical-react] Feature: React 19 unit tests (#6048)
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum authored May 22, 2024
1 parent b2699b1 commit 53f6f1d
Show file tree
Hide file tree
Showing 50 changed files with 508 additions and 188 deletions.
25 changes: 7 additions & 18 deletions .github/workflows/call-core-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
strategy:
matrix:
node-version: [18.18.0]
override-react-version: ['', 'beta']
env:
CI: true
steps:
Expand All @@ -41,22 +42,10 @@ jobs:
cache: npm
- name: Install dependencies
run: npm ci
- name: Install React ${{ matrix.override-react-version }}
if: matrix.override-react-version != ''
# This should be safe since we are caching ~/.npm and not node_modules
run: |
node ./scripts/override-react.js --version=${{ matrix.override-react-version }}
grep version node_modules/{react,react-dom}/package.json
- run: npm run test-unit

integration:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.18.0]
env:
CI: true
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- run: npm run test-integration
17 changes: 17 additions & 0 deletions .github/workflows/call-e2e-all-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,20 @@ jobs:
browser: ${{ matrix.browser }}
editor-mode: ${{ matrix.editor-mode }}
events-mode: ${{ matrix.events-mode }}

react-beta:
strategy:
matrix:
# Currently using a single combination for every-patch e2e tests of
# react beta to reduce cost impact
editor-mode: ['rich-text']
prod: [false]
uses: ./.github/workflows/call-e2e-test.yml
with:
os: 'macos-latest'
browser: 'chromium'
node-version: 18.18.0
events-mode: 'modern-events'
editor-mode: ${{ matrix.editor-mode }}
prod: ${{ matrix.prod }}
override-react-version: beta
10 changes: 9 additions & 1 deletion .github/workflows/call-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
editor-mode: {required: true, type: string}
events-mode: {required: true, type: string}
prod: {required: false, type: boolean}
override-react-version: {required: false, type: string}

jobs:
e2e-test:
Expand All @@ -18,6 +19,7 @@ jobs:
CI: true
E2E_EDITOR_MODE: ${{ inputs.editor-mode }}
E2E_EVENTS_MODE: ${{ inputs.events-mode }}
OVERRIDE_REACT_VERSION: ${{ inputs.override-react-version }}
cache_playwright_path: ${{ inputs.os == 'macos-latest' && '~/Library/Caches/ms-playwright' || inputs.os == 'windows-latest' && 'C:\Users\runneradmin\AppData\Local\ms-playwright' || '~/.cache/ms-playwright' }}
test_results_path: ${{ inputs.os == 'windows-latest' && '~/.npm/_logs/' || 'test-results/' }}
test_script: test-e2e-${{ inputs.editor-mode == 'rich-text-with-collab' && 'collab-' || '' }}${{ inputs.prod && 'prod-' || '' }}ci-${{ inputs.browser }}
Expand All @@ -35,6 +37,12 @@ jobs:
sudo apt-get install xvfb
- name: Install dependencies
run: npm ci
- name: Install React ${{ inputs.override-react-version }}
if: inputs.override-react-version != ''
# This should be safe since we are caching ~/.npm and not node_modules
run: |
node ./scripts/override-react.js --version=${{ inputs.override-react-version }}
grep version node_modules/{react,react-dom}/package.json
- name: Restore playwright from cache
uses: actions/cache/restore@v4
id: playwright-cache
Expand All @@ -55,6 +63,6 @@ jobs:
if: failure()
uses: actions/upload-artifact@v4
with:
name: Test Results ${{ inputs.os }}-${{ inputs.browser }}-${{ inputs.editor-mode }}-${{ inputs.events-mode }}-${{ inputs.prod && 'prod' || 'dev' }}-${{ inputs.node-version }}
name: Test Results ${{ inputs.os }}-${{ inputs.browser }}-${{ inputs.editor-mode }}-${{ inputs.events-mode }}-${{ inputs.prod && 'prod' || 'dev' }}-${{ inputs.node-version }}-${{ inputs.override-react-version }}
path: ${{ env.test_results_path }}
retention-days: 7
23 changes: 23 additions & 0 deletions .github/workflows/call-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lexical Integration Tests

on:
workflow_call:

jobs:
integration:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.18.0]
env:
CI: true
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- run: npm run test-integration
7 changes: 6 additions & 1 deletion .github/workflows/tests-extended.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: Lexical Tests (Extended)

on:
pull_request:
types: [labeled, synchronize]
types: [labeled, synchronize, reopened]
paths-ignore:
- 'packages/lexical-website/**'
- 'packages/*/README.md'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -14,3 +15,7 @@ jobs:
e2e-tests:
if: github.repository_owner == 'facebook' && contains(github.event.pull_request.labels.*.name, 'extended-tests')
uses: ./.github/workflows/call-e2e-all-tests.yml

integration-tests:
if: github.repository_owner == 'facebook' && contains(github.event.pull_request.labels.*.name, 'extended-tests')
uses: ./.github/workflows/call-integration-tests.yml
Loading

0 comments on commit 53f6f1d

Please sign in to comment.