diff --git a/app/routes/basistest/CacheStatusTable.tsx b/app/routes/basistest/CacheStatusTable.tsx
index ec7dc7f..484f4ce 100644
--- a/app/routes/basistest/CacheStatusTable.tsx
+++ b/app/routes/basistest/CacheStatusTable.tsx
@@ -1,7 +1,7 @@
import React from 'react';
-import { BodyShort, Label, Table, Tooltip } from '@navikt/ds-react';
+import { BodyShort, Table, Tooltip } from '@navikt/ds-react';
import { CheckmarkCircleIcon, XMarkOctagonIcon } from '@navikt/aksel-icons';
-import { formatDate } from '~/utils/dateUtils';
+import { formatTimeOnly } from '~/utils/dateUtils';
import { IResourceResult } from '~/types/BasicTest';
interface TestResultsTableProps {
@@ -18,49 +18,46 @@ function CacheStatusTable({ logResults }: TestResultsTableProps) {
}
return (
- <>
-
-
-
-
- Status
- Ressurs
- Sist oppdatert
- Cache størrelse
- Melding
+
+
+
+ Status
+ Ressurs
+ Sist oppdatert
+ Cache størrelse
+ Melding
+
+
+
+ {logResults.map((result, index) => (
+
+
+
+ {result.status === 'OK' ? (
+
+ ) : (
+
+ )}
+
+
+ {result.resource}
+
+ {result.lastUpdated <= 0 ? '' : formatTimeOnly(result.lastUpdated)}
+
+ {result.size <= 0 ? '' : result.size}
+ {result.message || 'Ingen melding'}
-
-
- {logResults.map((result, index) => (
-
-
-
- {result.status === 'OK' ? (
-
- ) : (
-
- )}
-
-
- {result.resource}
-
- {result.lastUpdated <= 0 ? '' : formatDate(result.lastUpdated)}
-
- {result.size <= 0 ? '' : result.size}
- {result.message || 'Ingen melding'}
-
- ))}
-
-
- >
+ ))}
+
+
);
}
diff --git a/app/routes/basistest/HealthTestResultsTable.tsx b/app/routes/basistest/HealthTestResultsTable.tsx
index 8bc5be1..201326a 100644
--- a/app/routes/basistest/HealthTestResultsTable.tsx
+++ b/app/routes/basistest/HealthTestResultsTable.tsx
@@ -1,12 +1,20 @@
import React from 'react';
import { Table } from '@navikt/ds-react';
-import { formatDate } from '~/utils/dateUtils';
+import { formatTimeOnly } from '~/utils/dateUtils';
import { IHealthData } from '~/types/BasicTest';
interface TestResultsTableProps {
logResults: IHealthData[] | null;
}
+// Translation mapping
+const statusTranslations: { [key: string]: string } = {
+ SENT_FROM_CONSUMER_TO_PROVIDER: 'Sendt fra konsumer til provider',
+ RECEIVED_IN_PROVIDER_FROM_CONSUMER: 'Mottatt i provider fra konsumer',
+ APPLICATION_HEALTHY: 'Adapter er ok',
+ RECEIVED_IN_CONSUMER_FROM_PROVIDER: 'Mottatt i consumer fra provider',
+};
+
function HealthTestResultsTable({ logResults }: TestResultsTableProps) {
return (
@@ -20,9 +28,11 @@ function HealthTestResultsTable({ logResults }: TestResultsTableProps) {
{logResults?.map((result, index) => (
- {result.status}
+
+ {statusTranslations[result.status] || result.status}
+
{result.component}
- {formatDate(result.timestamp)}
+ {formatTimeOnly(result.timestamp)}
))}
diff --git a/app/routes/basistest/route.tsx b/app/routes/basistest/route.tsx
index 163bb08..4094db6 100644
--- a/app/routes/basistest/route.tsx
+++ b/app/routes/basistest/route.tsx
@@ -2,7 +2,7 @@ import type { ActionFunctionArgs, LoaderFunction, MetaFunction } from '@remix-ru
import Breadcrumbs from '~/components/shared/breadcrumbs';
import InternalPageHeader from '~/components/shared/InternalPageHeader';
import { TerminalIcon } from '@navikt/aksel-icons';
-import { Alert, Box, Loader, VStack } from '@navikt/ds-react';
+import { Alert, BodyShort, Box, Heading, Loader, VStack } from '@navikt/ds-react';
import { getSelectedOrganization } from '~/utils/selectedOrganization';
import ComponentApi from '~/api/ComponentApi';
import { useFetcher, useLoaderData } from '@remix-run/react';
@@ -15,6 +15,7 @@ import HealthTestResultsTable from '~/routes/basistest/HealthTestResultsTable';
import CacheStatusTable from '~/routes/basistest/CacheStatusTable';
import logger from '~/utils/logger';
import { IFetcherResponseData } from '~/types/FetcherResponseData';
+import React from 'react';
export const meta: MetaFunction = () => {
return [{ title: 'Basis Test' }, { name: 'description', content: 'Run Basis Test' }];
@@ -37,10 +38,15 @@ export const loader: LoaderFunction = async ({ request }) => {
);
};
+type ExtendedFetcherResponseData = IFetcherResponseData & {
+ clientName: string;
+ testUrl: string;
+};
+
export default function Index() {
const breadcrumbs = [{ name: 'Basistest', link: '/basistest' }];
const fetcher = useFetcher();
- const actionData = fetcher.data as IFetcherResponseData;
+ const actionData = fetcher.data as ExtendedFetcherResponseData;
const { components, clients } = useLoaderData<{
components: IComponent[];
@@ -60,10 +66,13 @@ export default function Index() {
-
- Advarsel: Passordet til klienten du kjører testen på, vil bli nullstilt under
- testkjøringen. Det anbefales derfor å bruke en dedikert klient for testing.
-
+ {fetcher.state !== 'submitting' && !actionData && (
+
+ Advarsel: Passordet til klienten du kjører testen på, vil bli nullstilt
+ under testkjøringen. Det anbefales derfor å bruke en dedikert klient for
+ testing.
+
+ )}
- {fetcher.state === 'submitting' && (
-
+
+
+ {fetcher.state === 'submitting' && (
-
- )}
- {fetcher.state !== 'submitting' && (
- <>
- {actionData && (
- <>
- {actionData.message && (
-
- {actionData.message}
-
- )}
-
- {actionData.data.healthData.healthData && (
-
+ )}
+
+ {fetcher.state !== 'submitting' && (
+ <>
+ {actionData && (
+ <>
+ {actionData.message && (
+
+
+
+ {actionData.message}: {actionData.testUrl}
+
+
+ Bruker: {actionData.clientName}
+
+
+
+ )}
+
+ Resultat av helsetest:
+ {actionData.data.healthData.healthData && (
-
- )}
-
- {actionData.data.cacheData.resourceResults && (
-
+ )}
+
+
+ Cache status:{' '}
+
+ {actionData.data.cacheData.resourceResults && (
-
- )}
- >
- )}
- >
- )}
+ )}
+ >
+ )}
+ >
+ )}
+
>
);
@@ -128,9 +134,13 @@ export async function action({ request }: ActionFunctionArgs) {
const endpoint = formData.get('endpoint') as string;
const clientName = formData.get('clientName') as string;
const orgName = await getSelectedOrganization(request);
- const message = 'Testet med: ' + baseUrl + endpoint + ' ' + clientName + ' ' + orgName;
- logger.debug(`BASIS TEST baseurl/endpoint clientName orgname: ${message}`);
+ const message = 'Testet av: ';
+
+ //Test av: https://beta.felleskomponent.no/utdanning/elev
+ // Bruker: basistest@client.fintlabs.no
+
+ logger.debug(`BASIS TEST baseurl/endpoint clientName orgname: ${baseUrl}`);
const cacheData = await BasicTestApi.runTest(orgName, baseUrl, endpoint, clientName);
const healthData = await BasicTestApi.runHealthTest(orgName, baseUrl, endpoint, clientName);
@@ -139,6 +149,8 @@ export async function action({ request }: ActionFunctionArgs) {
return {
message: message,
+ clientName: clientName,
+ testUrl: baseUrl + endpoint,
variant: 'info',
data: {
healthData: healthData.data || [],
diff --git a/app/utils/dateUtils.tsx b/app/utils/dateUtils.tsx
index 4489bda..916efae 100644
--- a/app/utils/dateUtils.tsx
+++ b/app/utils/dateUtils.tsx
@@ -20,3 +20,9 @@ export const formatDate = (timestamp: number): string => {
const time = date.toLocaleTimeString('no-NO');
return `${d}.${m}.${y} ${time}`;
};
+
+export const formatTimeOnly = (timestamp: number): string => {
+ const date = new Date(timestamp);
+ const time = date.toLocaleTimeString('no-NO');
+ return `${time}`;
+};