Skip to content

Commit

Permalink
Revert yarn.lock, fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach Price committed Jan 10, 2025
1 parent df5b6c4 commit eb8186d
Show file tree
Hide file tree
Showing 8 changed files with 2,495 additions and 2,994 deletions.
19 changes: 13 additions & 6 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@
],
"testEnvironment": "jsdom",
"transform": {
"^.+\\.(t|j)sx?$": "@swc/jest"
"^.+.tsx?$": [
"ts-jest",
{}
]
}
},
"dependencies": {
"@ant-design/icons": "5.2.6",
"@babel/plugin-syntax-flow": "7.23.3",
"@babel/plugin-transform-react-jsx": "7.23.4",
"@react-keycloak/web": "3.4.0",
"antd": "^5.22.2",
"autoprefixer": "10.4.14",
Expand All @@ -88,8 +93,10 @@
"uuid": "^11.0.3"
},
"devDependencies": {
"@swc/core": "^1.10.1",
"@swc/jest": "^0.2.37",
"@babel/core": "7.24.1",
"@babel/eslint-parser": "7.24.1",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/preset-env": "7.24.0",
"@testing-library/dom": "9.3.4",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "14.2.1",
Expand All @@ -106,12 +113,11 @@
"@typescript-eslint/parser": "7.3.1",
"@vitejs/plugin-react": "^4.3.4",
"cross-fetch": "^4.1.0",
"eslint": "^8.57.0",
"eslint": "8.57.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "18.0.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest-dom": "^5.5.0",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-react": "7.33.0",
Expand All @@ -124,6 +130,7 @@
"prettier": "2.2.1",
"setimmediate": "1.0.5",
"ts-jest": "^29.2.5",
"vite": "^6.0.1"
"vite": "^6.0.1",
"vite-jest": "^0.1.4"
}
}
19 changes: 0 additions & 19 deletions frontend/src/api/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,6 @@ describe('test fetching search results', () => {
const projects = await fetchSearchResults({ reqUrl });
expect(projects).toEqual(ESGFSearchAPIFixture());
});
it('catches and throws an error based on HTTP status code', async () => {
server.use(rest.get(apiRoutes.esgfSearch.path, (_req, res, ctx) => res(ctx.status(404))));
await expect(fetchSearchResults([reqUrl])).rejects.toThrow(
apiRoutes.esgfSearch.handleErrorMsg(404)
);
});

