@openmrs/esm-active-visits-app 5.0.1-pre.2032 → 5.0.1-pre.2035
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.turbo/turbo-build.log
CHANGED
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.2.0"},"extensions":[{"name":"active-visits-widget","slot":"homepage-widgets-slot","component":"activeVisits","order":0},{"name":"visit-summary-widget","slot":"visit-summary-slot","component":"visitDetail"}],"pages":[],"version":"5.0.1-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.2.0"},"extensions":[{"name":"active-visits-widget","slot":"homepage-widgets-slot","component":"activeVisits","order":0},{"name":"visit-summary-widget","slot":"visit-summary-slot","component":"visitDetail"}],"pages":[],"version":"5.0.1-pre.2035"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-active-visits-app",
|
|
3
|
-
"version": "5.0.1-pre.
|
|
3
|
+
"version": "5.0.1-pre.2035",
|
|
4
4
|
"description": "Active visits widget microfrontend for the OpenMRS SPA",
|
|
5
5
|
"browser": "dist/openmrs-esm-active-visits-app.js",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"webpack": "^5.74.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "bf2b92b643b93596ff08d7c31f87583d1632d5bc"
|
|
54
54
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import ActiveVisitsTable from './active-visits.component';
|
|
4
|
+
import { useConfig, usePagination } from '@openmrs/esm-framework';
|
|
5
|
+
import { useActiveVisits } from './active-visits.resource';
|
|
6
|
+
|
|
7
|
+
const mockedUsePagination = usePagination as jest.Mock;
|
|
8
|
+
const mockActiveVisits = useActiveVisits as jest.Mock;
|
|
9
|
+
|
|
10
|
+
const mockActiveVisitsData = [{ id: '1', name: 'John Doe', visitType: 'Checkup', patientUuid: 'uuid1' }];
|
|
11
|
+
jest.mock('./active-visits.resource', () => ({
|
|
12
|
+
...jest.requireActual('./active-visits.resource'),
|
|
13
|
+
useActiveVisits: jest.fn(() => ({
|
|
14
|
+
activeVisits: mockActiveVisitsData,
|
|
15
|
+
isLoading: false,
|
|
16
|
+
isValidating: false,
|
|
17
|
+
error: null,
|
|
18
|
+
})),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock('@openmrs/esm-framework', () => ({
|
|
22
|
+
...jest.requireActual('@openmrs/esm-framework'),
|
|
23
|
+
useConfig: jest.fn(() => ({ activeVisits: { pageSizes: [10, 20, 30, 40, 50], pageSize: 10 } })),
|
|
24
|
+
usePagination: jest.fn().mockImplementation((data) => ({
|
|
25
|
+
currentPage: 1,
|
|
26
|
+
goTo: () => {},
|
|
27
|
+
results: data,
|
|
28
|
+
paginated: false,
|
|
29
|
+
})),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
describe('ActiveVisitsTable', () => {
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
jest.clearAllMocks();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('renders data table with active visits', () => {
|
|
38
|
+
render(<ActiveVisitsTable />);
|
|
39
|
+
|
|
40
|
+
expect(screen.getByText('Visit Time')).toBeInTheDocument();
|
|
41
|
+
expect(screen.getByText('ID Number')).toBeInTheDocument();
|
|
42
|
+
const expectedColumnHeaders = [/Visit Time/, /ID Number/, /Name/, /Gender/, /Age/, /Visit Type/];
|
|
43
|
+
expectedColumnHeaders.forEach((header) => {
|
|
44
|
+
expect(screen.getByRole('columnheader', { name: new RegExp(header, 'i') })).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const patientNameLink = screen.getByText('John Doe');
|
|
48
|
+
expect(patientNameLink).toBeInTheDocument();
|
|
49
|
+
expect(patientNameLink.tagName).toBe('A');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it.skip('filters active visits based on search input', () => {
|
|
53
|
+
mockActiveVisits.mockImplementationOnce(() => ({
|
|
54
|
+
activeVisits: [
|
|
55
|
+
{ id: '1', name: 'John Doe', visitType: 'Checkup', patientUuid: 'uuid1' },
|
|
56
|
+
{ id: '2', name: 'Some One', visitType: 'Checkup', patientUuid: 'uuid2' },
|
|
57
|
+
],
|
|
58
|
+
isLoading: false,
|
|
59
|
+
isValidating: false,
|
|
60
|
+
error: null,
|
|
61
|
+
}));
|
|
62
|
+
render(<ActiveVisitsTable />);
|
|
63
|
+
|
|
64
|
+
const searchInput = screen.getByPlaceholderText('Filter table');
|
|
65
|
+
fireEvent.change(searchInput, { target: { value: 'John' } });
|
|
66
|
+
|
|
67
|
+
expect(screen.getByText('John Doe')).toBeInTheDocument();
|
|
68
|
+
expect(screen.queryByText('Some One')).toBeNull();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('displays empty state when there are no active visits', () => {
|
|
72
|
+
mockActiveVisits.mockImplementationOnce(() => ({
|
|
73
|
+
activeVisits: [],
|
|
74
|
+
isLoading: false,
|
|
75
|
+
isValidating: false,
|
|
76
|
+
error: null,
|
|
77
|
+
}));
|
|
78
|
+
|
|
79
|
+
render(<ActiveVisitsTable />);
|
|
80
|
+
|
|
81
|
+
expect(screen.getByText('There are no active visits to display for this location.')).toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should not display the table when the data is loading', () => {
|
|
85
|
+
mockActiveVisits.mockImplementationOnce(() => ({
|
|
86
|
+
activeVisits: undefined,
|
|
87
|
+
isLoading: true,
|
|
88
|
+
isValidating: false,
|
|
89
|
+
error: null,
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
render(<ActiveVisitsTable />);
|
|
93
|
+
|
|
94
|
+
const expectedColumnHeaders = [/Visit Time/, /ID Number/, /Name/, /Gender/, /Age/, /Visit Type/];
|
|
95
|
+
expectedColumnHeaders.forEach((header) => {
|
|
96
|
+
expect(screen.queryByRole('columnheader', { name: new RegExp(header, 'i') })).not.toBeInTheDocument();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should display the Error when there is error', () => {
|
|
101
|
+
mockActiveVisits.mockImplementationOnce(() => ({
|
|
102
|
+
activeVisits: undefined,
|
|
103
|
+
isLoading: false,
|
|
104
|
+
isValidating: false,
|
|
105
|
+
error: 'Error in fetching data',
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
render(<ActiveVisitsTable />);
|
|
109
|
+
|
|
110
|
+
const expectedColumnHeaders = [/Visit Time/, /ID Number/, /Name/, /Gender/, /Age/, /Visit Type/];
|
|
111
|
+
expectedColumnHeaders.forEach((header) => {
|
|
112
|
+
expect(screen.queryByRole('columnheader', { name: new RegExp(header, 'i') })).toBeInTheDocument();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should display the pagination when pagination is true', () => {
|
|
117
|
+
mockActiveVisits.mockImplementationOnce(() => ({
|
|
118
|
+
activeVisits: [
|
|
119
|
+
{ id: '1', name: 'John Doe', visitType: 'Checkup' },
|
|
120
|
+
{ id: '2', name: 'Some One', visitType: 'Checkup' },
|
|
121
|
+
],
|
|
122
|
+
isLoading: false,
|
|
123
|
+
isValidating: false,
|
|
124
|
+
error: null,
|
|
125
|
+
}));
|
|
126
|
+
mockedUsePagination.mockImplementationOnce((data) => ({
|
|
127
|
+
currentPage: 1,
|
|
128
|
+
goTo: () => {},
|
|
129
|
+
results: data,
|
|
130
|
+
paginated: true,
|
|
131
|
+
}));
|
|
132
|
+
render(<ActiveVisitsTable />);
|
|
133
|
+
|
|
134
|
+
expect(screen.getByText(/Next Page/i)).toBeInTheDocument();
|
|
135
|
+
});
|
|
136
|
+
});
|