Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) O3-2655: Record Vitals: Error message for invalid values pops up only once #1578

Merged
merged 2 commits into from
Jan 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ const VitalsAndBiometricsForm: React.FC<DefaultWorkspaceProps> = ({ patientUuid,
diastolicBloodPressure,
)
}
showErrorMessage={showErrorMessage}
label={t('bloodPressure', 'Blood pressure')}
unitSymbol={conceptUnits.get(config.concepts.systolicBloodPressureUuid) ?? ''}
/>
Expand All @@ -358,6 +359,7 @@ const VitalsAndBiometricsForm: React.FC<DefaultWorkspaceProps> = ({ patientUuid,
pulse && isValueWithinReferenceRange(conceptMetadata, config.concepts['pulseUuid'], pulse)
}
label={t('heartRate', 'Heart rate')}
showErrorMessage={showErrorMessage}
unitSymbol={conceptUnits.get(config.concepts.pulseUuid) ?? ''}
/>
</Column>
Expand Down Expand Up @@ -557,6 +559,7 @@ const VitalsAndBiometricsForm: React.FC<DefaultWorkspaceProps> = ({ patientUuid,
<InlineNotification
className={styles.errorNotification}
lowContrast={false}
onClose={() => setHasInvalidVitals(false)}
title={t('vitalsAndBiometricsSaveError', 'Error saving vitals and biometrics')}
subtitle={t('checkForValidity', 'Some of the values entered are invalid')}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,33 @@ describe('VitalsBiometricsForm', () => {
title: 'Error saving vitals and biometrics',
});
});

it('Display an inline error notification on submit if value of vitals entered is invalid', async () => {
const user = userEvent.setup();

renderForm();
const systolic = screen.getByRole('spinbutton', { name: /systolic/i });
const pulse = screen.getByRole('spinbutton', { name: /pulse/i });
const oxygenSaturation = screen.getByRole('spinbutton', { name: /oxygen saturation/i });
const temperature = screen.getByRole('spinbutton', { name: /temperature/i });

await user.type(systolic, '1000');
await user.type(pulse, pulseValue.toString());
await user.type(oxygenSaturation, '200');
await user.type(temperature, temperatureValue.toString());

const saveButton = screen.getByRole('button', { name: /save and close/i });
await user.click(saveButton);

expect(screen.getByText(/Some of the values entered are invalid/i)).toBeInTheDocument();

// close the inline notification --> resubmit --> check for presence of inline notification
const closeInlineNotificationButton = screen.getByTitle(/close notification/i);
await user.click(closeInlineNotificationButton);
expect(screen.queryByText(/some of the values entered are invalid/i)).not.toBeInTheDocument();
await user.click(saveButton);
expect(screen.getByText(/Some of the values entered are invalid/i)).toBeInTheDocument();
});
});

function renderForm() {
Expand Down
Loading
Loading