From 1fbe5ca9b4c11fcb7b547db0b261118a96485aaa Mon Sep 17 00:00:00 2001 From: Josh Black Date: Mon, 9 Oct 2023 16:15:22 -0500 Subject: [PATCH] test(react): remove support for testing React 17 --- .github/workflows/ci.yml | 26 ------------------- jest.config.js | 5 ---- src/__tests__/ConfirmationDialog.test.tsx | 14 +++------- .../MarkdownEditor/MarkdownEditor.test.tsx | 14 ++-------- 4 files changed, 6 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2e7b89c6bb..ea2d3ac40fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,10 +54,6 @@ jobs: run: npm run lint:md test: - strategy: - fail-fast: false - matrix: - react: [17, 18] runs-on: ubuntu-latest steps: - name: Checkout repository @@ -69,15 +65,7 @@ jobs: node-version: 18 cache: 'npm' - - name: Set React version - run: node script/set-react-version.js ${{ matrix.react }} - - name: Install dependencies - if: ${{ matrix.react == 17 }} - run: npm install --legacy-peer-deps - - - name: Install dependencies - if: ${{ matrix.react == 18 }} run: npm ci - name: Build @@ -85,14 +73,8 @@ jobs: - name: Test run: npm run test -- --coverage - env: - REACT_VERSION_17: ${{ matrix.react == 17 }} type-check: - strategy: - fail-fast: false - matrix: - react: [17, 18] runs-on: ubuntu-latest steps: - name: Checkout repository @@ -104,15 +86,7 @@ jobs: node-version: 18 cache: 'npm' - - name: Set React version - run: node script/set-react-version.js ${{ matrix.react }} - - - name: Install dependencies - if: ${{ matrix.react == 17 }} - run: npm install --legacy-peer-deps - - name: Install dependencies - if: ${{ matrix.react != 17 }} run: npm ci - name: Type check diff --git a/jest.config.js b/jest.config.js index 0ca24b1d7d9..b1419db9262 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,16 +3,11 @@ 'use strict' const path = require('node:path') -const {REACT_VERSION_17} = process.env /** * @type {import('jest').Config} */ module.exports = { - globals: { - REACT_VERSION_LATEST: REACT_VERSION_17 ? REACT_VERSION_17 !== 'true' : true, - REACT_VERSION_17: REACT_VERSION_17 === 'true', - }, testEnvironment: 'jsdom', cacheDirectory: '.test', collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/stories/**', '!**/*.stories.{js,jsx,ts,tsx}'], diff --git a/src/__tests__/ConfirmationDialog.test.tsx b/src/__tests__/ConfirmationDialog.test.tsx index 32e604d21a6..70eca67de79 100644 --- a/src/__tests__/ConfirmationDialog.test.tsx +++ b/src/__tests__/ConfirmationDialog.test.tsx @@ -12,8 +12,6 @@ import {ThemeProvider} from '../ThemeProvider' import {SSRProvider} from '../utils/ssr' import {behavesAsComponent, checkExports} from '../utils/testing' -declare const REACT_VERSION_LATEST: boolean - const Basic = ({confirmButtonType}: Pick, 'confirmButtonType'>) => { const [isOpen, setIsOpen] = useState(false) const buttonRef = useRef(null) @@ -126,14 +124,10 @@ describe('ConfirmationDialog', () => { expect(getByText('Primary')).toEqual(document.activeElement) expect(getByText('Secondary')).not.toEqual(document.activeElement) - // REACT_VERSION_LATEST should be treated as a constant for the test - // environment - if (REACT_VERSION_LATEST) { - expect(spy).toHaveBeenCalledTimes(1) - expect(spy).toHaveBeenCalledWith( - expect.stringContaining('Warning: ReactDOM.render is no longer supported in React 18'), - ) - } + expect(spy).toHaveBeenCalledTimes(1) + expect(spy).toHaveBeenCalledWith( + expect.stringContaining('Warning: ReactDOM.render is no longer supported in React 18'), + ) spy.mockRestore() }) }) diff --git a/src/drafts/MarkdownEditor/MarkdownEditor.test.tsx b/src/drafts/MarkdownEditor/MarkdownEditor.test.tsx index 9f8a5fc20b6..75e64ac8176 100644 --- a/src/drafts/MarkdownEditor/MarkdownEditor.test.tsx +++ b/src/drafts/MarkdownEditor/MarkdownEditor.test.tsx @@ -7,8 +7,6 @@ import {act} from 'react-dom/test-utils' import MarkdownEditor, {MarkdownEditorHandle, MarkdownEditorProps, Mentionable, Reference, SavedReply} from '.' import ThemeProvider from '../../ThemeProvider' -declare const REACT_VERSION_LATEST: boolean - type UncontrolledEditorProps = Omit & Partial> & { hideLabel?: boolean @@ -1212,11 +1210,7 @@ describe('MarkdownEditor', () => { // // At the moment, it doesn't seem clear how to appropriately wrap this // interaction in an act() in order to cover this warning - if (REACT_VERSION_LATEST) { - expect(spy).toHaveBeenCalled() - } else { - expect(spy).not.toHaveBeenCalled() - } + expect(spy).toHaveBeenCalled() expect(queryByRole('listbox')).toBeInTheDocument() spy.mockClear() @@ -1254,11 +1248,7 @@ describe('MarkdownEditor', () => { // Note: this spy assertion for console.error() is for an act() violation. // It's not clear where this act() violation is located as wrapping the // above code does not address this. - if (REACT_VERSION_LATEST) { - expect(spy).toHaveBeenCalled() - } else { - expect(spy).not.toHaveBeenCalled() - } + expect(spy).toHaveBeenCalled() spy.mockRestore() })