Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FI-3104: Update React + other packages #529

Merged
merged 27 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
78d06fa
resolve vulnerabilities
AlyssaWang Sep 12, 2024
9c85939
update react and mui versions
AlyssaWang Sep 12, 2024
cd23794
clean up tree item components
AlyssaWang Sep 12, 2024
132d928
update tree item conditional icon rendering
AlyssaWang Sep 16, 2024
7f695dd
update other packages
AlyssaWang Sep 16, 2024
be74499
update webpack
AlyssaWang Sep 16, 2024
f926939
update other packages
AlyssaWang Sep 16, 2024
6089580
fix test lint errors
AlyssaWang Sep 16, 2024
285410d
update linter and testing packages
AlyssaWang Sep 18, 2024
b622610
resolve act errors in tests
AlyssaWang Sep 18, 2024
89ee93c
add act fix
AlyssaWang Sep 20, 2024
29f6017
Merge branch 'main' of github.com:inferno-framework/inferno-core into…
AlyssaWang Sep 20, 2024
e0638e4
add missing input case for empty map
AlyssaWang Sep 20, 2024
ebf1965
clean up lint files
AlyssaWang Sep 20, 2024
d226a97
fix broken inputs modal test
AlyssaWang Sep 20, 2024
a17166c
resolve deprecated vite cjs node api error
AlyssaWang Sep 20, 2024
ff34077
update gh workflow node version
AlyssaWang Sep 20, 2024
e16d864
update deprecated vitest coverage package
AlyssaWang Sep 20, 2024
d7a80ab
donwgrade node
AlyssaWang Sep 23, 2024
08b816e
Merge branch 'main' of github.com:inferno-framework/inferno-core into…
AlyssaWang Sep 23, 2024
f4f3318
reupdate node
AlyssaWang Sep 23, 2024
3cf48f9
update nvm and vite eslint
AlyssaWang Sep 25, 2024
1f00ed8
upgrade node
AlyssaWang Sep 25, 2024
381a547
update github workflows
AlyssaWang Sep 25, 2024
51369ae
update node
AlyssaWang Sep 25, 2024
3ee479b
update npm registry
AlyssaWang Sep 25, 2024
9d23ed9
Merge branch 'main' into FI-3104-update-react
AlyssaWang Sep 27, 2024
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
38 changes: 0 additions & 38 deletions .eslintrc.json

This file was deleted.

