Skip to content

Commit

Permalink
Prmp 1182 - Remove number of files line from available records page (#…
Browse files Browse the repository at this point in the history
…485)

* removes number of files and size of files from within record card

* adds number of files downloading back

* fixes tests

* remove unnessecary import

* remove unnessecary import

* remove unnessecary import

* remove unnessecary import

---------

Co-authored-by: Jack Sutton <[email protected]>
Co-authored-by: steph-torres-nhs <[email protected]>
  • Loading branch information
3 people authored Dec 20, 2024
1 parent 735f574 commit 6b29964
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ describe('GP Workflow: View Lloyd George record', () => {
// Assert contents of page when downloading
cy.getByTestId('lloyd-george-download-header').should('exist');
cy.getByTestId('cancel-download-link').should('exist');
cy.getByTestId('download-file-header-' + testFiles.length + '-files').should(
'exist',
);

// Assert contents of page after download
cy.wait('@documentManifestCompleted');
Expand Down Expand Up @@ -225,7 +222,6 @@ describe('GP Workflow: View Lloyd George record', () => {
cy.title().should('eq', downloadingPageTitle);
// Assert contents of page when downloading
cy.getByTestId('lloyd-george-download-header').should('exist');
cy.getByTestId('download-file-header-2-files').should('exist');

cy.getByTestId('cancel-download-link').should('exist');

Expand Down Expand Up @@ -289,8 +285,6 @@ describe('GP Workflow: View Lloyd George record', () => {
cy.title().should('eq', downloadingPageTitle);
// Assert contents of page when downloading
cy.getByTestId('lloyd-george-download-header').should('exist');
cy.getByTestId('download-file-header-1-files').should('exist');

cy.getByTestId('cancel-download-link').should('exist');

// Assert contents of page after download
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ describe('GP Workflow: View Lloyd George record', () => {
assertPatientInfo();
cy.getByTestId('pdf-card')
.should('include.text', 'Lloyd George record')
.should('include.text', 'Last updated: 09 October 2023 at 15:41:38')
.should('include.text', '12 files | File size: 502 KB | File format: PDF');
.should('include.text', 'Last updated: 09 October 2023 at 15:41:38');
cy.getByTestId('pdf-viewer').should('be.visible');

// Act - open full screen view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ describe('LloydGeorgeDownloadStage', () => {

const renderComponent = (history: MemoryHistory, propsOverride?: Partial<Props>) => {
const props: Omit<Props, 'setStage' | 'setDownloadStage'> = {
numberOfFiles: mockPdf.numberOfFiles,
deleteAfterDownload: false,
...propsOverride,
numberOfFiles: mockPdf.numberOfFiles,
};

return render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ function LloydGeorgeDownloadStage({
filename: '',
});
const linkRef = useRef<HTMLAnchorElement | null>(null);

const pageDownloadCountId = 'download-file-header-' + numberOfFiles + '-files';
const mounted = useRef(false);
const navigate = useNavigate();
const { mockLocal } = useConfig();
const patientDetails = usePatient();
const nhsNumber = patientDetails?.nhsNumber ?? '';
const [delayTimer, setDelayTimer] = useState<NodeJS.Timeout>();

const pageDownloadCountId = 'download-file-header-' + numberOfFiles + '-files';

const progressTimer = useMemo(() => {
return new FakeProgress({
timeConstant: timeToComplete,
Expand Down Expand Up @@ -145,7 +143,6 @@ function LloydGeorgeDownloadStage({
navigate,
mockLocal,
selectedDocuments,
numberOfFiles,
]);

const pageHeader = 'Downloading documents';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { render, screen } from '@testing-library/react';
import LgRecordDetails, { Props } from './LloydGeorgeRecordDetails';
import { buildLgSearchResult } from '../../../../helpers/test/testBuilders';
import formatFileSize from '../../../../helpers/utils/formatFileSize';

const mockPdf = buildLgSearchResult();

Expand All @@ -19,20 +18,13 @@ describe('LloydGeorgeRecordDetails', () => {
renderComponent();

expect(screen.getByText(`Last updated: ${mockPdf.lastUpdated}`)).toBeInTheDocument();
expect(screen.getByText(`${mockPdf.numberOfFiles} files`)).toBeInTheDocument();
expect(
screen.getByText(`File size: ${formatFileSize(mockPdf.totalFileSizeInBytes)}`),
).toBeInTheDocument();
expect(screen.getByText('File format: PDF')).toBeInTheDocument();
});
});
});

const renderComponent = (propsOverride?: Partial<Props>) => {
const props: Props = {
lastUpdated: mockPdf.lastUpdated,
numberOfFiles: mockPdf.numberOfFiles,
totalFileSizeInBytes: mockPdf.totalFileSizeInBytes,
...propsOverride,
};
return render(<LgRecordDetails {...props} />);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import React from 'react';
import formatFileSize from '../../../../helpers/utils/formatFileSize';

export type Props = {
lastUpdated: string;
numberOfFiles: number;
totalFileSizeInBytes: number;
};

function LloydGeorgeRecordDetails({ lastUpdated, numberOfFiles, totalFileSizeInBytes }: Props) {
function LloydGeorgeRecordDetails({ lastUpdated }: Props) {
return (
<div className="lloydgeorge_record-details">
<div className="lloydgeorge_record-details_details">
<div className="lloydgeorge_record-details_details--last-updated">
Last updated: {lastUpdated}
</div>
<div className="lloydgeorge_record-details_details--num-files">
<span>{numberOfFiles} files</span>
{' | '}
<span>File size: {formatFileSize(totalFileSizeInBytes)}</span>
{' | '}
<span>File format: PDF</span>
{' |'}
</div>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import useRole from '../../../../helpers/hooks/useRole';
import useIsBSOL from '../../../../helpers/hooks/useIsBSOL';
import useConfig from '../../../../helpers/hooks/useConfig';
import { act, render, screen, waitFor } from '@testing-library/react';
import formatFileSize from '../../../../helpers/utils/formatFileSize';
import { DOWNLOAD_STAGE } from '../../../../types/generic/downloadStage';
import { getFormattedDate } from '../../../../helpers/utils/formatDate';
import userEvent from '@testing-library/user-event';
Expand Down Expand Up @@ -62,11 +61,6 @@ describe('LloydGeorgeViewRecordStage', () => {
expect(screen.getByText('View in full screen')).toBeInTheDocument();
expect(screen.getByText('Lloyd George record')).toBeInTheDocument();
expect(screen.getByText(`Last updated: ${mockPdf.lastUpdated}`)).toBeInTheDocument();
expect(screen.getByText(`${mockPdf.numberOfFiles} files`)).toBeInTheDocument();
expect(
screen.getByText(`File size: ${formatFileSize(mockPdf.totalFileSizeInBytes)}`),
).toBeInTheDocument();
expect(screen.getByText('File format: PDF')).toBeInTheDocument();

expect(
screen.queryByText('No documents are available for this patient.'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ function LloydGeorgeViewRecordStage({
const recordDetailsProps: RecordDetailsProps = {
downloadStage,
lastUpdated,
numberOfFiles,
totalFileSizeInBytes,
};

const pageHeader = 'Available records';
Expand Down Expand Up @@ -258,17 +256,9 @@ function LloydGeorgeViewRecordStage({
);
}

type RecordDetailsProps = Pick<
Props,
'downloadStage' | 'lastUpdated' | 'numberOfFiles' | 'totalFileSizeInBytes'
>;
type RecordDetailsProps = Pick<Props, 'downloadStage' | 'lastUpdated'>;

const RecordDetails = ({
downloadStage,
lastUpdated,
numberOfFiles,
totalFileSizeInBytes,
}: RecordDetailsProps) => {
const RecordDetails = ({ downloadStage, lastUpdated }: RecordDetailsProps) => {
switch (downloadStage) {
case DOWNLOAD_STAGE.INITIAL:
case DOWNLOAD_STAGE.PENDING:
Expand All @@ -277,8 +267,6 @@ const RecordDetails = ({
case DOWNLOAD_STAGE.SUCCEEDED: {
const detailsProps = {
lastUpdated,
numberOfFiles,
totalFileSizeInBytes,
};
return <LloydGeorgeRecordDetails {...detailsProps} />;
}
Expand Down
21 changes: 0 additions & 21 deletions app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from '../../helpers/test/testBuilders';
import { getFormattedDate } from '../../helpers/utils/formatDate';
import axios from 'axios';
import formatFileSize from '../../helpers/utils/formatFileSize';
import usePatient from '../../helpers/hooks/usePatient';
import useConfig from '../../helpers/hooks/useConfig';
import useRole from '../../helpers/hooks/useRole';
Expand Down Expand Up @@ -99,20 +98,6 @@ describe('LloydGeorgeRecordPage', () => {
});
});

it('calls refreshRecord and updates state when successful', async () => {
const lgResult = buildLgSearchResult();
mockAxios.post.mockResolvedValue({ data: { jobStatus: 'Complete' } });
mockAxios.get.mockResolvedValue({ data: lgResult });

renderPage(history);

await waitFor(async () => {
expect(screen.getByText(`${lgResult.numberOfFiles} files`)).toBeInTheDocument();
});

expect(screen.getByText('File format: PDF')).toBeInTheDocument();
});

it('renders initial lg record view with no docs available text if lambda return records status is uploading for more than 3 min', async () => {
const errorResponse = {
response: {
Expand Down Expand Up @@ -199,12 +184,6 @@ describe('LloydGeorgeRecordPage', () => {

expect(screen.getByText('Lloyd George record')).toBeInTheDocument();
expect(screen.queryByText('No documents are available')).not.toBeInTheDocument();

expect(screen.getByText(`${lgResult.numberOfFiles} files`)).toBeInTheDocument();
expect(
screen.getByText(`File size: ${formatFileSize(lgResult.totalFileSizeInBytes)}`),
).toBeInTheDocument();
expect(screen.getByText('File format: PDF')).toBeInTheDocument();
});

describe('Accessibility', () => {
Expand Down

0 comments on commit 6b29964

Please sign in to comment.