diff --git a/airflow/www/package.json b/airflow/www/package.json index ad11cc3a0d976..15d237d1cd7a8 100644 --- a/airflow/www/package.json +++ b/airflow/www/package.json @@ -34,7 +34,6 @@ "@babel/preset-typescript": "^7.17.12", "@testing-library/jest-dom": "^5.16.0", "@testing-library/react": "^13.0.0", - "@testing-library/react-hooks": "^8.0.0", "@types/react": "^18.0.12", "@types/react-dom": "^18.0.5", "@typescript-eslint/eslint-plugin": "^5.13.0", diff --git a/airflow/www/static/js/grid/api/useTasks.test.jsx b/airflow/www/static/js/grid/api/useTasks.test.jsx index 9fb5bc677b4b5..d642dae32a55c 100644 --- a/airflow/www/static/js/grid/api/useTasks.test.jsx +++ b/airflow/www/static/js/grid/api/useTasks.test.jsx @@ -20,7 +20,7 @@ /* global describe, test, expect, beforeEach, afterEach, jest */ import React from 'react'; -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook, waitFor } from '@testing-library/react'; import { QueryClient, QueryClientProvider } from 'react-query'; import nock from 'nock'; @@ -59,15 +59,12 @@ describe('Test useTasks hook', () => { const scope = nock(fakeUrl) .get('/') .reply(200, { totalEntries: 1, tasks: [{ taskId: 'task_id' }] }); - const { result, waitFor } = renderHook(() => useTasks(), { wrapper: Wrapper }); + const { result } = renderHook(() => useTasks(), { wrapper: Wrapper }); expect(result.current.data.totalEntries).toBe(0); + expect(result.current.isFetching).toBeTruthy(); - await waitFor(() => result.current.isFetching); - - expect(result.current.data.totalEntries).toBe(0); - - await waitFor(() => !result.current.isFetching); + await waitFor(() => expect(result.current.isFetching).toBeFalsy()); expect(result.current.data.totalEntries).toBe(1); scope.done(); @@ -77,11 +74,11 @@ describe('Test useTasks hook', () => { const scope = nock(fakeUrl) .get('/') .replyWithError('something awful happened'); - const { result, waitFor } = renderHook(() => useTasks(), { wrapper: Wrapper }); + const { result } = renderHook(() => useTasks(), { wrapper: Wrapper }); expect(result.current.data.totalEntries).toBe(0); - await waitFor(() => result.current.isError); + await waitFor(() => expect(result.current.isError).toBeTruthy()); expect(result.current.data.totalEntries).toBe(0); scope.done(); diff --git a/airflow/www/static/js/grid/dagRuns/index.test.jsx b/airflow/www/static/js/grid/dagRuns/index.test.jsx index 3507153eb0331..14e9adc9a5bdc 100644 --- a/airflow/www/static/js/grid/dagRuns/index.test.jsx +++ b/airflow/www/static/js/grid/dagRuns/index.test.jsx @@ -110,8 +110,13 @@ describe('Test DagRuns', () => { }); test('Handles empty data correctly', () => { - global.autoRefreshInterval = 0; + const spy = jest.spyOn(useGridDataModule, 'default').mockImplementation(() => ({ + data: { groups: {}, dagRuns: [] }, + })); + const { queryByTestId } = render(, { wrapper: TableWrapper }); expect(queryByTestId('run')).toBeNull(); + + spy.mockRestore(); }); }); diff --git a/airflow/www/static/js/grid/utils/useFilters.test.jsx b/airflow/www/static/js/grid/utils/useFilters.test.jsx index f23846efd5e79..e8873d3a6499d 100644 --- a/airflow/www/static/js/grid/utils/useFilters.test.jsx +++ b/airflow/www/static/js/grid/utils/useFilters.test.jsx @@ -18,7 +18,7 @@ */ /* global describe, expect, jest, test, moment */ -import { act, renderHook } from '@testing-library/react-hooks'; +import { act, renderHook } from '@testing-library/react'; import { RouterWrapper } from './testUtils'; diff --git a/airflow/www/static/js/grid/utils/useSelection.test.tsx b/airflow/www/static/js/grid/utils/useSelection.test.tsx index 19871c3ff098a..a1fd90d79e157 100644 --- a/airflow/www/static/js/grid/utils/useSelection.test.tsx +++ b/airflow/www/static/js/grid/utils/useSelection.test.tsx @@ -20,7 +20,7 @@ /* global describe, test, expect */ import React from 'react'; -import { act, renderHook } from '@testing-library/react-hooks'; +import { act, renderHook } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; import useSelection from './useSelection'; diff --git a/airflow/www/yarn.lock b/airflow/www/yarn.lock index edeb3eb35eed2..6fca1aac6d88b 100644 --- a/airflow/www/yarn.lock +++ b/airflow/www/yarn.lock @@ -2608,14 +2608,6 @@ lodash "^4.17.15" redent "^3.0.0" -"@testing-library/react-hooks@^8.0.0": - version "8.0.0" - resolved "https://registry.yarnpkg.com/@testing-library/react-hooks/-/react-hooks-8.0.0.tgz#7d0164bffce4647f506039de0a97f6fcbd20f4bf" - integrity sha512-uZqcgtcUUtw7Z9N32W13qQhVAD+Xki2hxbTR461MKax8T6Jr8nsUvZB+vcBTkzY2nFvsUet434CsgF0ncW2yFw== - dependencies: - "@babel/runtime" "^7.12.5" - react-error-boundary "^3.1.0" - "@testing-library/react@^13.0.0": version "13.3.0" resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-13.3.0.tgz#bf298bfbc5589326bbcc8052b211f3bb097a97c5" @@ -8455,13 +8447,6 @@ react-dom@^18.0.0: loose-envify "^1.1.0" scheduler "^0.22.0" -react-error-boundary@^3.1.0: - version "3.1.4" - resolved "https://registry.yarnpkg.com/react-error-boundary/-/react-error-boundary-3.1.4.tgz#255db92b23197108757a888b01e5b729919abde0" - integrity sha512-uM9uPzZJTF6wRQORmSrvOIgt4lJ9MC1sNgEOj2XGsDTRE4kmpWxg7ENK9EWNKJRMAOY9z0MuF4yIfl6gp4sotA== - dependencies: - "@babel/runtime" "^7.12.5" - react-fast-compare@3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb"