diff --git a/frontend/app-development/App.test.tsx b/frontend/app-development/App.test.tsx index 13d2a82a8d4..980f0775245 100644 --- a/frontend/app-development/App.test.tsx +++ b/frontend/app-development/App.test.tsx @@ -11,6 +11,8 @@ import { queriesMock } from 'app-shared/mocks/queriesMock'; jest.mock('../language/src/nb.json', jest.fn()); jest.mock('../language/src/en.json', jest.fn()); +// Mocking console.error due to Tanstack Query removing custom logger between V4 and v5 see issue: #11692 +const realConsole = console; const render = async (remainingMinutes: number = 40) => { renderWithProviders(, { startUrl: `${APP_DEVELOPMENT_BASENAME}/my-org/my-app`, @@ -25,7 +27,16 @@ const render = async (remainingMinutes: number = 40) => { }); }; describe('App', () => { - afterEach(() => jest.clearAllMocks()); + beforeEach(() => { + global.console = { + ...console, + error: jest.fn(), + }; + }); + afterEach(() => { + global.console = realConsole; + jest.clearAllMocks(); + }); it('should present popover with options to log out or stay logged in when session about to expire ', async () => { render(6); diff --git a/frontend/app-development/features/administration/components/Administration.test.tsx b/frontend/app-development/features/administration/components/Administration.test.tsx index 779fcab3442..6bb5d15b306 100644 --- a/frontend/app-development/features/administration/components/Administration.test.tsx +++ b/frontend/app-development/features/administration/components/Administration.test.tsx @@ -11,7 +11,20 @@ const org = 'org'; const app = 'app'; const title = 'test'; +// Mocking console.error due to Tanstack Query removing custom logger between V4 and v5 see issue: #11692 +const realConsole = console; + describe('Administration', () => { + beforeEach(() => { + global.console = { + ...console, + error: jest.fn(), + }; + }); + afterEach(() => { + global.console = realConsole; + jest.clearAllMocks(); + }); it('renders component', async () => { render({ getEnvironments: jest.fn().mockImplementation(() => Promise.resolve([])), @@ -34,8 +47,8 @@ describe('Administration', () => { it('should display error message if fetching goes wrong', async () => { render({ - getOrgList: jest.fn().mockImplementation(() => Promise.reject()), - getAppConfig: jest.fn().mockImplementation(() => Promise.reject()), + getAppConfig: () => Promise.reject(), + getOrgList: () => Promise.reject(), }); expect(await screen.findByText(textMock('administration.fetch_title_error_message'))); }); diff --git a/frontend/app-development/features/administration/components/Administration.tsx b/frontend/app-development/features/administration/components/Administration.tsx index a1d2be2c366..cf2e9cced45 100644 --- a/frontend/app-development/features/administration/components/Administration.tsx +++ b/frontend/app-development/features/administration/components/Administration.tsx @@ -17,18 +17,18 @@ import { PageContainer } from 'app-shared/components/PageContainer/PageContainer export const Administration = () => { const { org, app } = useStudioUrlParams(); const { - data: orgs = { orgs: {} }, - isLoading: isLoadingOrgs, + data: orgs, + isPending: isPendingOrgs, isError: isOrgsError, } = useOrgListQuery({ hideDefaultError: true }); - const selectedOrg = orgs.orgs[org]; + const selectedOrg = orgs?.orgs[org]; const hasEnvironments = selectedOrg?.environments?.length > 0; const { data: appConfigData, isError: isAppConfigError, - isLoading: isLoadingAppConfig, + isPending: isPendingAppConfig, } = useAppConfigQuery(org, app, { hideDefaultError: true }); const { t } = useTranslation(); @@ -36,7 +36,7 @@ export const Administration = () => { toast.error(t('administration.fetch_title_error_message')); } - if (isLoadingAppConfig || isLoadingOrgs) { + if (isPendingAppConfig || isPendingOrgs) { return (
diff --git a/frontend/app-development/features/administration/components/AppEnvironments.tsx b/frontend/app-development/features/administration/components/AppEnvironments.tsx index cb8487c6345..c5a63871399 100644 --- a/frontend/app-development/features/administration/components/AppEnvironments.tsx +++ b/frontend/app-development/features/administration/components/AppEnvironments.tsx @@ -16,16 +16,16 @@ export const AppEnvironments = () => { const { data: environmentList = [], - isLoading: envIsLoading, + isPending: envIsPending, isError: envIsError, } = useEnvironmentsQuery({ hideDefaultError: true }); const { data: orgs = { orgs: {} }, - isLoading: orgsIsLoading, + isPending: orgsIsPending, isError: orgsIsError, } = useOrgListQuery({ hideDefaultError: true }); - if (envIsLoading || orgsIsLoading) return ; + if (envIsPending || orgsIsPending) return ; if (envIsError || orgsIsError) return {t('administration.app_environments_error')}; diff --git a/frontend/app-development/features/administration/components/AppLogs.tsx b/frontend/app-development/features/administration/components/AppLogs.tsx index 317aa139cd8..917b7f5edc3 100644 --- a/frontend/app-development/features/administration/components/AppLogs.tsx +++ b/frontend/app-development/features/administration/components/AppLogs.tsx @@ -16,17 +16,17 @@ export const AppLogs = () => { const { data: appDeployments = [], - isLoading: isLoadingDeploys, + isPending: isPendingDeploys, isError: deploysHasError, } = useAppDeploymentsQuery(org, app, { hideDefaultError: true }); const { data: environmentList = [], - isLoading: envIsLoading, + isPending: envIsPending, isError: envIsError, } = useEnvironmentsQuery({ hideDefaultError: true }); - if (isLoadingDeploys || envIsLoading) return ; + if (isPendingDeploys || envIsPending) return ; if (deploysHasError || envIsError) return {t('administration.app_logs_error')}; diff --git a/frontend/app-development/features/administration/components/AppStatus.tsx b/frontend/app-development/features/administration/components/AppStatus.tsx index 03f7aea40a8..585c54a53a6 100644 --- a/frontend/app-development/features/administration/components/AppStatus.tsx +++ b/frontend/app-development/features/administration/components/AppStatus.tsx @@ -22,7 +22,7 @@ export const AppStatus = ({ envName, envType }: AppStatusProps) => { const { data: appDeployments = [], - isLoading: deploysAreLoading, + isPending: isPendingDeploys, isError: deploysAreError, } = useAppDeploymentsQuery(org, app, { hideDefaultError: true }); @@ -63,7 +63,7 @@ export const AppStatus = ({ envName, envType }: AppStatusProps) => { }); }; - if (deploysAreLoading) return ; + if (isPendingDeploys) return ; if (deploysAreError) return ( diff --git a/frontend/app-development/features/administration/components/News.tsx b/frontend/app-development/features/administration/components/News.tsx index bcfe62ff890..fde48ba2d82 100644 --- a/frontend/app-development/features/administration/components/News.tsx +++ b/frontend/app-development/features/administration/components/News.tsx @@ -6,10 +6,10 @@ import { useTranslation } from 'react-i18next'; import classes from './News.module.css'; export const News = () => { - const { data: newsList, isLoading, isError } = useNewsListQuery(); + const { data: newsList, isPending, isError } = useNewsListQuery(); const { t } = useTranslation(); - if (isLoading) { + if (isPending) { return ( diff --git a/frontend/app-development/features/administration/components/ResetRepoModal.tsx b/frontend/app-development/features/administration/components/ResetRepoModal.tsx index 26c0aafd7d3..d5ca2e19803 100644 --- a/frontend/app-development/features/administration/components/ResetRepoModal.tsx +++ b/frontend/app-development/features/administration/components/ResetRepoModal.tsx @@ -90,8 +90,8 @@ export function ResetRepoModal(props: IResetRepoModalProps) { autoFocus onKeyUp={handleOnKeypressEnter} /> - {repoResetMutation.isLoading && } - {!repoResetMutation.isLoading && ( + {repoResetMutation.isPending && } + {!repoResetMutation.isPending && (