Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen committed Nov 12, 2024
1 parent 8e0702f commit 9973f92
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('PrintIdentifierStickerModal', () => {
const mockHandlePrint = jest.fn();
mockedUseReactToPrint.mockReturnValue(mockHandlePrint);

renderPrintIdentifierStickerModal();
render(<PrintIdentifierSticker closeModal={mockedCloseModal} patient={mockFhirPatient} />);

expect(screen.getByText(/print identifier sticker/i)).toBeInTheDocument();
const printButton = screen.getByRole('button', { name: /print/i });
Expand All @@ -57,7 +57,7 @@ describe('PrintIdentifierStickerModal', () => {
},
});

renderPrintIdentifierStickerModal();
render(<PrintIdentifierSticker closeModal={mockedCloseModal} patient={mockFhirPatient} />);

expect(screen.getAllByTestId('barcode')[0]).toBeInTheDocument();
expect(Barcode).toHaveBeenCalledWith(
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('PrintIdentifierStickerModal', () => {
},
});

renderPrintIdentifierStickerModal();
render(<PrintIdentifierSticker closeModal={mockedCloseModal} patient={mockFhirPatient} />);

expect(screen.queryByTestId('barcode')).not.toBeInTheDocument();
expect(screen.queryByTestId('openmrs-logo')).not.toBeInTheDocument();
Expand All @@ -110,43 +110,39 @@ describe('PrintIdentifierStickerModal', () => {
},
});

renderPrintIdentifierStickerModal();
render(<PrintIdentifierSticker closeModal={mockedCloseModal} patient={mockFhirPatient} />);

expect(screen.getAllByRole('img')[0]).toHaveAttribute('src', '/openmrs/spa/logo.png');
});

it("renders the patient's details in the print modal", () => {
renderPrintIdentifierStickerModal();
render(<PrintIdentifierSticker closeModal={mockedCloseModal} patient={mockFhirPatient} />);

expect(screen.getAllByText(/Joshua Johnson/i)[0]).toBeInTheDocument();
expect(screen.getAllByText(/\+255777053243/i)[0]).toBeInTheDocument();
expect(screen.getAllByText(/100008E/i)[0]).toBeInTheDocument();
expect(screen.getAllByText(age(mockFhirPatient.birthDate))[0]).toBeInTheDocument();
});
});

it('should not render multiple sticker inputs if multiple stickers are disabled via config', async () => {
mockedUseConfig.mockReturnValue({
...defaultConfig,
printPatientSticker: {
...defaultConfig.printPatientSticker,
printMultipleStickers: {
enabled: false,
totalStickers: 1,
stickerColumnsPerPage: 1,
stickerRowsPerPage: 1,
it('should not render multiple sticker inputs if multiple stickers are disabled via config', async () => {
mockedUseConfig.mockReturnValue({
...defaultConfig,
printPatientSticker: {
...defaultConfig.printPatientSticker,
printMultipleStickers: {
enabled: false,
totalStickers: 1,
stickerColumnsPerPage: 1,
stickerRowsPerPage: 1,
},
stickerSize: { height: '2in', width: '2in' },
},
stickerSize: { height: '2in', width: '2in' },
},
});
});

renderPrintIdentifierStickerModal();
render(<PrintIdentifierSticker closeModal={mockedCloseModal} patient={mockFhirPatient} />);

expect(screen.queryByLabelText('columnsPerPage')).not.toBeInTheDocument();
expect(screen.queryByLabelText('rowsPerPage')).not.toBeInTheDocument();
expect(screen.queryByLabelText('totalNumber')).not.toBeInTheDocument();
expect(screen.queryByLabelText('columnsPerPage')).not.toBeInTheDocument();
expect(screen.queryByLabelText('rowsPerPage')).not.toBeInTheDocument();
expect(screen.queryByLabelText('totalNumber')).not.toBeInTheDocument();
});
});

function renderPrintIdentifierStickerModal() {
return render(<PrintIdentifierSticker closeModal={mockedCloseModal} patient={mockFhirPatient} />);
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import { useReactToPrint } from 'react-to-print';
import {
Button,
Column,
Grid,
InlineLoading,
ModalBody,
ModalFooter,
ModalHeader,
NumberInput,
Stack,
Grid,
Column,
Toggle,
} from '@carbon/react';
import { getPatientName, showSnackbar, useConfig, getCoreTranslation } from '@openmrs/esm-framework';
import { getPatientName, getCoreTranslation, showSnackbar, useConfig } from '@openmrs/esm-framework';
import { type ConfigObject } from '../config-schema';
import styles from './print-identifier-sticker.scss';
import classNames from 'classnames';
import PrintComponent from './print-identifier-sticker.component';
import styles from './print-identifier-sticker.scss';

interface PrintIdentifierStickerProps {
closeModal: () => void;
Expand All @@ -26,17 +26,17 @@ interface PrintIdentifierStickerProps {

interface PrintMultipleStickersComponentProps extends Partial<ConfigObject> {
pageSize: string;
patient: fhir.Patient;
printMultipleStickers: {
enabled: boolean;
totalStickers: number;
stickerColumnsPerPage: number;
stickerRowsPerPage: number;
totalStickers: number;
};
stickerSize: {
height: string;
width: string;
};
patient: fhir.Patient;
}

const PrintIdentifierSticker: React.FC<PrintIdentifierStickerProps> = ({ closeModal, patient }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use '@carbon/colors';
@use '@carbon/layout';
@use '@carbon/type';
@use '@openmrs/esm-styleguide/src/_vars' as *;
@use '@carbon/colors';

.stickerContainer {
padding: layout.$spacing-03 layout.$spacing-05;
Expand All @@ -10,7 +10,7 @@
}

.gridContainer {
padding-left: 0rem;
padding-left: 0;
}

.documentHeader {
Expand All @@ -30,13 +30,13 @@
}

.gridRow {
padding: 0px;
padding: 0;
display: flex;
flex-direction: row;
justify-content: space-between;

div {
margin-left: 0px;
margin-left: 0;
margin-bottom: 5px;
}
}
Expand Down Expand Up @@ -77,6 +77,7 @@
@include type.type-style('heading-03');
font-weight: 700;
}

:global(.cds--toggle__switch--checked) {
background-color: colors.$green-50;
}
Expand All @@ -92,18 +93,18 @@
}

.previewContainer {
max-height: 10rem;
max-height: layout.$spacing-13;
overflow: scroll;
background-color: white;
width: 100%;
border: 1px solid $ui-03;
margin-left: auto;
margin-right: auto;
padding: 2rem;
padding: layout.$spacing-07;
}

.labelNumberInput {
padding: 1rem;
padding: layout.$spacing-05;
}

.hidePreviewContainer {
Expand Down Expand Up @@ -149,17 +150,17 @@

.multipleStickerInputs {
display: flex;
gap: 1rem;
gap: layout.$spacing-05;
}

.previewButton {
margin-top: 1rem;
margin-top: layout.$spacing-05;
}

.fieldsContainer {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem 1rem;
gap: layout.$spacing-05 layout.$spacing-05;
}

.fieldRow {
Expand Down

0 comments on commit 9973f92

Please sign in to comment.