From 341243fe810342686423c93827407451b39ed989 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Thu, 12 Oct 2023 15:01:57 -0500 Subject: [PATCH] test(react): remove support for testing React 17 (#3800) Co-authored-by: Josh Black --- .github/workflows/ci.yml | 26 ------------------- jest.config.js | 5 ---- .../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/ConfirmationDialog/ConfirmationDialog.test.tsx b/src/ConfirmationDialog/ConfirmationDialog.test.tsx index 057d109576c..5ce61a751de 100644 --- a/src/ConfirmationDialog/ConfirmationDialog.test.tsx +++ b/src/ConfirmationDialog/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() })