diff --git a/src/__tests__/AssignBadgePopup.test.js b/src/components/Badge/__tests__/AssignBadgePopup.test.js similarity index 98% rename from src/__tests__/AssignBadgePopup.test.js rename to src/components/Badge/__tests__/AssignBadgePopup.test.js index 3dcc1e84ea..4c623cbff0 100644 --- a/src/__tests__/AssignBadgePopup.test.js +++ b/src/components/Badge/__tests__/AssignBadgePopup.test.js @@ -5,7 +5,7 @@ import thunk from 'redux-thunk'; import configureStore from 'redux-mock-store'; import AssignBadgePopup from 'components/Badge/AssignBadgePopup'; import { Provider } from 'react-redux'; -import { themeMock } from './mockStates'; +import { themeMock } from '../../../__tests__/mockStates'; const mockStore = configureStore([thunk]); diff --git a/src/__tests__/ForcePasswordUpdate.test.js b/src/components/ForcePasswordUpdate/__tests__/ForcePasswordUpdate.test.js similarity index 94% rename from src/__tests__/ForcePasswordUpdate.test.js rename to src/components/ForcePasswordUpdate/__tests__/ForcePasswordUpdate.test.js index 883a3adcfd..180e0f1591 100644 --- a/src/__tests__/ForcePasswordUpdate.test.js +++ b/src/components/ForcePasswordUpdate/__tests__/ForcePasswordUpdate.test.js @@ -1,16 +1,16 @@ -import { renderWithProvider, renderWithRouterMatch } from './utils.js'; +import { renderWithProvider, renderWithRouterMatch } from '../../../__tests__/utils.js'; import '@testing-library/jest-dom/extend-expect'; import React from 'react'; -import mockState from './mockAdminState.js'; +import mockState from '../../../__tests__/mockAdminState.js'; import { createMemoryHistory } from 'history'; import { rest } from 'msw'; import { setupServer } from 'msw/node'; -import { ENDPOINTS } from '../utils/URL'; +import { ENDPOINTS } from '../../../utils/URL.js'; import { render, screen, fireEvent, waitFor } from '@testing-library/react'; -import routes from './../routes'; -import { ForcePasswordUpdate } from '../components/ForcePasswordUpdate/ForcePasswordUpdate'; -import { forcePasswordUpdate as fPU } from './../actions/updatePassword'; -import { clearErrors } from './../actions/errorsActions'; +import routes from '../../../routes.js'; +import { ForcePasswordUpdate } from '../ForcePasswordUpdate.jsx'; +import { forcePasswordUpdate as fPU } from '../../../actions/updatePassword.js'; +import { clearErrors } from '../../../actions/errorsActions.js'; import { shallow } from 'enzyme'; describe('Force Password Update page structure', () => { diff --git a/src/__tests__/__snapshots__/ForcePasswordUpdate.test.js.snap b/src/components/ForcePasswordUpdate/__tests__/__snapshots__/ForcePasswordUpdate.test.js.snap similarity index 99% rename from src/__tests__/__snapshots__/ForcePasswordUpdate.test.js.snap rename to src/components/ForcePasswordUpdate/__tests__/__snapshots__/ForcePasswordUpdate.test.js.snap index f5d00b442b..05c3c15deb 100644 --- a/src/__tests__/__snapshots__/ForcePasswordUpdate.test.js.snap +++ b/src/components/ForcePasswordUpdate/__tests__/__snapshots__/ForcePasswordUpdate.test.js.snap @@ -70,4 +70,4 @@ exports[`Force Password Update page structure should match the snapshot 1`] = ` -`; +`; \ No newline at end of file diff --git a/src/components/Projects/Overview/Overview.test.jsx b/src/components/Projects/Overview/__tests__/Overview.test.jsx similarity index 95% rename from src/components/Projects/Overview/Overview.test.jsx rename to src/components/Projects/Overview/__tests__/Overview.test.jsx index b9f6712cd9..7b544ec76f 100644 --- a/src/components/Projects/Overview/Overview.test.jsx +++ b/src/components/Projects/Overview/__tests__/Overview.test.jsx @@ -1,5 +1,5 @@ import { render, screen } from '@testing-library/react'; -import Overview from './Overview'; +import Overview from '../Overview'; describe('Overview Component', () => { it('renders correctly with props', () => { diff --git a/src/components/Projects/WBS/AddWBS/AddWBS.test.jsx b/src/components/Projects/WBS/AddWBS/__tests__/AddWBS.test.jsx similarity index 99% rename from src/components/Projects/WBS/AddWBS/AddWBS.test.jsx rename to src/components/Projects/WBS/AddWBS/__tests__/AddWBS.test.jsx index 8d08ce24f1..1f23f065c3 100644 --- a/src/components/Projects/WBS/AddWBS/AddWBS.test.jsx +++ b/src/components/Projects/WBS/AddWBS/__tests__/AddWBS.test.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { render, screen, fireEvent } from '@testing-library/react'; -import AddWBS from './AddWBS'; +import AddWBS from '../AddWBS'; import userEvent from '@testing-library/user-event' import { Provider } from 'react-redux'; import configureMockStore from 'redux-mock-store' diff --git a/src/components/Projects/Projects.test.jsx b/src/components/Projects/__tests__/Projects.test.jsx similarity index 98% rename from src/components/Projects/Projects.test.jsx rename to src/components/Projects/__tests__/Projects.test.jsx index f76d721e5d..118855cee7 100644 --- a/src/components/Projects/Projects.test.jsx +++ b/src/components/Projects/__tests__/Projects.test.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { shallow, mount } from 'enzyme'; -import { Projects } from './Projects'; +import { Projects } from '../Projects'; import { createMemoryHistory } from 'history'; import { PROJECTS, @@ -9,7 +9,7 @@ import { ACTIVE, MEMBERS, WBS, -} from './../../languages/en/ui'; +} from '../../../languages/en/ui'; import { Router } from 'react-router-dom'; diff --git a/src/__tests__/WbsTable.test.js b/src/components/Reports/__tests__/WbsTable.test.js similarity index 100% rename from src/__tests__/WbsTable.test.js rename to src/components/Reports/__tests__/WbsTable.test.js diff --git a/src/__tests__/TeamTable.test.js b/src/components/Teams/__tests__/TeamTable.test.js similarity index 97% rename from src/__tests__/TeamTable.test.js rename to src/components/Teams/__tests__/TeamTable.test.js index 68c71bde61..a9a0186b16 100644 --- a/src/__tests__/TeamTable.test.js +++ b/src/components/Teams/__tests__/TeamTable.test.js @@ -2,7 +2,7 @@ import { mount } from 'enzyme'; import { Provider } from 'react-redux'; import { MemoryRouter } from 'react-router-dom'; import configureMockStore from 'redux-mock-store'; -import TeamTable from '../components/Reports/TeamTable.jsx'; +import TeamTable from '../../Reports/TeamTable.jsx'; import thunk from 'redux-thunk'; const middlewares = [thunk]; diff --git a/src/components/UserManagement/__test__/UserSearchPanel.test.js b/src/components/UserManagement/__test__/UserSearchPanel.test.js deleted file mode 100644 index 13399bcc3a..0000000000 --- a/src/components/UserManagement/__test__/UserSearchPanel.test.js +++ /dev/null @@ -1,111 +0,0 @@ -import React from 'react'; -import { screen, render} from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import UserSearchPanel from '../UserSearchPanel'; -import thunk from 'redux-thunk'; -import configureStore from 'redux-mock-store'; -import { renderWithProvider } from '../../../__tests__/utils'; -import { rolesMock } from '../../../__tests__/mockStates'; -const mockStore = configureStore([thunk]); -const adminAccountMock = { - _id: '5edf141c78f1380017b829a6', - isAdmin: true, - user: { - expiryTimestamp: '2023-08-22T22:51:06.544Z', - iat: 1597272666, - userid: '5edf141c78f1380017b829a6', - role: 'Administrator', - email: 'non_jae@hgn.net' - }, - firstName: 'Non', - lastName: 'Petterson', - role: 'Administrator', - weeklycommittedHours: 10, - email: 'non_jae@hgn.net' -} - - -describe('user search panel', () => { - let onNewUserClick; - let onSearch; - let onActiveFilter; - let store; - beforeEach(() => { - store = mockStore({ - auth: adminAccountMock, - userProfile: adminAccountMock, - role: rolesMock.role - }); - onNewUserClick = jest.fn(); - onSearch = jest.fn(); - onActiveFilter = jest.fn(); - renderWithProvider( - , - { store, } - ); - }); - - describe('Structure', () => { - it('should render one `create new user` button', () => { - expect(screen.getByRole('button', { name: /create new user/i })).toBeInTheDocument(); - }); - it('should render one textbox', () => { - expect(screen.getByRole('textbox')).toBeInTheDocument(); - }); - it('should render one combo box for selection', () => { - expect(screen.getByRole('combobox')).toBeInTheDocument(); - }); - }); - describe('Behavior', () => { - it('should call onNewUserClick() when the user clicks `create new user` button', () => { - userEvent.click(screen.getByRole('button', { name: /create new user/i })); - expect(onNewUserClick).toHaveBeenCalled(); - }); - it('should call onSearch each time the user types one letter', async () => { - await userEvent.type(screen.getByRole('textbox'), 'test', { allAtOnce: false }); - expect(onSearch).toHaveBeenCalledTimes(4); - }); - it('should change value when user types something', async () => { - await userEvent.type(screen.getByRole('textbox'), 'test', { allAtOnce: false }); - expect(screen.getByRole('textbox')).toHaveValue('test'); - }); - it('should change value when user select different option on the combobox', () => { - userEvent.selectOptions(screen.getByRole('combobox'), 'active'); - expect(screen.getByRole('combobox')).toHaveValue('active'); - userEvent.selectOptions(screen.getByRole('combobox'), 'inactive'); - expect(screen.getByRole('combobox')).toHaveValue('inactive'); - }); - it('should fire onActiveFilter() once the user change the value on combobox', () => { - userEvent.selectOptions(screen.getByRole('combobox'), 'active'); - expect(onActiveFilter).toHaveBeenCalled(); - userEvent.selectOptions(screen.getByRole('combobox'), 'inactive'); - expect(onActiveFilter).toHaveBeenCalledTimes(2); - }); - }); - describe('More Behaviors', () => { - it('should not call onSearch when no user input', async () => { - await userEvent.type(screen.getByRole('textbox'), ''); - expect(onSearch).toHaveBeenCalledTimes(0); - }); - it('should change value when user types something', async () => { - await userEvent.type(screen.getByRole('textbox'), 'test all at once', { allAtOnce: true }); - expect(screen.getByRole('textbox')).toHaveValue('test all at once'); - }); - it('should change value when user select different option on the combobox', () => { - userEvent.selectOptions(screen.getByRole('combobox'), 'paused'); - expect(screen.getByRole('combobox')).toHaveValue('paused'); - userEvent.selectOptions(screen.getByRole('combobox'), 'all'); - expect(screen.getByRole('combobox')).toHaveValue('all'); - }); - it('should fire onActiveFilter() once the user change the value on combobox', () => { - userEvent.selectOptions(screen.getByRole('combobox'), 'paused'); - expect(onActiveFilter).toHaveBeenCalled(); - userEvent.selectOptions(screen.getByRole('combobox'), 'all'); - expect(onActiveFilter).toHaveBeenCalledTimes(2); - }); - }); -}); diff --git a/src/components/UserManagement/__test__/ActivationDatePopup.test.js b/src/components/UserManagement/__tests__/ActivationDatePopup.test.js similarity index 100% rename from src/components/UserManagement/__test__/ActivationDatePopup.test.js rename to src/components/UserManagement/__tests__/ActivationDatePopup.test.js diff --git a/src/components/UserManagement/__test__/ActiveInactiveConfirmationPopup.test.js b/src/components/UserManagement/__tests__/ActiveInactiveConfirmationPopup.test.js similarity index 100% rename from src/components/UserManagement/__test__/ActiveInactiveConfirmationPopup.test.js rename to src/components/UserManagement/__tests__/ActiveInactiveConfirmationPopup.test.js diff --git a/src/components/UserManagement/__test__/DeleteUserPopup.test.js b/src/components/UserManagement/__tests__/DeleteUserPopup.test.js similarity index 100% rename from src/components/UserManagement/__test__/DeleteUserPopup.test.js rename to src/components/UserManagement/__tests__/DeleteUserPopup.test.js diff --git a/src/components/UserManagement/__test__/DuplicateNamePopup.test.js b/src/components/UserManagement/__tests__/DuplicateNamePopup.test.js similarity index 100% rename from src/components/UserManagement/__test__/DuplicateNamePopup.test.js rename to src/components/UserManagement/__tests__/DuplicateNamePopup.test.js diff --git a/src/components/UserManagement/__test__/NewUserPopup.test.js b/src/components/UserManagement/__tests__/NewUserPopup.test.js similarity index 100% rename from src/components/UserManagement/__test__/NewUserPopup.test.js rename to src/components/UserManagement/__tests__/NewUserPopup.test.js diff --git a/src/components/UserManagement/__test__/TextSearchBox.test.js b/src/components/UserManagement/__tests__/TextSearchBox.test.js similarity index 100% rename from src/components/UserManagement/__test__/TextSearchBox.test.js rename to src/components/UserManagement/__tests__/TextSearchBox.test.js diff --git a/src/components/UserManagement/__test__/UserTableData.test.js b/src/components/UserManagement/__tests__/UserTableData.test.js similarity index 100% rename from src/components/UserManagement/__test__/UserTableData.test.js rename to src/components/UserManagement/__tests__/UserTableData.test.js diff --git a/src/components/UserManagement/__test__/UserTableSearchHeader.test.js b/src/components/UserManagement/__tests__/UserTableSearchHeader.test.js similarity index 100% rename from src/components/UserManagement/__test__/UserTableSearchHeader.test.js rename to src/components/UserManagement/__tests__/UserTableSearchHeader.test.js diff --git a/src/components/UserProfile/BadgeImage/__test__/BadgeImage.test.js b/src/components/UserProfile/BadgeImage/__tests__/BadgeImage.test.js similarity index 100% rename from src/components/UserProfile/BadgeImage/__test__/BadgeImage.test.js rename to src/components/UserProfile/BadgeImage/__tests__/BadgeImage.test.js diff --git a/src/components/UserProfile/FeaturedBadges/__test__/mockData.js b/src/components/UserProfile/FeaturedBadges/__mocks__/mockData.js similarity index 100% rename from src/components/UserProfile/FeaturedBadges/__test__/mockData.js rename to src/components/UserProfile/FeaturedBadges/__mocks__/mockData.js diff --git a/src/components/UserProfile/FeaturedBadges/__test__/FeaturedBadges.test.js b/src/components/UserProfile/FeaturedBadges/__tests__/FeaturedBadges.test.js similarity index 94% rename from src/components/UserProfile/FeaturedBadges/__test__/FeaturedBadges.test.js rename to src/components/UserProfile/FeaturedBadges/__tests__/FeaturedBadges.test.js index 281811dd13..091aeea019 100644 --- a/src/components/UserProfile/FeaturedBadges/__test__/FeaturedBadges.test.js +++ b/src/components/UserProfile/FeaturedBadges/__tests__/FeaturedBadges.test.js @@ -1,7 +1,7 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import FeaturedBadges from '../FeaturedBadges'; -import mockProps from './mockData' +import mockProps from '../__mocks__/mockData' describe('FeaturedBadges Component', () => { it('renders correctly with badges data', () => { diff --git a/src/components/UserProfile/TimeZoneDropDown/__test__/TimeZoneDropDown.test.js b/src/components/UserProfile/TimeZoneDropDown/__tests__/TimeZoneDropDown.test.js similarity index 100% rename from src/components/UserProfile/TimeZoneDropDown/__test__/TimeZoneDropDown.test.js rename to src/components/UserProfile/TimeZoneDropDown/__tests__/TimeZoneDropDown.test.js diff --git a/src/components/UserProfile/UserLinkLayout/__test__/UserLinkLayout.test.js b/src/components/UserProfile/UserLinkLayout/__tests__/UserLinkLayout.test.js similarity index 100% rename from src/components/UserProfile/UserLinkLayout/__test__/UserLinkLayout.test.js rename to src/components/UserProfile/UserLinkLayout/__tests__/UserLinkLayout.test.js diff --git a/src/components/UserProfile/UserProfileEdit/__test__/LinkModButton.test.js b/src/components/UserProfile/UserProfileEdit/__tests__/LinkModButton.test.js similarity index 100% rename from src/components/UserProfile/UserProfileEdit/__test__/LinkModButton.test.js rename to src/components/UserProfile/UserProfileEdit/__tests__/LinkModButton.test.js diff --git a/src/components/UserProfile/UserProfileEdit/__test__/SaveButton.test.js b/src/components/UserProfile/UserProfileEdit/__tests__/SaveButton.test.js similarity index 100% rename from src/components/UserProfile/UserProfileEdit/__test__/SaveButton.test.js rename to src/components/UserProfile/UserProfileEdit/__tests__/SaveButton.test.js diff --git a/src/components/WeeklySummary/__test__/DueDateTime.test.js b/src/components/WeeklySummary/__tests__/DueDateTime.test.js similarity index 100% rename from src/components/WeeklySummary/__test__/DueDateTime.test.js rename to src/components/WeeklySummary/__tests__/DueDateTime.test.js diff --git a/src/components/WeeklySummary/__test__/WeeklySummary.test.js b/src/components/WeeklySummary/__tests__/WeeklySummary.test.js similarity index 100% rename from src/components/WeeklySummary/__test__/WeeklySummary.test.js rename to src/components/WeeklySummary/__tests__/WeeklySummary.test.js diff --git a/src/components/WeeklySummary/__test__/WeeklySummary.test.jsx b/src/components/WeeklySummary/__tests__/WeeklySummary.test.jsx similarity index 100% rename from src/components/WeeklySummary/__test__/WeeklySummary.test.jsx rename to src/components/WeeklySummary/__tests__/WeeklySummary.test.jsx diff --git a/src/__tests__/WeeklySummary/WeeklySummaryContentTooltip.test.js b/src/components/WeeklySummary/__tests__/WeeklySummaryContentTooltip.test.js similarity index 89% rename from src/__tests__/WeeklySummary/WeeklySummaryContentTooltip.test.js rename to src/components/WeeklySummary/__tests__/WeeklySummaryContentTooltip.test.js index 7f36fed6ce..30ef8992f1 100644 --- a/src/__tests__/WeeklySummary/WeeklySummaryContentTooltip.test.js +++ b/src/components/WeeklySummary/__tests__/WeeklySummaryContentTooltip.test.js @@ -1,5 +1,5 @@ import { render, fireEvent, screen } from '@testing-library/react'; -import { WeeklySummaryContentTooltip, MediaURLTooltip } from '../../components/WeeklySummary/WeeklySummaryTooltips'; // Adjust the import path as needed +import { WeeklySummaryContentTooltip, MediaURLTooltip } from '../WeeklySummaryTooltips'; // Adjust the import path as needed describe('WeeklySummaryContentTooltip Component Tests', () => { it('renders without crashing', () => { @@ -10,7 +10,7 @@ describe('WeeklySummaryContentTooltip Component Tests', () => { it('toggles tooltip on icon click', () => { render(); const icon = screen.getByTestId('summary-content-tooltip-icon'); - fireEvent.mouseOver(icon) + fireEvent.mouseOver(icon); }); });