@openmrs/esm-active-visits-app 8.0.3-pre.4473 → 8.0.3-pre.4476

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.
@@ -34,4 +34,4 @@ Entrypoints:
34
34
  main (350 KiB)
35
35
  main.js
36
36
 
37
- webpack 5.88.0 compiled with 2 warnings in 102431 ms
37
+ webpack 5.88.0 compiled with 2 warnings in 100903 ms
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"},{"name":"active-visits-tile","slot":"home-metrics-tiles-slot","component":"homeActiveVisitsTile"},{"name":"total-visits-tile","slot":"home-metrics-tiles-slot","component":"homeTotalVisitsTile"}],"pages":[],"version":"8.0.3-pre.4473"}
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"},{"name":"active-visits-tile","slot":"home-metrics-tiles-slot","component":"homeActiveVisitsTile"},{"name":"total-visits-tile","slot":"home-metrics-tiles-slot","component":"homeTotalVisitsTile"}],"pages":[],"version":"8.0.3-pre.4476"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-active-visits-app",
3
- "version": "8.0.3-pre.4473",
3
+ "version": "8.0.3-pre.4476",
4
4
  "description": "Active visits widget microfrontend for O3",
5
5
  "browser": "dist/openmrs-esm-active-visits-app.js",
6
6
  "main": "src/index.ts",
@@ -1,21 +1,23 @@
1
1
  import React from 'react';
2
2
  import userEvent from '@testing-library/user-event';
3
3
  import { render, screen } from '@testing-library/react';
4
- import { formatDate } from '@openmrs/esm-framework';
5
4
  import { useVisit } from './visit.resource';
6
5
  import VisitDetailComponent from './visit-detail.component';
7
6
 
7
+ const mockUseVisit = jest.mocked(useVisit);
8
8
  const defaultProps = {
9
9
  patientUuid: '691eed12-c0f1-11e2-94be-8c13b969e334',
10
10
  visitUuid: '497b8b17-54ec-4726-87ec-3c4da8cdcaeb',
11
11
  };
12
- const mockUseVisit = jest.mocked(useVisit);
13
12
 
14
- jest.mock('./visit.resource');
13
+ jest.mock('./visit.resource', () => ({
14
+ ...jest.requireActual('./visit.resource'),
15
+ useVisit: jest.fn(),
16
+ }));
15
17
 
16
18
  describe('VisitDetail', () => {
17
19
  it('renders a loading spinner when data is loading', () => {
18
- mockUseVisit.mockReturnValueOnce({
20
+ mockUseVisit.mockReturnValue({
19
21
  visit: null,
20
22
  error: undefined,
21
23
  isLoading: true,
@@ -29,7 +31,8 @@ describe('VisitDetail', () => {
29
31
 
30
32
  it('renders a visit detail overview when data is available', () => {
31
33
  const mockVisitDate = new Date();
32
- mockUseVisit.mockReturnValueOnce({
34
+
35
+ mockUseVisit.mockReturnValue({
33
36
  visit: {
34
37
  encounters: [],
35
38
  startDatetime: mockVisitDate.toISOString(),
@@ -43,13 +46,14 @@ describe('VisitDetail', () => {
43
46
 
44
47
  render(<VisitDetailComponent {...defaultProps} />);
45
48
 
46
- expect(screen.getByText(/Some Visit Type/)).toBeInTheDocument();
47
- expect(screen.getByText(formatDate(mockVisitDate), { collapseWhitespace: false })).toBeInTheDocument();
48
- expect(screen.getByText('All Encounters')).toBeInTheDocument();
49
- expect(screen.getByText('Visit Summary')).toBeInTheDocument();
49
+ expect(screen.getByRole('heading', { name: /some visit type/i })).toBeInTheDocument();
50
+ expect(screen.getByRole('heading', { name: /no encounters found/i })).toBeInTheDocument();
51
+ expect(screen.getByText(/there is no information to display here/i)).toBeInTheDocument();
52
+ expect(screen.getByRole('tab', { name: /all encounters/i })).toBeInTheDocument();
53
+ expect(screen.getByRole('tab', { name: /visit summary/i })).toBeInTheDocument();
50
54
  });
51
55
 
52
- it('render the Encounter Lists view when the "All Encounters" tab is clicked', async () => {
56
+ it('renders the Encounter Lists view when the "All Encounters" tab is clicked', async () => {
53
57
  const user = userEvent.setup();
54
58
 
55
59
  mockUseVisit.mockReturnValue({
@@ -74,8 +78,12 @@ describe('VisitDetail', () => {
74
78
 
75
79
  render(<VisitDetailComponent {...defaultProps} />);
76
80
 
77
- await user.click(screen.getByText('All Encounters'));
78
- expect(screen.getByTestId('encountersTable')).toBeInTheDocument();
81
+ await user.click(screen.getByRole('tab', { name: /all encounters/i }));
82
+ expect(screen.getByRole('table')).toBeInTheDocument();
83
+ expect(screen.getByRole('columnheader', { name: /time/i })).toBeInTheDocument();
84
+ expect(screen.getByRole('columnheader', { name: /encounter type/i })).toBeInTheDocument();
85
+ expect(screen.getByRole('columnheader', { name: /provider/i })).toBeInTheDocument();
86
+ expect(screen.getByRole('row', { name: /12:34 pm encounter type/i })).toBeInTheDocument();
79
87
  });
80
88
 
81
89
  it('renders the Visit Summaries view when the "Visit Summary" tab is clicked', async () => {
@@ -112,7 +120,12 @@ describe('VisitDetail', () => {
112
120
 
113
121
  render(<VisitDetailComponent {...defaultProps} />);
114
122
 
115
- await user.click(screen.getByText('Visit Summary'));
116
- expect(screen.getByRole('tablist', { name: 'Visit summary tabs' })).toBeInTheDocument();
123
+ await user.click(screen.getByRole('tab', { name: /visit summary/i }));
124
+ expect(screen.getByRole('tablist', { name: /visit summary tabs/i })).toBeInTheDocument();
125
+ expect(screen.getByRole('tab', { name: /notes/i })).toBeInTheDocument();
126
+ expect(screen.getByRole('tab', { name: /tests/i })).toBeInTheDocument();
127
+ expect(screen.getByRole('tab', { name: /medications/i })).toBeInTheDocument();
128
+ expect(screen.getByText(/no diagnoses found/i)).toBeInTheDocument();
129
+ expect(screen.getByText(/there are no notes to display for this patient/i)).toBeInTheDocument();
117
130
  });
118
131
  });