Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/backend/api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public void ConfigureServices(IServiceCollection services)
"Ches",
sp => new ChesHealthCheck(sp.GetService<IEmailRepository>()),
null,
new string[] { SERVICES, EXTERNAL, SYSTEMCHECK })
new string[] { SERVICES, EXTERNAL })
{ Period = TimeSpan.FromMinutes(allHealthCheckOptions.Ches.Period) });
}

Expand Down Expand Up @@ -518,7 +518,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVers
config.MapControllers();
config.MapHealthChecks("health/system", new HealthCheckOptions()
{
Predicate = r => r.Tags.Contains("system-check"),
Predicate = r => r.Tags.Contains(SYSTEMCHECK),
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { act, render, RenderOptions, userEvent } from '@/utils/test-utils';

import HealthcheckView, { IHealthCheckIssue, IHealthCheckViewProps } from './HealthcheckView';
import { act, render, RenderOptions, userEvent, screen } from '@/utils/test-utils';

const mockHealthcheckIssues: IHealthCheckIssue[] = [
{
Expand Down Expand Up @@ -53,4 +54,41 @@ describe('Healthcheck View component', () => {
});
expect(getByTestId('healthcheck-full-list-lnk')).toBeVisible();
});

it(`shows modal with full list after clicking the link`, async () => {
const { getByTestId, getByText } = await setup({
props: {
systemDegraded: true,
systemChecks: [
...mockHealthcheckIssues,
{
key: 'Mayan',
msg: 'The PIMS Document server is experiencing service degradation, you will be unable to view, download or upload documents until resolved.',
},
],
},
});

const link = getByTestId('healthcheck-full-list-lnk');
expect(link).toBeVisible();
await act(() => userEvent.click(link));
expect(
getByText(/The PIMS Document server is experiencing service degradation/i),
).toBeVisible();
});

it('works as expected when system is degraded and issues array is empty', async () => {
const { getByLabelText, getByText } = await setup({
props: {
systemDegraded: true,
systemChecks: [],
},
});
expect(getByLabelText('System degraded icon')).toBeVisible();
expect(
getByText(
'The system is currently experiencing service degradation, you may experience issues using the application until this is resolved.',
),
).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { LinkButton } from '@/components/common/buttons/LinkButton';
import { ModalSize } from '@/components/common/GenericModal';
import { useModalContext } from '@/hooks/useModalContext';
import HealthCheckStyled from '@/layouts/Healthcheck';
import { firstOrNull } from '@/utils/utils';

export interface IHealthCheckIssue {
key: string;
Expand All @@ -23,17 +24,19 @@ const HealthcheckView: React.FunctionComponent<IHealthCheckViewProps> = ({
systemChecks,
}) => {
const { setModalContent, setDisplayModal } = useModalContext();
const firstIssue = firstOrNull(systemChecks);

return systemChecked && systemDegraded ? (
<HealthCheckStyled>
<StyledWrapperDiv>
<StyledIconDiv>
<StyledIconDiv aria-label="System degraded icon">
<FaBan size={24} />
</StyledIconDiv>
<StyledContainer>
<label>
<span>{systemChecks[0].key}: </span>
{systemChecks[0].msg}
<span>{firstIssue?.key ?? 'Unknown'}: </span>
{firstIssue?.msg ??
'The system is currently experiencing service degradation, you may experience issues using the application until this is resolved.'}
</label>
{systemChecks.length > 1 && (
<LinkButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ exports[`Healthcheck View component > renders as expected 1`] = `
class="c1"
>
<div
aria-label="System degraded icon"
class="c2"
>
<svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ export const AcquisitionContainer: React.FunctionComponent<IAcquisitionContainer
await fetchLastUpdatedBy();
mapMachine.refreshMapProperties();
setIsEditing(false);
if (isValidId(acquisitionFileId)) {
pathGenerator.showFile('acquisition', acquisitionFileId);
}
};

const canRemove = async () => {
Expand Down Expand Up @@ -308,6 +305,9 @@ export const AcquisitionContainer: React.FunctionComponent<IAcquisitionContainer
)
.then(response => {
onSuccess();
if (isValidId(response?.id)) {
pathGenerator.showFile('acquisition', response.id);
}
return response;
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ export const ResearchContainer: React.FunctionComponent<IResearchContainerProps>
userOverrideCodes,
).then(response => {
onSuccess();
if (isValidId(response?.id)) {
pathGenerator.showFile('research', response.id);
}
return response;
});
},
Expand Down
Loading