From d3386190af2a8c9dc7a63482bdecd882e3a40172 Mon Sep 17 00:00:00 2001 From: "Dusan Mijatovic (PC2020)" Date: Mon, 21 Aug 2023 15:25:25 +0200 Subject: [PATCH] tests: additional unit tests --- .../components/admin/rsd-contributors/apiContributors.tsx | 2 +- frontend/components/cards/CardContentFrame.tsx | 4 ++-- frontend/components/cards/CardImageFrame.tsx | 4 ++-- frontend/components/form/ControlledTextField.tsx | 5 ++--- frontend/components/form/HelperTextWithCounter.tsx | 4 ++-- frontend/components/layout/ConfirmDeleteModal.tsx | 4 ++-- frontend/components/layout/ContentContainer.tsx | 4 ++-- frontend/components/layout/SortableList.tsx | 4 ++-- frontend/components/mention/editMentionContext.tsx | 5 ++--- frontend/components/menu/IconBtnMenuOnAction.tsx | 4 ++-- frontend/components/organisation/metadata/Links.tsx | 4 ++-- .../components/organisation/settings/SettingsNavItems.tsx | 4 ++-- .../components/organisation/tabs/OrganisationTabItems.tsx | 4 ++-- frontend/components/organisation/units/ResearchUnitItem.tsx | 2 -- frontend/components/projects/edit/editProjectPages.tsx | 6 +++--- .../projects/overview/cards/ProjectOverviewGrid.tsx | 4 ++-- .../projects/overview/list/ProjectListItemContent.tsx | 4 ++-- .../projects/overview/list/ProjectOverviewList.tsx | 4 ++-- frontend/components/software/edit/editSoftwarePages.tsx | 6 +++--- .../software/overview/cards/SoftwareOverviewGrid.tsx | 4 ++-- .../software/overview/cards/SoftwareOverviewMasonry.tsx | 4 ++-- .../components/software/overview/list/OverviewListItem.tsx | 4 ++-- .../software/overview/list/SoftwareListItemContent.tsx | 4 ++-- .../software/overview/list/SoftwareOverviewList.tsx | 4 ++-- frontend/components/table/EditableTable.tsx | 4 ++-- frontend/components/user/UserNavItems.tsx | 6 +++--- frontend/components/user/project-quality/SortableTable.tsx | 2 +- frontend/config/menuItems.ts | 4 ++-- 28 files changed, 55 insertions(+), 59 deletions(-) diff --git a/frontend/components/admin/rsd-contributors/apiContributors.tsx b/frontend/components/admin/rsd-contributors/apiContributors.tsx index 5fb48ac0f..3063097ea 100644 --- a/frontend/components/admin/rsd-contributors/apiContributors.tsx +++ b/frontend/components/admin/rsd-contributors/apiContributors.tsx @@ -38,7 +38,7 @@ export function useContributors({token, orderBy}:useContributorsProps) { const {searchFor, page, rows, setCount} = usePaginationWithSearch('Find contributor') const [contributors, setContributors] = useState([]) const [loading, setLoading] = useState(true) - const [columns, setColumns] = useState(createColumns(token)) + const [columns] = useState(createColumns(token)) const loadContributors = useCallback(async () => { let abort = false diff --git a/frontend/components/cards/CardContentFrame.tsx b/frontend/components/cards/CardContentFrame.tsx index e4abbd0e0..81aa51823 100644 --- a/frontend/components/cards/CardContentFrame.tsx +++ b/frontend/components/cards/CardContentFrame.tsx @@ -3,9 +3,9 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' -export default function CardContentFrame({children}:{children:React.JSX.Element[]}) { +export default function CardContentFrame({children}:{children:JSX.Element[]}) { return (
{children} diff --git a/frontend/components/cards/CardImageFrame.tsx b/frontend/components/cards/CardImageFrame.tsx index c2c0b793f..74ab569d4 100644 --- a/frontend/components/cards/CardImageFrame.tsx +++ b/frontend/components/cards/CardImageFrame.tsx @@ -3,9 +3,9 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' -export default function CardImageFrame({children}:{children:React.JSX.Element}) { +export default function CardImageFrame({children}:{children:JSX.Element}) { return (
{children} diff --git a/frontend/components/form/ControlledTextField.tsx b/frontend/components/form/ControlledTextField.tsx index 4f9119c5a..9350cbc39 100644 --- a/frontend/components/form/ControlledTextField.tsx +++ b/frontend/components/form/ControlledTextField.tsx @@ -6,8 +6,7 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' -import {useEffect, useRef} from 'react' +import {useEffect, useRef, JSX} from 'react' import {Controller} from 'react-hook-form' import TextField, {TextFieldProps} from '@mui/material/TextField' import HelperTextWithCounter from './HelperTextWithCounter' @@ -25,7 +24,7 @@ export type ControlledTextFieldOptions = { variant?: 'outlined'|'standard' useNull?: boolean, defaultValue?: string | number | null - helperTextMessage?: string | React.JSX.Element + helperTextMessage?: string | JSX.Element helperTextCnt?: string disabled?: boolean muiProps?: TextFieldProps diff --git a/frontend/components/form/HelperTextWithCounter.tsx b/frontend/components/form/HelperTextWithCounter.tsx index 3d0124f56..9e1567ab7 100644 --- a/frontend/components/form/HelperTextWithCounter.tsx +++ b/frontend/components/form/HelperTextWithCounter.tsx @@ -6,9 +6,9 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' -export default function HelperTextWithCounter({message,count}:{message:string|undefined|React.JSX.Element,count:string}) { +export default function HelperTextWithCounter({message,count}:{message:string|undefined|JSX.Element,count:string}) { return ( <> {message} diff --git a/frontend/components/layout/ConfirmDeleteModal.tsx b/frontend/components/layout/ConfirmDeleteModal.tsx index 4f5a8dcef..81c134b0e 100644 --- a/frontend/components/layout/ConfirmDeleteModal.tsx +++ b/frontend/components/layout/ConfirmDeleteModal.tsx @@ -6,7 +6,7 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' import Button from '@mui/material/Button' import Dialog from '@mui/material/Dialog' import DialogActions from '@mui/material/DialogActions' @@ -19,7 +19,7 @@ import WarningIcon from '@mui/icons-material/Warning' type ConfirmDeleteModalProps = { open: boolean, title: string, - body: React.JSX.Element, + body: JSX.Element, onCancel: () => void, onDelete: () => void } diff --git a/frontend/components/layout/ContentContainer.tsx b/frontend/components/layout/ContentContainer.tsx index 14e6a5e63..db059e23c 100644 --- a/frontend/components/layout/ContentContainer.tsx +++ b/frontend/components/layout/ContentContainer.tsx @@ -3,12 +3,12 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' type ContentContainerProps = { element?: 'section' | 'article' | 'main' | 'div' className?: string - children: React.JSX.Element | React.JSX.Element[] + children: JSX.Element | JSX.Element[] } export default function ContentContainer(props: ContentContainerProps) { diff --git a/frontend/components/layout/SortableList.tsx b/frontend/components/layout/SortableList.tsx index 07268397c..2b6e1965c 100644 --- a/frontend/components/layout/SortableList.tsx +++ b/frontend/components/layout/SortableList.tsx @@ -5,7 +5,7 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' import { DndContext, DragEndEvent, useSensor, useSensors, TouchSensor, MouseSensor @@ -23,7 +23,7 @@ export type RequiredListProps = { type SortableListProps={ items:T[], onSorted: (items: T[]) => void - onRenderItem:(item:T,index:number) => React.JSX.Element + onRenderItem:(item:T,index:number) => JSX.Element } export default function SortableList({ diff --git a/frontend/components/mention/editMentionContext.tsx b/frontend/components/mention/editMentionContext.tsx index a76708668..86872e62b 100644 --- a/frontend/components/mention/editMentionContext.tsx +++ b/frontend/components/mention/editMentionContext.tsx @@ -6,8 +6,7 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' -import {createContext} from 'react' +import {createContext,JSX} from 'react' import {MentionItemProps} from '~/types/Mention' import {EditMentionAction, EditMentionState} from './editMentionReducer' import NoMentionItems from './NoMentionItems' @@ -15,7 +14,7 @@ import NoMentionItems from './NoMentionItems' export type EditMentionSettings = { editModalTitle: string, confirmDeleteModalTitle: string, - noItemsComponent:()=>React.JSX.Element + noItemsComponent:()=>JSX.Element } export type EditModalProps = { diff --git a/frontend/components/menu/IconBtnMenuOnAction.tsx b/frontend/components/menu/IconBtnMenuOnAction.tsx index 3247335c5..c5ed729cc 100644 --- a/frontend/components/menu/IconBtnMenuOnAction.tsx +++ b/frontend/components/menu/IconBtnMenuOnAction.tsx @@ -5,7 +5,7 @@ // // SPDX-License-Identifier: Apache-2.0 -import {useState} from 'react' +import {useState, JSX} from 'react' import IconButton from '@mui/material/IconButton' import MoreVertIcon from '@mui/icons-material/MoreVert' import Menu from '@mui/material/Menu' @@ -16,7 +16,7 @@ export type IconBtnMenuOption = { type: 'divider' | 'action' key: string, label: string, - icon?: React.JSX.Element, + icon?: JSX.Element, action: T disabled?: boolean, } diff --git a/frontend/components/organisation/metadata/Links.tsx b/frontend/components/organisation/metadata/Links.tsx index a654eb476..d9e4a35dc 100644 --- a/frontend/components/organisation/metadata/Links.tsx +++ b/frontend/components/organisation/metadata/Links.tsx @@ -5,13 +5,13 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' import Link from 'next/link' export type LinksProps = { title: string, url: string - icon: React.JSX.Element, + icon: JSX.Element, } export default function Links({links=[]}:{links:LinksProps[]}) { diff --git a/frontend/components/organisation/settings/SettingsNavItems.tsx b/frontend/components/organisation/settings/SettingsNavItems.tsx index e1a5b25dc..802d56a8a 100644 --- a/frontend/components/organisation/settings/SettingsNavItems.tsx +++ b/frontend/components/organisation/settings/SettingsNavItems.tsx @@ -5,7 +5,7 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' import InfoIcon from '@mui/icons-material/Info' import PersonIcon from '@mui/icons-material/Person' import SettingsIcon from '@mui/icons-material/Settings' @@ -14,7 +14,7 @@ export type SettingsMenuProps = { id: string, status: string, label: (props?:any)=>string, - icon: React.JSX.Element + icon: JSX.Element } export const settingsMenu: SettingsMenuProps[] = [ diff --git a/frontend/components/organisation/tabs/OrganisationTabItems.tsx b/frontend/components/organisation/tabs/OrganisationTabItems.tsx index 3590e6d88..81a169066 100644 --- a/frontend/components/organisation/tabs/OrganisationTabItems.tsx +++ b/frontend/components/organisation/tabs/OrganisationTabItems.tsx @@ -3,7 +3,7 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' import InfoIcon from '@mui/icons-material/Info' import TerminalIcon from '@mui/icons-material/Terminal' import AccountTreeIcon from '@mui/icons-material/AccountTree' @@ -21,7 +21,7 @@ type IsVisibleProps = Partial & { export type OrganisationTabItemProps = { id: string, label: (props:any)=>string, - icon: React.JSX.Element, + icon: JSX.Element, isVisible: (props: IsVisibleProps) => boolean } diff --git a/frontend/components/organisation/units/ResearchUnitItem.tsx b/frontend/components/organisation/units/ResearchUnitItem.tsx index 09a30b883..29e25bd2f 100644 --- a/frontend/components/organisation/units/ResearchUnitItem.tsx +++ b/frontend/components/organisation/units/ResearchUnitItem.tsx @@ -29,8 +29,6 @@ type UnitListItemProps = { export default function UnitItem({pos,slug,name,website,logo_id,isMaintainer,onEdit}: UnitListItemProps) { const router = useRouter() - // remove query params from url (id) - const baseUrl = router.asPath.split('?') const slugs = [] if (typeof router.query['slug'] === 'string') { slugs.push(router.query['slug']) diff --git a/frontend/components/projects/edit/editProjectPages.tsx b/frontend/components/projects/edit/editProjectPages.tsx index 800e37e00..777cf869b 100644 --- a/frontend/components/projects/edit/editProjectPages.tsx +++ b/frontend/components/projects/edit/editProjectPages.tsx @@ -5,7 +5,7 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' import dynamic from 'next/dynamic' import InfoIcon from '@mui/icons-material/Info' @@ -53,8 +53,8 @@ export type EditProjectPageProps = { id: string, status: string, label: string, - icon: React.JSX.Element, - render: () => React.JSX.Element + icon: JSX.Element, + render: () => JSX.Element } export const editProjectPage: EditProjectPageProps[] = [ diff --git a/frontend/components/projects/overview/cards/ProjectOverviewGrid.tsx b/frontend/components/projects/overview/cards/ProjectOverviewGrid.tsx index 1897d5306..59f646a9e 100644 --- a/frontend/components/projects/overview/cards/ProjectOverviewGrid.tsx +++ b/frontend/components/projects/overview/cards/ProjectOverviewGrid.tsx @@ -6,9 +6,9 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' -export default function ProjectOverviewGrid({children}: { children: React.JSX.Element | React.JSX.Element[] }) { +export default function ProjectOverviewGrid({children}: { children: JSX.Element | JSX.Element[] }) { // console.log('ProjectOverviewGrid') return (
React.JSX.Element + icon: JSX.Element, + render: () => JSX.Element } export const editSoftwarePage:EditSoftwarePageProps[] = [{ diff --git a/frontend/components/software/overview/cards/SoftwareOverviewGrid.tsx b/frontend/components/software/overview/cards/SoftwareOverviewGrid.tsx index bafa7bc78..83f6f030b 100644 --- a/frontend/components/software/overview/cards/SoftwareOverviewGrid.tsx +++ b/frontend/components/software/overview/cards/SoftwareOverviewGrid.tsx @@ -6,9 +6,9 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' -export default function SoftwareOverviewGrid({children}: { children: React.JSX.Element | React.JSX.Element[] }) { +export default function SoftwareOverviewGrid({children}: { children: JSX.Element | JSX.Element[] }) { return (
= { sx?: SxProps order?: OrderProps patchFn?: (props: UpdateProps) => Promise<{ status: number, message: string }> - renderFn?: (data:T) => React.JSX.Element + renderFn?: (data:T) => JSX.Element } export type OrderByProps = { diff --git a/frontend/components/user/UserNavItems.tsx b/frontend/components/user/UserNavItems.tsx index a3f25d985..9e754b81c 100644 --- a/frontend/components/user/UserNavItems.tsx +++ b/frontend/components/user/UserNavItems.tsx @@ -8,7 +8,7 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' import dynamic from 'next/dynamic' import TerminalIcon from '@mui/icons-material/Terminal' @@ -44,8 +44,8 @@ export type UserMenuProps = { id: string, status: string, label: (props:any)=>string, - icon: React.JSX.Element, - component: (props: any) => React.JSX.Element + icon: JSX.Element, + component: (props: any) => JSX.Element showSearch: boolean } diff --git a/frontend/components/user/project-quality/SortableTable.tsx b/frontend/components/user/project-quality/SortableTable.tsx index f6ed3a870..30de96795 100644 --- a/frontend/components/user/project-quality/SortableTable.tsx +++ b/frontend/components/user/project-quality/SortableTable.tsx @@ -35,7 +35,7 @@ type SortableTableProps = { export default function SortableTable({metadata, initialData, initialOrder=''}: SortableTableProps) { const propKeys = Array.from(metadata.keys()) const [sortColumn, setSortColumn] = useState(initialOrder) - const [data, setData] = useState(initialData) + const [data] = useState(initialData) const [ascending, setAscending] = useState(true) function getDirection(metadataKey:string){ diff --git a/frontend/config/menuItems.ts b/frontend/config/menuItems.ts index 95aaf511d..68714949c 100644 --- a/frontend/config/menuItems.ts +++ b/frontend/config/menuItems.ts @@ -7,7 +7,7 @@ // // SPDX-License-Identifier: Apache-2.0 -import React from 'react' +import {JSX} from 'react' export type MenuItemType = { type?: 'link' | 'function' |'divider' @@ -18,7 +18,7 @@ export type MenuItemType = { match?: string, // used to customize menu items per user/profile active?: boolean - icon?: React.JSX.Element, + icon?: JSX.Element, // optional, but fn is provided it will have higher priority // than path fn?: Function,