Skip to content

Commit

Permalink
Mijn-9741-Chore refactor some filestructure (#1615)
Browse files Browse the repository at this point in the history
* Move test-utils to separate folder

* Move file to testing

* Rename file

* Rename file

* Move testing hook

* Rename file

* Rename folder

* Change setup, disable lint for this file

* Change path
  • Loading branch information
timvanoostrom authored Nov 21, 2024
1 parent 848d6aa commit 8556c89
Show file tree
Hide file tree
Showing 85 changed files with 97 additions and 99 deletions.
2 changes: 1 addition & 1 deletion src/client/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render, waitFor } from '@testing-library/react';
import { vi, describe, it, expect } from 'vitest';

import App from './App';
import { bffApi } from '../test-utils';
import { bffApi } from '../testing/utils';

const mocks = vi.hoisted(() => {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/client/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import ZaakStatus from './pages/ZaakStatus/ZaakStatus';
import ZorgThemaPagina from './pages/Zorg/Zorg';
import ZorgVoorzieningen from './pages/Zorg/ZorgRegelingen';
import ZorgDetail from './pages/ZorgDetail/ZorgDetail';
import { useMonitoring } from './utils/monitoring';
import { useMonitoring } from './helpers/monitoring';

function AppNotAuthenticated() {
useSetDeeplinkEntry(['sso', 'authMethod']);
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/DocumentList/DocumentLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { IconAlert, IconDownload } from '../../assets/icons';
import { trackDownload } from '../../hooks/analytics.hook';
import { useProfileTypeValue } from '../../hooks/useProfileType';
import { useUserCity } from '../../hooks/useUserCity';
import { captureException } from '../../utils/monitoring';
import { captureException } from '../../helpers/monitoring';
import { MaLink } from '../MaLink/MaLink';
import { Spinner } from '../Spinner/Spinner';

Expand Down
2 changes: 1 addition & 1 deletion src/client/components/DocumentList/DocumentList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import DocumentList from './DocumentList';
import { GenericDocument } from '../../../universal/types/App.types';
import * as analytics from '../../hooks/analytics.hook';
import { trackDownload } from '../../hooks/analytics.hook';
import * as Monitoring from '../../utils/monitoring';
import * as Monitoring from '../../helpers/monitoring';

vi.mock('../../hooks/analytics.hook');

Expand Down
2 changes: 1 addition & 1 deletion src/client/components/DocumentList/DocumentListV2.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import DocumentListV2 from './DocumentListV2';
import { GenericDocument } from '../../../universal/types/App.types';
import * as analytics from '../../hooks/analytics.hook';
import { trackDownload } from '../../hooks/analytics.hook';
import * as Monitoring from '../../utils/monitoring';
import * as Monitoring from '../../helpers/monitoring';

vi.mock('../../hooks/analytics.hook');

Expand Down
2 changes: 1 addition & 1 deletion src/client/components/MainFooter/MainFooter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { describe, expect, it, vi } from 'vitest';

import footer from './amsterdam-nl-footer-data.json';
import MainFooter from './MainFooter';
import { bffApi } from '../../../test-utils';
import { bffApi } from '../../../testing/utils';
import { AppRoutes } from '../../../universal/config/routes';
import { appStateAtom } from '../../hooks/useAppState';
import MockApp from '../../pages/MockApp';
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/MyArea/MyArea.hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, expect, it, test, vi } from 'vitest';

import { useMapLocations, useSetMapCenterAtLocation } from './MyArea.hooks';
import { appStateAtom } from '../../hooks/useAppState';
import { renderRecoilHook } from '../../utils/renderRecoilHook';
import { renderRecoilHook } from '../../../testing/render-recoil.hook';

const mapInstanceMock = {
setView: vi.fn(),
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/MyArea/MyArea.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { getFullAddress } from '../../../universal/helpers/brp';
import { BFFApiUrls } from '../../config/api';
import { DEFAULT_MAP_OPTIONS } from '../../config/map';
import { useAppStateGetter, useAppStateReady } from '../../hooks/useAppState';
import { captureMessage } from '../../utils/monitoring';
import { captureMessage } from '../../helpers/monitoring';

const NO_DATA_ERROR_RESPONSE = {
errors: [
Expand Down
4 changes: 2 additions & 2 deletions src/client/components/MyNotifications/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { ThemaTitles } from '../../config/thema';
import { trackItemClick } from '../../hooks/analytics.hook';
import { useContentDimensions } from '../../hooks/useContentDimensions';
import { useProfileTypeValue } from '../../hooks/useProfileType';
import { trackEvent } from '../../utils/monitoring';
import { isInteralUrl } from '../../utils/utils';
import { trackEvent } from '../../helpers/monitoring';
import { isInteralUrl } from '../../helpers/utils';
import Linkd from '../Button/Button';
import { DocumentLink } from '../DocumentList/DocumentLink';
import ThemaIcon from '../ThemaIcon/ThemaIcon';
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/Search/Search.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { afterEach, beforeEach, describe, expect, test } from 'vitest';
import * as bagResponse from './bag-response.json';
import { Search } from './Search';
import * as remoteConfig from './search-config.json';
import { bffApi, remoteApi } from '../../../test-utils';
import { bffApi, remoteApi } from '../../../testing/utils';
import { appStateAtom } from '../../hooks/useAppState';

describe('<Search />', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/Search/useSearch.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
useSearchIndex,
} from './useSearch';
import type { Vergunning } from '../../../server/services';
import { bffApi } from '../../../test-utils';
import { bffApi } from '../../../testing/utils';
import { AppRoutes } from '../../../universal/config/routes';
import { AppState } from '../../../universal/types/App.types';
import { appStateAtom } from '../../hooks/useAppState';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ComponentChildren } from '../../../universal/types';
import { IconChevronRight } from '../../assets/icons';
import { useSessionStorage } from '../../hooks/storage.hook';
import { useContentDimensions } from '../../hooks/useContentDimensions';
import { withKeyPress } from '../../utils/utils';
import { withKeyPress } from '../../helpers/utils';
import LoadingContent from '../LoadingContent/LoadingContent';

export interface SectionCollapsibleProps {
Expand Down
2 changes: 1 addition & 1 deletion src/client/data-transform/appState.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppState } from '../../universal/types/App.types';
import { PRISTINE_APPSTATE, createAllErrorState } from '../AppState';
import { transformSourceData } from './appState';
import * as Monitoring from '../utils/monitoring';
import * as Monitoring from '../helpers/monitoring';

describe('transformSourceData', () => {
test('transformSourceData', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/data-transform/appState.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppState } from '../../universal/types/App.types';
import { createAllErrorState, PRISTINE_APPSTATE } from '../AppState';
import { captureMessage } from '../utils/monitoring';
import { captureMessage } from '../helpers/monitoring';

export function transformSourceData(data: Partial<AppState> | null) {
// Copy the pristine content to the error content so we keep our
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ThemaMenuItem } from './thema';
import { FeatureToggle } from '../../universal/config/feature-toggles';
import { Themas } from '../../universal/config/thema';
import { isLoading } from '../../universal/helpers/api';
import { isMokum } from '../../universal/helpers/brp';
import { AppState, AppStateKey } from '../../universal/types/App.types';
import { DecosCaseType } from '../../universal/types/vergunningen';
import { ThemaMenuItem } from '../config/thema';
import { PARKEER_CASE_TYPES } from '../pages/Parkeren/useParkerenData.hook';

export function isThemaActive(item: ThemaMenuItem, appState: AppState) {
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/client/hooks/api/useDataApi.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { act, renderHook, waitFor } from '@testing-library/react';
import { describe, expect, it } from 'vitest';

import { getDefaultState, useDataApi } from './useDataApi';
import { bffApiHost } from '../../../setupTests';
import { bffApi } from '../../../test-utils';
import { bffApiHost } from '../../../testing/setup';
import { bffApi } from '../../../testing/utils';

interface ResponseData {
foo: string;
Expand Down
2 changes: 1 addition & 1 deletion src/client/hooks/api/useDataApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import axios, { AxiosRequestConfig, AxiosResponseTransformer } from 'axios';

import { apiErrorResult } from '../../../universal/helpers/api';
import { Action } from '../../../universal/types';
import { captureException } from '../../utils/monitoring';
import { captureException } from '../../helpers/monitoring';

export interface ApiRequestOptions extends AxiosRequestConfig {
postpone?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/client/hooks/storage.hook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useState } from 'react';

import { Unshaped } from '../../universal/types';
import { captureException } from '../utils/monitoring';
import { captureException } from '../helpers/monitoring';

interface LocalStorageHandler {
value: string | null;
Expand Down
4 changes: 2 additions & 2 deletions src/client/hooks/useAppState.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import {
apiSuccessResult,
} from '../../universal/helpers/api';
import * as appStateModule from '../AppState';
import * as Monitoring from '../utils/monitoring';
import { renderRecoilHook } from '../utils/renderRecoilHook';
import * as Monitoring from '../helpers/monitoring';
import { renderRecoilHook } from '../../testing/render-recoil.hook';

vi.mock('./api/useTipsApi');
vi.mock('./useProfileType');
Expand Down
2 changes: 1 addition & 1 deletion src/client/hooks/useAppState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { PRISTINE_APPSTATE, createAllErrorState } from '../AppState';
import { BFFApiUrls } from '../config/api';
import { transformSourceData } from '../data-transform/appState';
import { captureMessage } from '../utils/monitoring';
import { captureMessage } from '../helpers/monitoring';
import { useDataApi } from './api/useDataApi';
import { useProfileTypeValue } from './useProfileType';
import { SSE_ERROR_MESSAGE, useSSE } from './useSSE';
Expand Down
2 changes: 1 addition & 1 deletion src/client/hooks/usePageChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
NOT_FOUND_TITLE,
PageTitleMain,
} from '../config/thema';
import { captureMessage } from '../utils/monitoring';
import { captureMessage } from '../helpers/monitoring';

const sortedPageTitleRoutes = Object.keys(DocumentTitles).sort((a, b) => {
if (a.length === b.length) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/hooks/useThemaMenuItems.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Themas } from '../../universal/config/thema';
import { ThemaMenuItem, ThemaTitles } from '../config/thema';
import { getThemaMenuItemsAppState, isThemaActive } from '../config/themas';
import { getThemaMenuItemsAppState, isThemaActive } from '../helpers/themas';

describe('useThemaMenuItems', () => {
test('Parkeren is not active without an Appstate entry.', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/hooks/useThemaMenuItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useProfileTypeValue } from './useProfileType';
import { ApiResponse, isError, isLoading } from '../../universal/helpers/api';
import { themasByProfileType } from '../config/menuItems';
import { ThemaMenuItem } from '../config/thema';
import { getThemaMenuItemsAppState, isThemaActive } from '../config/themas';
import { getThemaMenuItemsAppState, isThemaActive } from '../helpers/themas';

export interface ThemasState {
items: ThemaMenuItem[];
Expand Down
4 changes: 2 additions & 2 deletions src/client/hooks/useTrackThemas.hook.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { MutableSnapshot, RecoilRoot } from 'recoil';
import { appStateAtom } from './useAppState';
import { useTrackThemas } from './useTrackThemas.hook';
import { AppState } from '../../universal/types';
import { trackEvent } from '../utils/monitoring';
import { trackEvent } from '../helpers/monitoring';

vi.mock('../utils/monitoring', () => ({
vi.mock('../helpers/monitoring', () => ({
trackEvent: vi.fn(),
}));

Expand Down
2 changes: 1 addition & 1 deletion src/client/hooks/useTrackThemas.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect } from 'react';
import { useSessionStorage } from './storage.hook';
import { useAppStateGetter } from './useAppState';
import { useThemaMenuItems } from './useThemaMenuItems';
import { trackEvent } from '../utils/monitoring';
import { trackEvent } from '../helpers/monitoring';

type ThemaTitleAndId = Record<'title' | 'id', string>;

Expand Down
2 changes: 1 addition & 1 deletion src/client/hooks/useUsabilla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect } from 'react';
import { usePhoneScreen } from './media.hook';
import { useScript } from './useScript';
import { IS_AP } from '../../universal/config/env';
import { captureException } from '../utils/monitoring';
import { captureException } from '../helpers/monitoring';

const MAX_WAIT_FOR_USABILA_LIVE_MS = 5000; // 5 seconds
const USABILLA_ID_MOBILE = '9fd5da44aa5b';
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/Afis/Afis.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
AfisBusinessPartnerDetailsTransformed,
AfisFacturenByStateResponse,
} from '../../../server/services/afis/afis-types';
import { bffApi } from '../../../test-utils';
import { bffApi } from '../../../testing/utils';
import { AppRoutes } from '../../../universal/config/routes';
import { AppState } from '../../../universal/types';
import { appStateAtom } from '../../hooks/useAppState';
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/Afis/AfisBetaalVoorkeuren.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { generatePath } from 'react-router-dom';
import { MutableSnapshot } from 'recoil';

import { AfisBusinessPartnerDetailsTransformed } from '../../../server/services/afis/afis-types';
import { bffApi } from '../../../test-utils';
import { bffApi } from '../../../testing/utils';
import { AppRoutes } from '../../../universal/config/routes';
import { AppState } from '../../../universal/types';
import { appStateAtom } from '../../hooks/useAppState';
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/Afis/AfisFacturen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render, waitFor } from '@testing-library/react';
import { generatePath } from 'react-router-dom';
import { MutableSnapshot } from 'recoil';

import { bffApi } from '../../../test-utils';
import { bffApi } from '../../../testing/utils';
import { AppRoutes } from '../../../universal/config/routes';
import { AppState } from '../../../universal/types';
import { appStateAtom } from '../../hooks/useAppState';
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/Dashboard/Dashboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AppState } from '../../../universal/types/App.types';
import { appStateAtom } from '../../hooks/useAppState';
import MockApp from '../MockApp';
import Dashboard from './Dashboard';
import { remoteApiHost } from '../../../setupTests';
import { remoteApiHost } from '../../../testing/setup';

const testState: any = {
BRP: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
transformDossierResponse,
transformErfpachtDossierProperties,
} from '../../../../server/services/simple-connect/erfpacht';
import { bffApi } from '../../../../test-utils';
import { bffApi } from '../../../../testing/utils';
import { AppRoutes } from '../../../../universal/config/routes';
import { jsonCopy } from '../../../../universal/helpers/utils';
import { AppState } from '../../../../universal/types/App.types';
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/Erfpacht/ErfpachtFacturen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
transformDossierResponse,
transformErfpachtDossierProperties,
} from '../../../server/services/simple-connect/erfpacht';
import { bffApi } from '../../../test-utils';
import { bffApi } from '../../../testing/utils';
import { AppRoutes } from '../../../universal/config/routes';
import { AppState } from '../../../universal/types/App.types';
import { appStateAtom } from '../../hooks/useAppState';
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/Landing/Landing.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RecoilRoot } from 'recoil';
import { describe, expect, it } from 'vitest';

import Landing from './Landing';
import { bffApi } from '../../../test-utils';
import { bffApi } from '../../../testing/utils';
import { SessionState, sessionAtom } from '../../hooks/api/useSessionApi';

const appState = { isAuthenticated: false } as SessionState;
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/NotFound/NotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

import { PageContent, PageHeading, TextPage } from '../../components';
import { captureMessage } from '../../utils/monitoring';
import { captureMessage } from '../../helpers/monitoring';

export default function NotFound() {
const location = useLocation();
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/Search/Search.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MutableSnapshot } from 'recoil';
import { beforeAll, describe, it } from 'vitest';

import Search from './Search';
import { bffApi } from '../../../test-utils';
import { bffApi } from '../../../testing/utils';
import { AppRoutes } from '../../../universal/config/routes';
import { appStateAtom } from '../../hooks/useAppState';
import MockApp from '../../pages/MockApp';
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/StatusDetail/StatusDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import { LinkdInline } from '../../components/Button/Button';
import { ThemaTitles } from '../../config/thema';
import { useAppStateGetter } from '../../hooks/useAppState';
import { captureMessage } from '../../utils/monitoring';
import { captureMessage } from '../../helpers/monitoring';

export type StatusSourceItem = StatusLine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MutableSnapshot } from 'recoil';
import { describe, expect } from 'vitest';

import { BBVergunning } from '../../../server/services/toeristische-verhuur/toeristische-verhuur-powerbrowser-bb-vergunning-types';
import { bffApi } from '../../../test-utils';
import { bffApi } from '../../../testing/utils';
import { AppRoutes } from '../../../universal/config/routes';
import { appStateAtom } from '../../hooks/useAppState';
import MockApp from '../MockApp';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { AppRoutes } from '../../../universal/config/routes';
import { appStateAtom } from '../../hooks/useAppState';
import MockApp from '../MockApp';
import VergunningDetail from './VergunningDetail';
import { bffApi } from '../../../test-utils';
import { bffApi } from '../../../testing/utils';

const content = transformVergunningenData(vergunningenData as any);

Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createRoot } from 'react-dom/client';
import App from './client/App';
import ApplicationError from './client/pages/ApplicationError/ApplicationError';
import './client/styles/main.scss';
import { reactPlugin } from './client/utils/monitoring';
import { reactPlugin } from './client/helpers/monitoring';

if (
/MSIE (\d+\.\d+);/.test(navigator.userAgent) ||
Expand Down
2 changes: 1 addition & 1 deletion src/server/auth/auth-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
getReqMockWithOidc,
RequestMock,
ResponseMock,
} from '../../test-utils';
} from '../../testing/utils';
import * as blacklist from '../services/session-blacklist';

describe('auth-helpers', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/server/helpers/source-api-request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
getRequestConfigCacheKey,
requestData,
} from './source-api-request';
import { remoteApiHost } from '../../setupTests';
import { remoteApi } from '../../test-utils';
import { remoteApiHost } from '../../testing/setup';
import { remoteApi } from '../../testing/utils';
import {
apiErrorResult,
apiPostponeResult,
Expand Down
2 changes: 1 addition & 1 deletion src/server/routing/route-handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getReqMockWithOidc,
RequestMock,
ResponseMock,
} from '../../test-utils';
} from '../../testing/utils';
import { OIDC_SESSION_COOKIE_NAME } from '../auth/auth-config';
import { cache } from '../helpers/source-api-request';
import { addToBlackList } from '../services/session-blacklist';
Expand Down
Loading

0 comments on commit 8556c89

Please sign in to comment.