You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2022/06/30 14:03:40 UTC

[airflow] 13/14: Address all yarn test warnings (#24722)

This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 5e4d93df6af6e87f48d5d9020281f190f34b5b36
Author: Brent Bovenzi <br...@gmail.com>
AuthorDate: Tue Jun 28 23:06:18 2022 -0400

    Address all yarn test warnings (#24722)
    
    - remove outdated react-hooks library
    - add missing mock
    
    (cherry picked from commit c15cf6e10c7bdcb7389dd51f4b11650b7c930b0a)
---
 airflow/www/package.json                               |  1 -
 airflow/www/static/js/grid/api/useTasks.test.jsx       | 15 ++++++---------
 airflow/www/static/js/grid/dagRuns/index.test.jsx      |  7 ++++++-
 airflow/www/static/js/grid/utils/useFilters.test.jsx   |  2 +-
 airflow/www/static/js/grid/utils/useSelection.test.tsx |  2 +-
 airflow/www/yarn.lock                                  | 15 ---------------
 6 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/airflow/www/package.json b/airflow/www/package.json
index ad11cc3a0d..15d237d1cd 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 9fb5bc677b..d642dae32a 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 3507153eb0..14e9adc9a5 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(<DagRuns />, { 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 f23846efd5..e8873d3a64 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 19871c3ff0..a1fd90d79e 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 edeb3eb35e..6fca1aac6d 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"