Skip to content

Commit

Permalink
Merge pull request #1458 from ral-facilities/misc-fixes
Browse files Browse the repository at this point in the history
Misc fixes
  • Loading branch information
louise-davies authored Nov 11, 2022
2 parents 436f69a + 139877b commit 231151a
Show file tree
Hide file tree
Showing 49 changed files with 274 additions and 258 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"test": "yarn test:unit && yarn test:e2e",
"test:unit": "yarn workspaces foreach --interlaced --verbose --parallel --jobs 3 --exclude datagateway run test",
"test:e2e": "yarn workspaces foreach --interlaced --verbose --parallel --jobs 3 run e2e",
"datagateway-dataview": "cd packages/datagateway-dataview && yarn start",
"datagateway-download": "cd packages/datagateway-download && yarn start",
"datagateway-search": "cd packages/datagateway-search && yarn start",
"datagateway-dataview": "yarn workspace datagateway-dataview start",
"datagateway-download": "yarn workspace datagateway-download start",
"datagateway-search": "yarn workspace datagateway-search start",
"postinstall": "husky install"
},
"packageManager": "yarn@3.2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ exports[`Visit details panel component should check if multiple publications res
>
<button
aria-controls="visit-details-panel"
aria-selected="false"
class="MuiButtonBase-root MuiTab-root MuiTab-textColorSecondary css-1a4cg4j-MuiButtonBase-root-MuiTab-root"
aria-selected="true"
class="MuiButtonBase-root MuiTab-root MuiTab-textColorSecondary Mui-selected css-1a4cg4j-MuiButtonBase-root-MuiTab-root"
id="visit-details-tab"
role="tab"
tabindex="-1"
tabindex="0"
type="button"
>
investigations.details.label
Expand Down Expand Up @@ -254,11 +254,11 @@ exports[`Visit details panel component should check if multiple samples result i
>
<button
aria-controls="visit-details-panel"
aria-selected="false"
class="MuiButtonBase-root MuiTab-root MuiTab-textColorSecondary css-1a4cg4j-MuiButtonBase-root-MuiTab-root"
aria-selected="true"
class="MuiButtonBase-root MuiTab-root MuiTab-textColorSecondary Mui-selected css-1a4cg4j-MuiButtonBase-root-MuiTab-root"
id="visit-details-tab"
role="tab"
tabindex="-1"
tabindex="0"
type="button"
>
investigations.details.label
Expand Down Expand Up @@ -484,11 +484,11 @@ exports[`Visit details panel component should gracefully handles InvestigationUs
>
<button
aria-controls="visit-details-panel"
aria-selected="false"
class="MuiButtonBase-root MuiTab-root MuiTab-textColorSecondary css-1a4cg4j-MuiButtonBase-root-MuiTab-root"
aria-selected="true"
class="MuiButtonBase-root MuiTab-root MuiTab-textColorSecondary Mui-selected css-1a4cg4j-MuiButtonBase-root-MuiTab-root"
id="visit-details-tab"
role="tab"
tabindex="-1"
tabindex="0"
type="button"
>
investigations.details.label
Expand Down Expand Up @@ -692,11 +692,11 @@ exports[`Visit details panel component should render correctly 1`] = `
>
<button
aria-controls="visit-details-panel"
aria-selected="false"
class="MuiButtonBase-root MuiTab-root MuiTab-textColorSecondary css-1a4cg4j-MuiButtonBase-root-MuiTab-root"
aria-selected="true"
class="MuiButtonBase-root MuiTab-root MuiTab-textColorSecondary Mui-selected css-1a4cg4j-MuiButtonBase-root-MuiTab-root"
id="visit-details-tab"
role="tab"
tabindex="-1"
tabindex="0"
type="button"
>
investigations.details.label
Expand Down Expand Up @@ -870,11 +870,11 @@ exports[`Visit details panel component should render user, sample and publicatio
>
<button
aria-controls="visit-details-panel"
aria-selected="false"
class="MuiButtonBase-root MuiTab-root MuiTab-textColorSecondary css-1a4cg4j-MuiButtonBase-root-MuiTab-root"
aria-selected="true"
class="MuiButtonBase-root MuiTab-root MuiTab-textColorSecondary Mui-selected css-1a4cg4j-MuiButtonBase-root-MuiTab-root"
id="visit-details-tab"
role="tab"
tabindex="-1"
tabindex="0"
type="button"
>
investigations.details.label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const VisitDetailsPanel = (
textColor="secondary"
indicatorColor="secondary"
scrollButtons="auto"
value={selectedTab}
value={selectedTab ?? DEFAULT_TAB}
onChange={(event, newValue) => changeTab(newValue)}
aria-label={t('investigations.details.tabs_label')}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ describe('Investigation details panel component', () => {
it('Shows "No <field> provided" incase of a null field', async () => {
const { summary, doi, startDate, endDate, ...amendedRowData } = rowData;

(axios.get as jest.Mock).mockReturnValueOnce({
(axios.get as jest.Mock).mockResolvedValueOnce({
data: amendedRowData,
});

Expand Down
2 changes: 1 addition & 1 deletion packages/datagateway-common/src/handleICATError.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxiosError } from 'axios';
import * as log from 'loglevel';
import log from 'loglevel';
import handleICATError from './handleICATError';
import { AnyAction } from 'redux';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/datagateway-common/src/handleICATError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxiosError } from 'axios';
import * as log from 'loglevel';
import log from 'loglevel';
import {
NotificationType,
InvalidateTokenType,
Expand Down
2 changes: 2 additions & 0 deletions packages/datagateway-common/src/setupTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import thunk from 'redux-thunk';
import configureStore from 'redux-mock-store';
import { createMemoryHistory, History } from 'history';

jest.setTimeout(15000);

// Unofficial React 17 Enzyme adapter
Enzyme.configure({ adapter: new Adapter() });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports[`Data cell component renders correctly 1`] = `
title="non nested property"
>
<ForwardRef(Typography)
component="span"
noWrap={true}
variant="body2"
>
Expand Down Expand Up @@ -61,6 +62,7 @@ exports[`Data cell component renders nested cell data correctly 1`] = `
title="nested property"
>
<ForwardRef(Typography)
component="span"
noWrap={true}
variant="body2"
>
Expand Down Expand Up @@ -106,6 +108,7 @@ exports[`Data cell component renders provided cell data correctly 1`] = `
title="provided test"
>
<ForwardRef(Typography)
component="span"
noWrap={true}
variant="body2"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const DataCell = React.memo((props: CellRendererProps): React.ReactElement => {
enterDelay={500}
sx={{ flex: 1 }}
>
<Typography variant="body2" noWrap>
<Typography variant="body2" noWrap component="span">
{cellContent}
</Typography>
</ArrowTooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('Table component', () => {
.find('[role="row"]')
.find('[role="gridcell"]')
.first()
.find('p')
.find('span')
.text()
).toEqual('test1');

Expand All @@ -105,7 +105,7 @@ describe('Table component', () => {
.find('[role="row"]')
.find('[role="gridcell"]')
.last()
.find('p')
.find('span')
.text()
).toEqual('2 B');
});
Expand Down
2 changes: 1 addition & 1 deletion packages/datagateway-dataview/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { mount } from 'enzyme';
import * as log from 'loglevel';
import log from 'loglevel';
import { Provider } from 'react-redux';

jest.mock('loglevel');
Expand Down
2 changes: 1 addition & 1 deletion packages/datagateway-dataview/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Location,
Action,
} from 'history';
import * as log from 'loglevel';
import log from 'loglevel';
import React from 'react';
import { Translation } from 'react-i18next';
import { batch, connect, Provider } from 'react-redux';
Expand Down
3 changes: 3 additions & 0 deletions packages/datagateway-dataview/src/__mocks__/loglevel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// TODO: move __mocks__ folder back to package root once facebook/create-react-app#7539 is fixed

export default jest.createMockFromModule('loglevel');
2 changes: 1 addition & 1 deletion packages/datagateway-dataview/src/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios';
import { MicroFrontendId, RegisterRouteType } from 'datagateway-common';
import LogoLight from 'datagateway-common/src/images/datagateway-logo.svg';
import LogoDark from 'datagateway-common/src/images/datgateway-white-text-blue-mark-logo.svg';
import * as log from 'loglevel';
import log from 'loglevel';
import { fetchSettings } from './';

jest.mock('loglevel');
Expand Down
4 changes: 2 additions & 2 deletions packages/datagateway-dataview/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import singleSpaReact from 'single-spa-react';
import * as log from 'loglevel';
import log from 'loglevel';
import {
MicroFrontendId,
MicroFrontendToken,
Expand Down Expand Up @@ -184,7 +184,7 @@ if (
.then((response) => {
const jwtHeader = { alg: 'HS256', typ: 'JWT' };
const payload = {
sessionID: response.data.sessionID,
sessionId: response.data.sessionID,
username: 'Thomas409',
};
const jwt = jsrsasign.KJUR.jws.JWS.sign(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { ReactWrapper } from 'enzyme';
import { QueryClientProvider, QueryClient } from 'react-query';
import DoiRedirect from './doiRedirect.component';
import { createLocation, createMemoryHistory } from 'history';
import * as log from 'loglevel';
import log from 'loglevel';
import { AnyAction } from 'redux';

jest.mock('loglevel');
// jest.mock('loglevel');

jest.mock('datagateway-common', () => {
const originalModule = jest.requireActual('datagateway-common');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import React from 'react';
import { Redirect, useParams } from 'react-router-dom';
import { paths } from './pageContainer.component';
import * as log from 'loglevel';
import log from 'loglevel';

type DoiRedirectRouteParams = {
facilityName: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/datagateway-dataview/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { StateType } from './state/app.types';
import { initialState as dgDataViewInitialState } from './state/reducers/dgdataview.reducer';
import { dGCommonInitialState } from 'datagateway-common';

jest.setTimeout(15000);

// Unofficial React 17 Enzyme adapter
Enzyme.configure({ adapter: new Adapter() });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import axios, { type AxiosRequestConfig } from 'axios';
import { downloadDatafile } from 'datagateway-common';
import type { Datafile } from 'datagateway-common/lib/app.types';
import * as React from 'react';
import { QueryClient, QueryClientProvider } from 'react-query';
import { QueryClient, QueryClientProvider, setLogger } from 'react-query';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import { combineReducers, createStore, type Store } from 'redux';
Expand All @@ -25,6 +25,13 @@ jest.mock('datagateway-common', () => ({
downloadDatafile: jest.fn(),
}));

// silence react-query errors
setLogger({
log: console.log,
warn: console.warn,
error: jest.fn(),
});

function createMockStore(): Store {
return createStore(
combineReducers({
Expand Down Expand Up @@ -556,7 +563,7 @@ describe('DatafilePreviewer', () => {
).toHaveStyle({
'font-size': '14px',
});
}, 10000);
});

it('should have a zoom out button that decreases the size of the datafile preview when clicked', async () => {
renderComponent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { RenderResult } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import { DGThemeProvider } from 'datagateway-common';
import * as React from 'react';
import { QueryClient, QueryClientProvider } from 'react-query';
import { QueryClient, QueryClientProvider, setLogger } from 'react-query';
import { Provider } from 'react-redux';
import { combineReducers, createStore, Store } from 'redux';
import { StateType } from '../../../state/app.types';
Expand All @@ -14,6 +14,13 @@ import {
import { mockDatafile, mockTxtFileContent } from '../testData';
import TextPreview from './textPreview.component';

// silence react-query errors
setLogger({
log: console.log,
warn: console.warn,
error: jest.fn(),
});

function renderComponent(store: Store): RenderResult {
return render(
<DGThemeProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ describe('DLS MyData table component', () => {

wrapper = createWrapper();

expect(wrapper.find('[aria-colindex=5]').find('p').text()).toEqual('');
expect(wrapper.find('[aria-colindex=5]').find('span').text()).toEqual('');
});

it('displays details panel when expanded', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,6 @@ describe('DLS Visits table component', () => {

const wrapper = createWrapper();

expect(wrapper.find('[aria-colindex=4]').find('p').text()).toEqual('');
expect(wrapper.find('[aria-colindex=4]').find('span').text()).toEqual('');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,11 @@ describe('Investigation table component', () => {
it('renders date objects as just the date', () => {
const wrapper = createWrapper();

expect(wrapper.find('[aria-colindex=9]').find('p').text()).toEqual(
expect(wrapper.find('[aria-colindex=9]').find('span').text()).toEqual(
'2019-07-23'
);

expect(wrapper.find('[aria-colindex=10]').find('p').text()).toEqual(
expect(wrapper.find('[aria-colindex=10]').find('span').text()).toEqual(
'2019-07-24'
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ describe('ISIS Investigations table component', () => {

it('displays the correct user as the PI ', () => {
const wrapper = createWrapper();
expect(wrapper.find('[aria-colindex=7]').find('p').text()).toEqual(
expect(wrapper.find('[aria-colindex=7]').find('span').text()).toEqual(
'Test PI'
);
});
Expand Down Expand Up @@ -508,8 +508,8 @@ describe('ISIS Investigations table component', () => {
});

wrapper = createWrapper();
expect(wrapper.find('[aria-colindex=5]').find('p').text()).toEqual('');
expect(wrapper.find('[aria-colindex=7]').find('p').text()).toEqual('');
expect(wrapper.find('[aria-colindex=5]').find('span').text()).toEqual('');
expect(wrapper.find('[aria-colindex=7]').find('span').text()).toEqual('');
});

it('renders actions correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,11 @@ describe('ISIS MyData table component', () => {
});
wrapper = createWrapper();

expect(wrapper.find('[aria-colindex=3]').find('p').text()).toEqual(
expect(wrapper.find('[aria-colindex=3]').find('span').text()).toEqual(
'Test 1 title'
);

expect(wrapper.find('[aria-colindex=6]').find('p').text()).toEqual(
expect(wrapper.find('[aria-colindex=6]').find('span').text()).toEqual(
'Test 1 name'
);

Expand All @@ -562,8 +562,8 @@ describe('ISIS MyData table component', () => {
});
wrapper = createWrapper();

expect(wrapper.find('[aria-colindex=4]').find('p').text()).toEqual('');
expect(wrapper.find('[aria-colindex=4]').find('span').text()).toEqual('');

expect(wrapper.find('[aria-colindex=7]').find('p').text()).toEqual('');
expect(wrapper.find('[aria-colindex=7]').find('span').text()).toEqual('');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ describe('ISIS Studies table component', () => {

const wrapper = createWrapper();

expect(wrapper.find('[aria-colindex=2]').find('p').first().text()).toBe(
expect(wrapper.find('[aria-colindex=2]').find('span').first().text()).toBe(
'Test investigation'
);
});
Expand Down
Loading

0 comments on commit 231151a

Please sign in to comment.