26 changes: 13 additions & 13 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['16.x']
node-version: ['20.x']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node.js modules
uses: actions/cache@v2
uses: actions/cache@v4
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
Expand All @@ -35,16 +35,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['16.x']
node-version: ['20.x']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node.js modules
uses: actions/cache@v2
uses: actions/cache@v4
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
Expand All @@ -56,7 +56,7 @@ jobs:
# `npm run coverage` is run tests with coverage flags, rather than repeating them here
- run: npm run coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: frontend-coverage
flags: frontend
Expand All @@ -67,16 +67,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['16.x']
node-version: ['20.x']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node.js modules
uses: actions/cache@v2
uses: actions/cache@v4
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.15.0
20.17.0
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ruby 3.1.2
nodejs 16.20.1
nodejs 20.17.0
4 changes: 2 additions & 2 deletions client/src/api/TestRunsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function postTestRun(
testSessionId: string,
runnableType: RunnableType,
runnableId: string,
inputs: TestInput[]
inputs: TestInput[],
): Promise<TestRun | null> {
const postEndpoint = getApiEndpoint('/test_runs');
const postBody: CreateTestRunBody = {
Expand Down Expand Up @@ -51,7 +51,7 @@ export function deleteTestRun(testRunId: string): Promise<Response> {

export function getTestRunWithResults(
testRunId: string,
time: string | null | undefined
time: string | null | undefined,
): Promise<TestRun | null> {
let endpoint = getApiEndpoint(`/test_runs/${testRunId}?include_results=true`);
if (time) {
Expand Down
6 changes: 3 additions & 3 deletions client/src/api/TestSessionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getApiEndpoint } from './infernoApiService';

export function getLastTestRun(test_session_id: string): Promise<TestRun | null> {
const testSessionsEndpoint = getApiEndpoint(
'/test_sessions/' + test_session_id + '/last_test_run'
'/test_sessions/' + test_session_id + '/last_test_run',
);
return fetch(testSessionsEndpoint)
.then((response) => response.json())
Expand All @@ -31,7 +31,7 @@ export function getTestSession(test_session_id: string): Promise<TestSession | n
export function postTestSessions(
testSuiteID: string,
presetId: string | null,
suiteOptions: SuiteOption[] | null
suiteOptions: SuiteOption[] | null,
): Promise<TestSession | null> {
const testSuiteIDParameter = { name: 'test_suite_id', value: testSuiteID };
const postEndpoint = getApiEndpoint('/test_sessions', [testSuiteIDParameter]);
Expand Down Expand Up @@ -69,7 +69,7 @@ export function getTestSessionData(test_session_id: string): Promise<TestOutput[

export function applyPreset(test_session_id: string, preset_id: string): Promise<null> {
const endpoint = getApiEndpoint(
`/test_sessions/${test_session_id}/session_data/apply_preset?preset_id=${preset_id}`
`/test_sessions/${test_session_id}/session_data/apply_preset?preset_id=${preset_id}`,
);

return fetch(endpoint, { method: 'PUT' }).then((response) => {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/App/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ export const router = (testSuites: TestSuite[]) => {
element: <TestSessionWrapper />,
},
],
{ basename: `/${basePath || ''}` }
{ basename: `/${basePath || ''}` },
);
};
16 changes: 9 additions & 7 deletions client/src/components/App/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import { act } from 'react-dom/test-utils';
import { render } from '@testing-library/react';
import React, { act } from 'react';
import { render, waitFor } from '@testing-library/react';

import { vi } from 'vitest';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { SnackbarProvider } from 'notistack';

import ThemeProvider from 'components/ThemeProvider';
Expand All @@ -26,16 +25,19 @@ describe('The App Root Component', () => {
it('sets Test Suite state on mount', async () => {
const getTestSuites = vi.spyOn(testSuitesApi, 'getTestSuites');
getTestSuites.mockResolvedValue(testSuites);

await act(() =>
render(
<ThemeProvider>
<SnackbarProvider>
<App />
</SnackbarProvider>
</ThemeProvider>
)
</ThemeProvider>,
),
);

expect(getTestSuites).toBeCalledTimes(1);
await waitFor(() => {
expect(getTestSuites).toBeCalledTimes(1);
});
});
});
1 change: 1 addition & 0 deletions client/src/components/App/__tests__/Page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { RouterProvider, createMemoryRouter } from 'react-router-dom';
import { render /* , waitFor */ } from '@testing-library/react';
import { testSuites } from '~/components/App/__mocked_data__/mockData';
import Page from '../Page';
import { describe, it } from 'vitest';

describe('The Page Component', () => {
it('sets page title on render', /* async */ () => {
Expand Down
11 changes: 6 additions & 5 deletions client/src/components/Footer/__tests__/Footer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ import { render, screen } from '@testing-library/react';
import Footer from '..';
import ThemeProvider from 'components/ThemeProvider';
import { basePath } from '~/api/infernoApiService';
import { expect, test } from 'vitest';

test('renders Inferno Footer', () => {
render(
<ThemeProvider>
<Footer version={'dummyVersion'} />
</ThemeProvider>
</ThemeProvider>,
);
});

test('has no links if not provided any', () => {
render(
<ThemeProvider>
<Footer version={'dummyVersion'} />
</ThemeProvider>
</ThemeProvider>,
);

// testing a negative is nearly meaningless
Expand All @@ -33,7 +34,7 @@ test('can be given a list of links to display', () => {
render(
<ThemeProvider>
<Footer version={'dummyVersion'} linkList={links} />
</ThemeProvider>
</ThemeProvider>,
);

expect(screen.getByRole('link', { name: /One/ })).toHaveAttribute('href', 'http://one.com');
Expand All @@ -49,11 +50,11 @@ test('displays API link with scheme and host name', () => {
render(
<ThemeProvider>
<Footer version={'dummyVersion'} />
</ThemeProvider>
</ThemeProvider>,
);

expect(screen.getByRole('link', { name: /API/ })).toHaveAttribute(
'href',
`${apiBase}?scheme=${scheme}&host=${fullHost}`
`${apiBase}?scheme=${scheme}&host=${fullHost}`,
);
});
2 changes: 0 additions & 2 deletions client/src/components/Footer/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Necessary to override default z-index value of appbar
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

import { Theme } from '@mui/material/styles';
import { makeStyles } from 'tss-react/mui';
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Header/__tests__/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Header from '../Header';

import { MemoryRouter } from 'react-router-dom';
import { useAppStore } from '~/store/app';
import { beforeEach, expect, test } from 'vitest';

// boilerplate for mocking zustand which uses hooks outside of a component
beforeEach(() => {
Expand All @@ -24,7 +25,7 @@ test('renders wide screen Inferno Header', () => {
toggleDrawer={() => (drawerOpen = !drawerOpen)}
/>
</ThemeProvider>
</MemoryRouter>
</MemoryRouter>,
);

const logoElement = screen.getByRole('img');
Expand Down
7 changes: 4 additions & 3 deletions client/src/components/Header/__tests__/HeaderSmall.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import Header from '../Header';

import { MemoryRouter } from 'react-router-dom';
import { useAppStore } from '~/store/app';
import { beforeEach, expect, test } from 'vitest';

// boilerplate for mocking zustand which uses hooks outside of a component
beforeEach(() => {
const { result } = renderHook(() => useAppStore((state) => state));
result.current.windowIsSmall = true;
});

test('renders narrow screen Inferno Header', () => {
test('renders narrow screen Inferno Header', async () => {
let drawerOpen = false;

render(
Expand All @@ -25,14 +26,14 @@ test('renders narrow screen Inferno Header', () => {
toggleDrawer={() => (drawerOpen = !drawerOpen)}
/>
</ThemeProvider>
</MemoryRouter>
</MemoryRouter>,
);

const buttonElement = screen.getAllByRole('button')[0];
expect(buttonElement).toHaveAttribute('aria-label', 'menu');

// test icon drawer control
expect(drawerOpen).toBe(false);
userEvent.click(buttonElement);
await userEvent.click(buttonElement);
expect(drawerOpen).toBe(true);
});
4 changes: 2 additions & 2 deletions client/src/components/InputsModal/AuthSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const authSettings = {
export const getAuthFields = (
authType: AuthType,
authValues: Map<string, unknown>,
components: TestInput[]
components: TestInput[],
): TestInput[] => {
const fields = [
{
Expand Down Expand Up @@ -232,7 +232,7 @@ export const accessSettings = {
export const getAccessFields = (
authType: AuthType,
accessValues: Map<string, unknown>,
components: TestInput[]
components: TestInput[],
): TestInput[] => {
const fields = [
{
Expand Down
10 changes: 5 additions & 5 deletions client/src/components/InputsModal/InputAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const InputAccess: FC<InputAccessProps> = ({ requirement, index, inputsMap, setI
const [authType, setAuthType] = React.useState<string>(
requirement.options?.components
? (requirement.options?.components[0].default as string)
: 'public'
: 'public',
);
const [accessFields, setAccessFields] = React.useState<TestInput[]>(
getAccessFields(authType as AuthType, accessValues, requirement.options?.components || [])
getAccessFields(authType as AuthType, accessValues, requirement.options?.components || []),
);

useEffect(() => {
Expand All @@ -44,7 +44,7 @@ const InputAccess: FC<InputAccessProps> = ({ requirement, index, inputsMap, setI
field.default = field.options?.list_options[0].value;
}
return field;
})
}),
);

const combinedStartingValues = getStartingValues();
Expand All @@ -64,7 +64,7 @@ const InputAccess: FC<InputAccessProps> = ({ requirement, index, inputsMap, setI
useEffect(() => {
// Recalculate hidden fields
setAccessFields(
getAccessFields(authType as AuthType, accessValues, requirement.options?.components || [])
getAccessFields(authType as AuthType, accessValues, requirement.options?.components || []),
);

// Update inputsMap while maintaining hidden values
Expand All @@ -82,7 +82,7 @@ const InputAccess: FC<InputAccessProps> = ({ requirement, index, inputsMap, setI
// Pre-populate values from AuthFields, requirement, and inputsMap in order of precedence
const fieldDefaultValues = accessFields.reduce(
(acc, field) => ({ ...acc, [field.name]: field.default }),
{}
{},
) as Auth;
const requirementDefaultValues =
requirement.default && typeof requirement.default === 'string'
Expand Down
Loading
Loading