Skip to content

Commit c7a090d

Browse files
committed
test linting
1 parent 81781f0 commit c7a090d

7 files changed

Lines changed: 18 additions & 12 deletions

File tree

src/frontend/src/tests/app/AppPublic.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
* See the LICENSE file in the repository root folder for details.
44
*/
55

6-
import { AuthenticatedUser, User } from 'shared';
6+
import { AuthenticatedUser } from 'shared';
77
import { render, screen, routerWrapperBuilder } from '../test-support/test-utils';
8-
import { exampleAdminUser } from '../test-support/test-data/users.stub';
98
import { mockAuth } from '../test-support/test-data/test-utils.stub';
109
import { useAuth } from '../../hooks/auth.hooks';
1110
import { routes } from '../../utils/routes';

src/frontend/src/tests/pages/CreateChangeRequestPage/CreateProposedSolutionsList.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { mockAuth } from '../../test-support/test-data/test-utils.stub';
1010
import { exampleAdminUser } from '../../test-support/test-data/users.stub';
1111
import * as userHooks from '../../../hooks/users.hooks';
1212
import AppContextUser from '../../../app/AppContextUser';
13+
import { exampleAuthenticatedAdminUser } from '../../test-support/test-data/authenticated-user.stub';
1314

1415
/**
1516
* Sets up the component under test with the desired values and renders it.
@@ -33,7 +34,7 @@ describe('Proposed Solutions List Test Suite', () => {
3334
onboardedTeamTypeIds: [],
3435
onboardingTeamTypeIds: []
3536
});
36-
vi.spyOn(authHooks, 'useAuth').mockReturnValue(mockAuth(false, exampleAdminUser));
37+
vi.spyOn(authHooks, 'useAuth').mockReturnValue(mockAuth(false, exampleAuthenticatedAdminUser));
3738
});
3839

3940
it('Renders correctly when empty', () => {

src/frontend/src/tests/pages/HomePage/Home.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as userHooks from '../../../hooks/users.hooks';
1111
import { exampleAdminUser } from '../../test-support/test-data/users.stub';
1212
import { mockAuth } from '../../test-support/test-data/test-utils.stub';
1313
import { mockUseSingleUserSettings } from '../../test-support/mock-hooks';
14+
import { exampleAuthenticatedAdminUser } from '../../test-support/test-data/authenticated-user.stub';
1415

1516
vi.mock('../../../pages/HomePage/components/UsefulLinks', () => {
1617
return {
@@ -53,7 +54,7 @@ const renderComponent = () => {
5354

5455
describe('home component', () => {
5556
beforeEach(() => {
56-
vi.spyOn(authHooks, 'useAuth').mockReturnValue(mockAuth(false, exampleAdminUser));
57+
vi.spyOn(authHooks, 'useAuth').mockReturnValue(mockAuth(false, exampleAuthenticatedAdminUser));
5758
vi.spyOn(userHooks, 'useCurrentUser').mockReturnValue({
5859
...exampleAdminUser,
5960
organizations: [],

src/frontend/src/tests/pages/SettingsPage/Settings.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { render, screen, routerWrapperBuilder } from '../../test-support/test-ut
77
import { routes } from '../../../utils/routes';
88
import Settings from '../../../pages/SettingsPage/SettingsPage';
99
import * as authHooks from '../../../hooks/auth.hooks';
10-
import { exampleAdminUser } from '../../test-support/test-data/users.stub';
1110
import { mockAuth } from '../../test-support/test-data/test-utils.stub';
11+
import { exampleAuthenticatedAdminUser } from '../../test-support/test-data/authenticated-user.stub';
1212

1313
vi.mock('../../../pages/SettingsPage/UserSettings/UserSettings', () => {
1414
return {
@@ -32,7 +32,7 @@ const renderComponent = () => {
3232
};
3333

3434
describe.skip('settings page component', () => {
35-
beforeEach(() => vi.spyOn(authHooks, 'useAuth').mockReturnValue(mockAuth(false, exampleAdminUser)));
35+
beforeEach(() => vi.spyOn(authHooks, 'useAuth').mockReturnValue(mockAuth(false, exampleAuthenticatedAdminUser)));
3636
it('renders all the information', () => {
3737
renderComponent();
3838
expect(screen.getAllByText('Settings').length).toEqual(1);

src/frontend/src/tests/pages/WorkPackageDetailPage/ActivateWorkPackageModalContainer/ActivateWorkPackageModalContainer.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import { exampleWbs1 } from '../../../test-support/test-data/wbs-numbers.stub';
1010
import ActivateWorkPackageModalContainer from '../../../../pages/WorkPackageDetailPage/ActivateWorkPackageModalContainer/ActivateWorkPackageModalContainer';
1111
import { mockAuth, mockUseMutationResult } from '../../../test-support/test-data/test-utils.stub';
1212
import { useCreateActivationChangeRequest } from '../../../../hooks/change-requests.hooks';
13-
import { exampleAdminUser, exampleAllUsers } from '../../../test-support/test-data/users.stub';
13+
import { exampleAllUsers } from '../../../test-support/test-data/users.stub';
1414
import * as authHooks from '../../../../hooks/auth.hooks';
1515
import * as userHooks from '../../../../hooks/users.hooks';
1616
import {
1717
mockLogUserInDevReturnValue,
1818
mockLogUserInReturnValue,
1919
mockUseAllUsersReturnValue
2020
} from '../../../test-support/mock-hooks';
21+
import { exampleAuthenticatedAdminUser } from '../../../test-support/test-data/authenticated-user.stub';
2122

2223
vi.mock('../../../../hooks/change-requests.hooks');
2324
vi.mock('../../../../hooks/toasts.hooks');
@@ -37,7 +38,7 @@ const renderComponent = () => {
3738

3839
describe('activate work package modal container test suite', () => {
3940
beforeEach(() => {
40-
vi.spyOn(authHooks, 'useAuth').mockReturnValue(mockAuth(false, exampleAdminUser));
41+
vi.spyOn(authHooks, 'useAuth').mockReturnValue(mockAuth(false, exampleAuthenticatedAdminUser));
4142
vi.spyOn(userHooks, 'useLogUserIn').mockReturnValue(mockLogUserInReturnValue);
4243
vi.spyOn(userHooks, 'useLogUserInDev').mockReturnValue(mockLogUserInDevReturnValue);
4344
vi.spyOn(userHooks, 'useAllUsers').mockReturnValue(mockUseAllUsersReturnValue(exampleAllUsers));

src/frontend/src/tests/pages/WorkPackageDetailPage/WorkPackagePage.test.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { exampleAdminUser, exampleGuestUser } from '../../test-support/test-data
1616
import WorkPackagePage from '../../../pages/WorkPackageDetailPage/WorkPackagePage';
1717
import AppContextUser from '../../../app/AppContextUser';
1818
import { useCurrentUser } from '../../../hooks/users.hooks';
19+
import {
20+
exampleAuthenticatedAdminUser,
21+
exampleAuthenticatedGuestUser
22+
} from '../../test-support/test-data/authenticated-user.stub';
1923

2024
vi.mock('../../../hooks/work-packages.hooks');
2125

@@ -35,7 +39,7 @@ vi.mock('../../../hooks/auth.hooks');
3539

3640
const mockedUseAuth = useAuth as jest.Mock<Auth>;
3741

38-
const mockAuthHook = (user = exampleAdminUser) => {
42+
const mockAuthHook = (user = exampleAuthenticatedAdminUser) => {
3943
mockedUseAuth.mockReturnValue(mockAuth(false, user));
4044
};
4145

@@ -105,7 +109,7 @@ describe('work package container', () => {
105109

106110
it('enables the edit button for non-guest user', () => {
107111
mockSingleWPHook(false, false, exampleResearchWorkPackage);
108-
mockAuthHook(exampleAdminUser);
112+
mockAuthHook(exampleAuthenticatedAdminUser);
109113
mockCurrentUserHook();
110114
mockGetBlockingWorkPackagesHook(false, false, [exampleDesignWorkPackage]);
111115
renderComponent();
@@ -116,7 +120,7 @@ describe('work package container', () => {
116120

117121
it('disables the edit button for guest user', () => {
118122
mockSingleWPHook(false, false, exampleResearchWorkPackage);
119-
mockAuthHook(exampleGuestUser);
123+
mockAuthHook(exampleAuthenticatedGuestUser);
120124
mockCurrentUserHook(exampleGuestUser);
121125
mockGetBlockingWorkPackagesHook(false, false, [exampleDesignWorkPackage]);
122126
renderComponent();

src/frontend/src/tests/test-support/test-data/test-utils.stub.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { AxiosHeaders, AxiosResponse } from 'axios';
77
import { UseMutationResult, UseQueryResult } from 'react-query';
8-
import { AuthenticatedUser, User } from 'shared';
8+
import { AuthenticatedUser } from 'shared';
99
import { exampleAuthenticatedAdminUser } from './authenticated-user.stub';
1010
import { Auth } from '../../../utils/types';
1111

0 commit comments

Comments
 (0)