Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion airflow/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 6 additions & 9 deletions airflow/www/static/js/grid/api/useTasks.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
7 changes: 6 additions & 1 deletion airflow/www/static/js/grid/dagRuns/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
2 changes: 1 addition & 1 deletion airflow/www/static/js/grid/utils/useFilters.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion airflow/www/static/js/grid/utils/useSelection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
15 changes: 0 additions & 15 deletions airflow/www/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down