Skip to content

Commit fdb1d39

Browse files
committed
BN-50 | Fix. Rename Empty State Message For Radiology Investigation Display Control
No radiology investigations found -> No radiology investigations recorded
1 parent e40f73c commit fdb1d39

File tree

6 files changed

+63
-81
lines changed

6 files changed

+63
-81
lines changed

public/locales/locale_en.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@
126126
"NETWORK_ERROR": "A network error occurred",
127127
"NO_ALLERGIES": "No Allergies recorded for this patient.",
128128
"NO_DIAGNOSES": "No diagnoses recorded",
129-
"NO_MATCHING_ALLERGEN_FOUND": "No matching allergen found",
130-
"NO_MATCHING_DIAGNOSIS_FOUND": "No matching diagnosis found.",
131-
"NO_RADIOLOGY_INVESTIGATIONS": "No radiology investigations found",
129+
"NO_MATCHING_ALLERGEN_FOUND": "No matching allergen recorded",
130+
"NO_MATCHING_DIAGNOSIS_FOUND": "No matching diagnosis recorded",
131+
"NO_RADIOLOGY_INVESTIGATIONS": "No radiology investigations recorded",
132132
"PARTICIPANT": "Participant(s)",
133133
"PATIENT_HEADER_ACTION_AREA_IN_PROGRESS": "Consultation in progress",
134134
"PATIENT_HEADER_LABEL": "Patient Header",

src/components/clinical/forms/allergies/__tests__/AllergiesForm.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ describe('AllergiesForm', () => {
262262
// Use a more flexible text matcher
263263
await waitFor(() => {
264264
expect(
265-
screen.getByText(/no matching allergen found/i),
265+
screen.getByText(/No matching allergen recorded/i),
266266
).toBeInTheDocument();
267267
});
268268
});

src/components/clinical/forms/diagnoses/__tests__/DiagnosesForm.test.tsx

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { render, screen, waitFor, fireEvent } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
4-
import { useTranslation, I18nextProvider } from 'react-i18next';
4+
import { I18nextProvider } from 'react-i18next';
55
import DiagnosesForm from '../DiagnosesForm';
66
import { useConceptSearch } from '@hooks/useConceptSearch';
77
import { ConceptSearch } from '@types/concepts';
@@ -14,14 +14,6 @@ import { CERTAINITY_CONCEPTS } from '@constants/concepts';
1414

1515
expect.extend(toHaveNoViolations);
1616

17-
// Mock the hooks
18-
jest.mock('react-i18next', () => ({
19-
useTranslation: jest.fn(),
20-
I18nextProvider: ({ children }: { children: React.ReactNode }) => (
21-
<>{children}</>
22-
),
23-
}));
24-
2517
jest.mock('@hooks/useConceptSearch', () => ({
2618
useConceptSearch: jest.fn(),
2719
}));
@@ -35,10 +27,6 @@ jest.mock('@stores/diagnosisStore', () => {
3527
};
3628
});
3729

