Minor corrections

Signed-off-by: lmejbar <42239917+lmejbar@users.noreply.github.com>
This commit is contained in:
lmejbar
2021-08-20 17:39:51 +02:00
committed by Fredrik Adelöw
parent c1ef701395
commit 48ac287ee0
4 changed files with 8 additions and 75 deletions
@@ -1,64 +0,0 @@
/*
* Copyright 2020 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import {
render,
act,
RenderResult,
waitFor,
fireEvent,
screen,
} from '@testing-library/react';
import { wrapInTestApp, renderInTestApp } from '@backstage/test-utils';
import { InputTextFilter } from './InputTextFilter';
const SUPPORT_BUTTON_ID = 'support-button';
const POPOVER_ID = 'support-button-popover';
describe('<InputTextFilter />', () => {
// it('renders without exploding', async () => {
// let renderResult: RenderResult;
// await act(async () => {
// renderResult = render(wrapInTestApp(<InputTextFilter />));
// });
// await waitFor(() =>
// expect(renderResult.getByTestId(SUPPORT_BUTTON_ID)).toBeInTheDocument(),
// );
// });
// it('supports passing a title', async () => {
// await renderInTestApp(<InputTextFilter title="Custom title" />);
// fireEvent.click(screen.getByTestId(SUPPORT_BUTTON_ID));
// expect(screen.getByText('Custom title')).toBeInTheDocument();
// });
// it('shows popover on click', async () => {
// let renderResult: RenderResult;
// await act(async () => {
// renderResult = render(wrapInTestApp(<InputTextFilter />));
// });
// let button: HTMLElement;
// await waitFor(() => {
// expect(renderResult.getByTestId(SUPPORT_BUTTON_ID)).toBeInTheDocument();
// button = renderResult.getByTestId(SUPPORT_BUTTON_ID);
// });
// await act(async () => {
// fireEvent.click(button);
// });
// await waitFor(() => {
// expect(renderResult.getByTestId(POPOVER_ID)).toBeInTheDocument();
// });
// });
});
@@ -18,7 +18,7 @@ import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';
const useStyles = makeStyles(theme => ({
const useStyles = makeStyles(() => ({
root: {
'& > *': {
width: '50ch',
@@ -37,7 +37,7 @@ export const InputTextFilter = ({
const [, setSearchCategory] = React.useState('');
const setSearchCategoryValue = event => {
const setSearchCategoryValue = (event: any) => {
setSearchCategory(event.target.value);
};
@@ -45,10 +45,7 @@ const useTechRadarLoader = (id: string | undefined) => {
return { loading, value, error };
};
const RadarComponent = (
props: TechRadarComponentProps,
searchText: string,
): JSX.Element => {
const RadarComponent = (props: TechRadarComponentProps): JSX.Element => {
const { loading, error, value: data } = useTechRadarLoader(props.id);
const mapToEntries = (
@@ -61,10 +58,10 @@ const RadarComponent = (
element =>
element.title
.toLowerCase()
.includes(props.searchText.toLowerCase()) ||
.includes(props.searchText!.toLowerCase()) ||
element.timeline[0].description
?.toLowerCase()
.includes(props.searchText.toLowerCase()),
.includes(props.searchText!.toLowerCase()),
);
}
return filteredArray.map(entry => {
@@ -22,7 +22,7 @@ import {
Content,
ContentHeader,
Page,
Header,
// Header,
SupportButton,
InputTextFilter,
} from '@backstage/core-components';
@@ -48,7 +48,7 @@ export const RadarPage = ({
const classes = useStyles();
const [searchText, setSearchText] = React.useState('');
const searchInput = event => {
const searchInput = (event: any) => {
setSearchText(event.target.value);
};
@@ -66,7 +66,7 @@ export const RadarPage = ({
</ContentHeader>
<Grid container spacing={3} direction="row">
<Grid item xs={12} sm={6} md={4}>
<RadarComponent {...props} searchText={searchText} />
<RadarComponent searchText={searchText} {...props} />
</Grid>
</Grid>
</Content>