Skip to content

Commit

Permalink
Moved hooks and updated hook tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ARADDCC012 committed Feb 14, 2024
1 parent 7cf8b3e commit 6ef925a
Show file tree
Hide file tree
Showing 16 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import createEmotionCache from 'utils/createEmotionCache'

import ThemeModeContext from '../src/contexts/themeModeContext'
import UnsavedChangesContext from '../src/contexts/unsavedChangesContext'
import useThemeMode from '../utils/hooks/useThemeMode'
import useUnsavedChanges from '../utils/hooks/useUnsavedChanges'
import useThemeMode from '../src/hooks/useThemeMode'
import useUnsavedChanges from '../src/hooks/useUnsavedChanges'

// Client-side cache, shared for the whole session of the user in the browser.
const clientSideEmotionCache = createEmotionCache()
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import React, { ChangeEvent, Fragment, useCallback, useState } from 'react'
import ChipSelector from 'src/common/ChipSelector'
import EmptyBlob from 'src/common/EmptyBlob'
import MultipleErrorWrapper from 'src/errors/MultipleErrorWrapper'
import useDebounce from 'src/hooks/useDebounce'
import Wrapper from 'src/Wrapper'
import useDebounce from 'utils/hooks/useDebounce'

interface KeyAndLabel {
key: string
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/MessageAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Alert, { AlertProps } from '@mui/material/Alert'
import Stack from '@mui/material/Stack'
import Link from 'next/link'
import { useEffect, useRef, useState } from 'react'
import useNotification from 'utils/hooks/useNotification'
import useNotification from 'src/hooks/useNotification'

type PartialMessageAlertProps =
| {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/contexts/themeModeContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext } from 'react'

import { ThemeModeHook } from '../../utils/hooks/useThemeMode'
import { ThemeModeHook } from '../hooks/useThemeMode'
import { lightTheme } from '../theme'

const ThemeModeContext = createContext<ThemeModeHook>({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/contexts/unsavedChangesContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext } from 'react'

import { UnsavedChangesHook } from '../../utils/hooks/useUnsavedChanges'
import { UnsavedChangesHook } from '../hooks/useUnsavedChanges'

const UnsavedChangesContext = createContext<UnsavedChangesHook>({
unsavedChanges: false,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Theme } from '@mui/material/styles'
import { ChangeEvent, useCallback, useState } from 'react'

import { darkTheme, lightTheme } from '../../src/theme'
import { darkTheme, lightTheme } from '../theme'

export type ThemeModeHook = {
theme: Theme
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion frontend/src/model/registry/CodeLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CodeIcon from '@mui/icons-material/Code'
import { Box, IconButton, Stack, Tooltip, Typography } from '@mui/material'
import { useTheme } from '@mui/material/styles'
import { ReactElement } from 'react'
import useNotification from 'utils/hooks/useNotification'
import useNotification from 'src/hooks/useNotification'

interface CodeLineProps {
line: string
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/model/settings/AccessRequestSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useState } from 'react'

import { ModelInterface } from '../../../types/v2/types'
import { getErrorMessage } from '../../../utils/fetcher'
import useNotification from '../../../utils/hooks/useNotification'
import useNotification from '../../hooks/useNotification'
import MessageAlert from '../../MessageAlert'

type ModelAccessProps = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/model/settings/ModelAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { patchModel, useGetModel } from '../../../actions/model'
import { useListUsers } from '../../../actions/user'
import { CollaboratorEntry, EntityObject, ModelInterface } from '../../../types/v2/types'
import { getErrorMessage } from '../../../utils/fetcher'
import useNotification from '../../../utils/hooks/useNotification'
import useNotification from '../../hooks/useNotification'
import MessageAlert from '../../MessageAlert'
import EntityItem from './EntityItem'

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/model/settings/ModelDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TeamInterface } from 'types/interfaces'
import { patchModel } from '../../../actions/model'
import { ModelForm, ModelInterface } from '../../../types/v2/types'
import { getErrorMessage } from '../../../utils/fetcher'
import useNotification from '../../../utils/hooks/useNotification'
import useNotification from '../../hooks/useNotification'
import MessageAlert from '../../MessageAlert'

type ModelAccessProps = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/wrapper/ModelSearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { alpha, styled, useTheme } from '@mui/material/styles'
import { useListModels } from 'actions/model'
import { ChangeEvent, useMemo, useState } from 'react'
import Loading from 'src/common/Loading'
import useDebounce from 'src/hooks/useDebounce'
import Link from 'src/Link'
import MessageAlert from 'src/MessageAlert'
import useDebounce from 'utils/hooks/useDebounce'

const Search = styled('div')(({ theme }) => ({
borderRadius: theme.shape.borderRadius,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SnackbarProvider } from 'notistack'
import React from 'react'
import { describe, expect, it } from 'vitest'

import useNotification from './useNotification'
import useNotification from '../../src/hooks/useNotification'

describe('Snackbar', () => {
function TestComponent() {
Expand All @@ -16,15 +16,15 @@ describe('Snackbar', () => {
return <Box>test</Box>
}

it('renders a Snackbar component', async () => {
it('displays a snackbar when a notification is sent', async () => {
render(
<SnackbarProvider>
<TestComponent />
</SnackbarProvider>,
)

await waitFor(async () => {
expect(await screen.findByText('Notification message')).not.toBeUndefined()
expect(await screen.findByText('Notification message')).toBeDefined()
})
})
})
1 change: 0 additions & 1 deletion frontend/test/model/common/ValidationErrorIcon.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('ValidationErrorIcon', () => {
</ThemeProvider>,
)

screen.debug()
await waitFor(async () => {
expect(container.childElementCount).toEqual(0)
})
Expand Down

0 comments on commit 6ef925a

Please sign in to comment.