38-
// Mock translation function
39-
const mockT = jest.fn((key: string) => key);
40-
(useTranslation as jest.Mock).mockReturnValue({ t: mockT });
41-
4230
// Mock data
4331
const mockConcepts: ConceptSearch[] = [
4432
{
@@ -132,9 +120,9 @@ describe('DiagnosesForm', () => {
132120
describe('Rendering', () => {
133121
it('should render the component with default state', () => {
134122
render(<DiagnosesForm />);
135-
expect(screen.getByText('DIAGNOSES_FORM_TITLE')).toBeInTheDocument();
123+
expect(screen.getByText('Diagnoses')).toBeInTheDocument();
136124
expect(
137-
screen.getByPlaceholderText('DIAGNOSES_SEARCH_PLACEHOLDER'),
125+
screen.getByPlaceholderText('Search to add new diagnosis'),
138126
).toBeInTheDocument();
139127
});
140128

@@ -146,9 +134,7 @@ describe('DiagnosesForm', () => {
146134
});
147135

148136
render(<DiagnosesForm />);
149-
expect(
150-
screen.queryByText('DIAGNOSES_ADDED_DIAGNOSES'),
151-
).not.toBeInTheDocument();
137+
expect(screen.queryByText('Added Diagnoses')).not.toBeInTheDocument();
152138
});
153139

154140
it('should render selected diagnoses section when diagnoses are present', () => {
@@ -159,7 +145,7 @@ describe('DiagnosesForm', () => {
159145
});
160146

161147
render(<DiagnosesForm />);
162-
expect(screen.getByText('DIAGNOSES_ADDED_DIAGNOSES')).toBeInTheDocument();
148+
expect(screen.getByText('Added Diagnoses')).toBeInTheDocument();
163149
expect(screen.getByText('Hypertension')).toBeInTheDocument();
164150
});
165151
});
@@ -192,7 +178,7 @@ describe('DiagnosesForm', () => {
192178
});
193179
render(<DiagnosesForm />);
194180
const searchInput = screen.getByPlaceholderText(
195-
'DIAGNOSES_SEARCH_PLACEHOLDER',
181+
'Search to add new diagnosis',
196182
);
197183

198184
// Type something first
@@ -204,7 +190,7 @@ describe('DiagnosesForm', () => {
204190
// Should have called handleSearch with empty string
205191
expect(useConceptSearch).toHaveBeenCalledWith('');
206192
expect(
207-
screen.queryByText('NO_MATCHING_DIAGNOSIS_FOUND'),
193+
screen.queryByText('No matching diagnosis recorded'),
208194
).not.toBeInTheDocument();
209195
});
210196

@@ -217,7 +203,7 @@ describe('DiagnosesForm', () => {
217203

218204
render(<DiagnosesForm />);
219205
const searchInput = screen.getByPlaceholderText(
220-
'DIAGNOSES_SEARCH_PLACEHOLDER',
206+
'Search to add new diagnosis',
221207
);
222208
await userEvent.type(searchInput, 'hyper');
223209

@@ -233,7 +219,7 @@ describe('DiagnosesForm', () => {
233219

234220
render(<DiagnosesForm />);
235221
const searchInput = screen.getByPlaceholderText(
236-
'DIAGNOSES_SEARCH_PLACEHOLDER',
222+
'Search to add new diagnosis',
237223
);
238224
await userEvent.type(searchInput, 'hyper');
239225

@@ -250,12 +236,12 @@ describe('DiagnosesForm', () => {
250236

251237
render(<DiagnosesForm />);
252238
const searchInput = screen.getByPlaceholderText(
253-
'DIAGNOSES_SEARCH_PLACEHOLDER',
239+
'Search to add new diagnosis',
254240
);
255241
await userEvent.type(searchInput, 'nonexistent');
256242

257243
expect(
258-
screen.getByText('NO_MATCHING_DIAGNOSIS_FOUND'),
244+
screen.getByText('No matching diagnosis recorded'),
259245
).toBeInTheDocument();
260246
});
261247

@@ -268,11 +254,11 @@ describe('DiagnosesForm', () => {
268254

269255
render(<DiagnosesForm />);
270256
const searchInput = screen.getByPlaceholderText(
271-
'DIAGNOSES_SEARCH_PLACEHOLDER',
257+
'Search to add new diagnosis',
272258
);
273259
await userEvent.type(searchInput, 'nonexistent');
274260

275-
expect(screen.getByText('LOADING_CONCEPTS')).toBeInTheDocument();
261+
expect(screen.getByText('Loading concepts...')).toBeInTheDocument();
276262
});
277263

278264
it('should display error message when search fails', async () => {
@@ -284,12 +270,14 @@ describe('DiagnosesForm', () => {
284270

285271
render(<DiagnosesForm />);
286272
const searchInput = screen.getByPlaceholderText(
287-
'DIAGNOSES_SEARCH_PLACEHOLDER',
273+
'Search to add new diagnosis',
288274
);
289275
await userEvent.type(searchInput, 'test');
290276

291277
// Verify error message is displayed
292-
const errorOption = screen.getByText('ERROR_FETCHING_CONCEPTS');
278+
const errorOption = screen.getByText(
279+
'An unexpected error occurred. Please try again later.',
280+
);
293281
expect(errorOption).toBeInTheDocument();
294282

295283
// Verify the error option is disabled
@@ -300,7 +288,7 @@ describe('DiagnosesForm', () => {
300288
it('should handle search term less than 3 characters', async () => {
301289
render(<DiagnosesForm />);
302290
const searchInput = screen.getByPlaceholderText(
303-
'DIAGNOSES_SEARCH_PLACEHOLDER',
291+
'Search to add new diagnosis',
304292
);
305293
await userEvent.type(searchInput, 'hy');
306294

@@ -319,7 +307,7 @@ describe('DiagnosesForm', () => {
319307

320308
render(<DiagnosesForm />);
321309
const searchInput = screen.getByPlaceholderText(
322-
'DIAGNOSES_SEARCH_PLACEHOLDER',
310+
'Search to add new diagnosis',
323311
);
324312
await userEvent.type(searchInput, 'hyper');
325313

@@ -357,13 +345,13 @@ describe('DiagnosesForm', () => {
357345

358346
render(<DiagnosesForm />);
359347
const searchInput = screen.getByPlaceholderText(
360-
'DIAGNOSES_SEARCH_PLACEHOLDER',
348+
'Search to add new diagnosis',
361349
);
362350
await userEvent.type(searchInput, 'hyper');
363351

364352
// Check that the already selected item shows with indicator text
365353
const disabledOption = await screen.findByText(
366-
`${mockConcepts[0].conceptName} DIAGNOSIS_ALREADY_SELECTED`,
354+
`${mockConcepts[0].conceptName} (Already selected)`,
367355
);
368356
expect(disabledOption).toBeInTheDocument();
369357
});
@@ -390,13 +378,13 @@ describe('DiagnosesForm', () => {
390378

391379
render(<DiagnosesForm />);
392380
const searchInput = screen.getByPlaceholderText(
393-
'DIAGNOSES_SEARCH_PLACEHOLDER',
381+
'Search to add new diagnosis',
394382
);
395383
await userEvent.type(searchInput, 'hyper');
396384

397385
// Find the disabled option
398386
const disabledOption = await screen.findByText(
399-
`${mockConcepts[0].conceptName} DIAGNOSIS_ALREADY_SELECTED`,
387+
`${mockConcepts[0].conceptName} (Already selected)`,
400388
);
401389
expect(disabledOption).toBeInTheDocument();
402390

@@ -426,7 +414,7 @@ describe('DiagnosesForm', () => {
426414

427415
// Initially no diagnoses selected
428416
const searchInput = screen.getByPlaceholderText(
429-
'DIAGNOSES_SEARCH_PLACEHOLDER',
417+
'Search to add new diagnosis',
430418
);
431419
await userEvent.type(searchInput, 'hyper');
432420

@@ -436,9 +424,7 @@ describe('DiagnosesForm', () => {
436424
});
437425

438426
// All items should be enabled (no "Already selected" text)
439-
expect(
440-
screen.queryByText(/DIAGNOSIS_ALREADY_SELECTED/),
441-
).not.toBeInTheDocument();
427+
expect(screen.queryByText(/(Already selected)/)).not.toBeInTheDocument();
442428

443429
// Now simulate adding a diagnosis to selected list
444430
const newDiagnosis: DiagnosisInputEntry = {
@@ -465,9 +451,7 @@ describe('DiagnosesForm', () => {
465451
// Now the item should show as disabled
466452
await waitFor(() => {
467453
expect(
468-
screen.getByText(
469-
`${mockConcepts[0].conceptName} DIAGNOSIS_ALREADY_SELECTED`,
470-
),
454+
screen.getByText(`${mockConcepts[0].conceptName} (Already selected)`),
471455
).toBeInTheDocument();
472456
});
473457
});
@@ -521,7 +505,7 @@ describe('DiagnosesForm', () => {
521505

522506
render(<DiagnosesForm />);
523507
const searchInput = screen.getByPlaceholderText(
524-
'DIAGNOSES_SEARCH_PLACEHOLDER',
508+
'Search to add new diagnosis',
525509
);
526510
await userEvent.type(searchInput, 'Test');
527511

@@ -540,9 +524,7 @@ describe('DiagnosesForm', () => {
540524
describe('Accessibility', () => {
541525
it('should have proper ARIA labels', () => {
542526
render(<DiagnosesForm />);
543-
expect(
544-
screen.getByLabelText('DIAGNOSES_SEARCH_ARIA_LABEL'),
545-
).toBeInTheDocument();
527+
expect(screen.getByLabelText('Search for diagnoses')).toBeInTheDocument();
546528
});
547529

548530
test('accessible forms pass axe', async () => {
@@ -611,7 +593,7 @@ describe('DiagnosesForm', () => {
611593
});
612594
const { container } = renderWithI18n(<DiagnosesForm />);
613595
const searchInput = screen.getByPlaceholderText(
614-
'DIAGNOSES_SEARCH_PLACEHOLDER',
596+
'Search to add new diagnosis',
615597
);
616598
await userEvent.type(searchInput, 'hyper');
617599
expect(container).toMatchSnapshot();

0 commit comments

Comments
 (0)