it('catches and throws generic network error', async () => {
server.use(
Expand Down Expand Up @@ -600,14 +594,6 @@ describe('test startGlobusTransfer function', () => {

expect(resp.data).toEqual({ status: 'OK', taskid: '1234567' });
});

it('catches and throws an error based on HTTP status code', async () => {
server.use(rest.post(apiRoutes.globusTransfer.path, (_req, res, ctx) => res(ctx.status(404))));

await expect(
startGlobusTransfer('asdfs', 'asdfs', 'endpointTest', 'path', 'id', ['clt'])
).rejects.toThrow(apiRoutes.globusTransfer.handleErrorMsg(408));
});
});

describe('test parsing node status', () => {
Expand All @@ -623,11 +609,6 @@ describe('test fetching node status', () => {

expect(res).toEqual(parsedNodeStatusFixture());
});
it('catches and throws an error based on HTTP status code', async () => {
server.use(rest.get(apiRoutes.nodeStatus.path, (_req, res, ctx) => res(ctx.status(404))));

await expect(fetchNodeStatus()).rejects.toThrow(apiRoutes.nodeStatus.handleErrorMsg(404));
});

it('catches and throws generic network error', async () => {
server.use(
Expand Down
10 changes: 1 addition & 9 deletions frontend/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import 'setimmediate'; // Added because in Jest 27, setImmediate is not defined, causing test errors
import humps from 'humps';
import queryString from 'query-string';
import { AxiosResponse, AxiosError } from 'axios';
import { AxiosResponse } from 'axios';
import PKCE from 'js-pkce';
import axios from '../lib/axios';
import {
Expand Down Expand Up @@ -681,14 +681,6 @@ export const startGlobusTransfer = async (
)
.then((resp) => {
return resp;
})
.catch((error: AxiosError) => {
let message = '';
/* istanbul ignore else */
if (error.response) {
message = error.response.data;
}
throw new Error(message);
});
};

Expand Down
35 changes: 10 additions & 25 deletions frontend/src/components/Globus/DatasetDownload.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,7 @@ describe('DatasetDownload form tests', () => {
});

// Click Transfer button
const globusTransferBtn = await screen.findByRole('button', {
name: /download transfer/i,
});
const globusTransferBtn = await screen.findByTestId('downloadDatasetBtn');
expect(globusTransferBtn).toBeTruthy();
await act(async () => {
await user.click(globusTransferBtn);
Expand Down Expand Up @@ -463,9 +461,7 @@ describe('DatasetDownload form tests', () => {
});

// Click Transfer button
const globusTransferBtn = await screen.findByRole('button', {
name: /download transfer/i,
});
const globusTransferBtn = await screen.findByTestId('downloadDatasetBtn');
expect(globusTransferBtn).toBeTruthy();
await act(async () => {
await user.click(globusTransferBtn);
Expand All @@ -488,9 +484,7 @@ describe('DatasetDownload form tests', () => {
});

// Click Transfer button
const globusTransferBtn = await screen.findByRole('button', {
name: /download transfer/i,
});
const globusTransferBtn = await screen.findByTestId('downloadDatasetBtn');
expect(globusTransferBtn).toBeTruthy();
await act(async () => {
await user.click(globusTransferBtn);
Expand All @@ -510,9 +504,7 @@ describe('DatasetDownload form tests', () => {
});

// Click Transfer button
const globusTransferBtn = await screen.findByRole('button', {
name: /download transfer/i,
});
const globusTransferBtn = await screen.findByTestId('downloadDatasetBtn');
expect(globusTransferBtn).toBeTruthy();
await act(async () => {
await user.click(globusTransferBtn);
Expand Down Expand Up @@ -562,9 +554,7 @@ describe('DatasetDownload form tests', () => {
});

// Click Transfer button
const globusTransferBtn = await screen.findByRole('button', {
name: /download transfer/i,
});
const globusTransferBtn = await screen.findByTestId('downloadDatasetBtn');
expect(globusTransferBtn).toBeTruthy();
await act(async () => {
await user.click(globusTransferBtn);
Expand All @@ -584,9 +574,7 @@ describe('DatasetDownload form tests', () => {
await initializeComponentForTest();

// Click Transfer button
const globusTransferBtn = await screen.findByRole('button', {
name: /download transfer/i,
});
const globusTransferBtn = await screen.findByTestId('downloadDatasetBtn');
expect(globusTransferBtn).toBeTruthy();
await act(async () => {
await user.click(globusTransferBtn);
Expand All @@ -605,16 +593,15 @@ describe('DatasetDownload form tests', () => {
await initializeComponentForTest();

// Click Transfer button
const globusTransferBtn = await screen.findByRole('button', {
name: /download transfer/i,
});
const globusTransferBtn = await screen.findByTestId('downloadDatasetBtn');
expect(globusTransferBtn).toBeTruthy();
await act(async () => {
await user.click(globusTransferBtn);
});

const globusTransferPopup = await screen.findByText(
'Globus transfer task failed. Resetting tokens.'
'is your error. Please contact ESGF support.',
{ exact: false }
);
expect(globusTransferPopup).toBeTruthy();
});
Expand Down Expand Up @@ -1029,9 +1016,7 @@ xit('If endpoint URL is set, and sign in tokens in URL, continue to select endpo
});

// Click Transfer button
const globusTransferBtn = screen.getByRole('button', {
name: /download transfer/i,
});
const globusTransferBtn = await screen.findByTestId('downloadDatasetBtn');
expect(globusTransferBtn).toBeTruthy();
await act(async () => {
await user.click(globusTransferBtn);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/NavBar/RightMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ it('display the users email after authentication if they did not provide a name
});

it("displays sign in button when user hasn't logged in via keycloak", async () => {
mockConfig.REACT_APP_AUTHENTICATION_METHOD = 'keycloak';
mockConfig.AUTHENTICATION_METHOD = 'keycloak';

customRender(<RightMenu {...rightMenuProps} />);

Expand All @@ -113,7 +113,7 @@ it("displays sign in button when user hasn't logged in via keycloak", async () =
});

it("displays sign in button when user hasn't logged in via globus", async () => {
mockConfig.REACT_APP_AUTHENTICATION_METHOD = 'globus';
mockConfig.AUTHENTICATION_METHOD = 'globus';

customRender(<RightMenu {...rightMenuProps} />);

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Search/Table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('test main table UI', () => {
});

it('renders component when globus nodes is empty', async () => {
mockConfig.REACT_APP_GLOBUS_NODES = [];
mockConfig.GLOBUS_NODES = [];
customRender(<Table {...defaultProps} />);

// Check table exists
Expand Down
12 changes: 4 additions & 8 deletions frontend/src/components/Search/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { act, within, screen, waitFor } from '@testing-library/react';
import { act, within, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import {
Expand Down Expand Up @@ -152,13 +152,9 @@ describe('test Search component', () => {
const paginationList = await screen.findByRole('list');
const pageSizeComboBox = await within(paginationList).findByRole('combobox');
pageSizeComboBox.focus();
await waitFor(
async () => {
await userEvent.keyboard('[ArrowDown]');
await userEvent.click(await screen.findByTestId('pageSize-option-20'));
},
{ timeout: 50000 }
);

await userEvent.keyboard('[ArrowDown]');
await userEvent.click(await screen.findByTestId('pageSize-option-20'));

expect(screen.getByTestId('cart-items-row-11')).toBeInTheDocument();
});
Expand Down
Loading

0 comments on commit eb8186d

Please sign in to comment.