@openmrs/esm-patient-programs-app 3.0.0-pre.65 → 3.0.0-pre.656
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/dist/133.openmrs-esm-patient-programs-app.js +3 -0
- package/dist/133.openmrs-esm-patient-programs-app.js.LICENSE.txt +14 -0
- package/dist/133.openmrs-esm-patient-programs-app.js.map +1 -0
- package/dist/401.openmrs-esm-patient-programs-app.js +3 -0
- package/dist/401.openmrs-esm-patient-programs-app.js.LICENSE.txt +14 -0
- package/dist/401.openmrs-esm-patient-programs-app.js.map +1 -0
- package/dist/574.openmrs-esm-patient-programs-app.js +1 -0
- package/dist/639.openmrs-esm-patient-programs-app.js +2 -0
- package/dist/639.openmrs-esm-patient-programs-app.js.map +1 -0
- package/dist/757.openmrs-esm-patient-programs-app.js +1 -0
- package/dist/783.openmrs-esm-patient-programs-app.js +3 -0
- package/dist/783.openmrs-esm-patient-programs-app.js.LICENSE.txt +23 -0
- package/dist/783.openmrs-esm-patient-programs-app.js.map +1 -0
- package/dist/839.openmrs-esm-patient-programs-app.js +2 -0
- package/dist/839.openmrs-esm-patient-programs-app.js.map +1 -0
- package/dist/972.openmrs-esm-patient-programs-app.js +2 -0
- package/dist/972.openmrs-esm-patient-programs-app.js.map +1 -0
- package/dist/openmrs-esm-patient-programs-app.js +2 -1
- package/dist/openmrs-esm-patient-programs-app.js.LICENSE.txt +5 -0
- package/dist/openmrs-esm-patient-programs-app.js.buildmanifest.json +220 -0
- package/dist/openmrs-esm-patient-programs-app.js.map +1 -1
- package/package.json +10 -11
- package/src/dashboard.meta.tsx +6 -0
- package/src/declarations.d.tsx +3 -3
- package/src/index.ts +31 -30
- package/src/programs/program-record.component.tsx +29 -48
- package/src/programs/program-record.test.outdated.tsx +30 -34
- package/src/programs/programs-detailed-summary.component.tsx +123 -114
- package/src/programs/programs-detailed-summary.scss +24 -0
- package/src/programs/programs-detailed-summary.test.tsx +71 -0
- package/src/programs/programs-form.component.tsx +257 -473
- package/src/programs/programs-form.scss +20 -0
- package/src/programs/programs-form.test.tsx +206 -0
- package/src/programs/programs-overview.component.tsx +44 -74
- package/src/programs/programs-overview.scss +4 -0
- package/src/programs/programs-overview.test.tsx +70 -0
- package/src/programs/programs.component.test.tsx +21 -0
- package/src/programs/programs.component.tsx +6 -10
- package/src/programs/programs.context.tsx +1 -1
- package/src/programs/programs.resource.tsx +31 -43
- package/translations/en.json +29 -1
- package/webpack.config.js +1 -80
- package/dist/0.openmrs-esm-patient-programs-app.js +0 -22
- package/dist/0.openmrs-esm-patient-programs-app.js.map +0 -1
- package/dist/1.openmrs-esm-patient-programs-app.js +0 -2
- package/dist/1.openmrs-esm-patient-programs-app.js.map +0 -1
- package/dist/3.openmrs-esm-patient-programs-app.js +0 -23
- package/dist/3.openmrs-esm-patient-programs-app.js.map +0 -1
- package/dist/4.openmrs-esm-patient-programs-app.js +0 -2
- package/dist/4.openmrs-esm-patient-programs-app.js.map +0 -1
- package/dist/5.openmrs-esm-patient-programs-app.js +0 -2
- package/dist/5.openmrs-esm-patient-programs-app.js.map +0 -1
- package/dist/6.openmrs-esm-patient-programs-app.js +0 -2
- package/dist/6.openmrs-esm-patient-programs-app.js.map +0 -1
- package/dist/7.openmrs-esm-patient-programs-app.js +0 -2
- package/dist/7.openmrs-esm-patient-programs-app.js.map +0 -1
- package/dist/8.openmrs-esm-patient-programs-app.js +0 -2
- package/dist/8.openmrs-esm-patient-programs-app.js.map +0 -1
- package/src/cards/summary-card.component.tsx +0 -82
- package/src/cards/summary-card.css +0 -65
- package/src/dashboard/dashboard-link.component.tsx +0 -7
- package/src/dashboard/dashboard.meta.tsx +0 -6
- package/src/openmrs-backend-dependencies.ts +0 -4
- package/src/programs/empty-state/empty-data-illustration.component.tsx +0 -53
- package/src/programs/empty-state/empty-state.component.tsx +0 -39
- package/src/programs/empty-state/empty-state.scss +0 -34
- package/src/programs/error-state/error-state.component.tsx +0 -26
- package/src/programs/error-state/error-state.scss +0 -36
- package/src/programs/openWorkspaceTab.tsx +0 -40
- package/src/programs/programs-detailed-summary.css +0 -63
- package/src/programs/programs-detailed-summary.test.outdated.tsx +0 -57
- package/src/programs/programs-form.css +0 -95
- package/src/programs/programs-form.test.outdated.tsx +0 -276
- package/src/programs/programs-overview.test.outdated.tsx +0 -73
- package/src/programs/programs.component.test.outdated.tsx +0 -18
- package/src/set-public-path.ts +0 -3
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
:global(.omrs-breakpoint-gt-phone) .programsSummary {
|
|
2
|
-
display: flex;
|
|
3
|
-
justify-content: center;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
:global(.omrs-breakpoint-lt-tablet) .programsSummary {
|
|
7
|
-
padding: 0.25rem 0.5rem 0 0.5rem;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.programTable {
|
|
11
|
-
width: 100%;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.programTable thead {
|
|
15
|
-
color: var(--omrs-color-ink-medium-contrast);
|
|
16
|
-
border-bottom: 0.0625rem solid var(--omrs-color-bg-low-contrast);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.programTable thead tr th {
|
|
20
|
-
font-weight: normal;
|
|
21
|
-
text-transform: uppercase;
|
|
22
|
-
padding: 1rem 0.25rem 1rem 1rem;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.programTable tbody {
|
|
26
|
-
padding: 2rem;
|
|
27
|
-
border-bottom: 0.0625rem solid var(--omrs-color-bg-low-contrast);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
:global(.omrs-breakpoint-lt-tablet) .programTable thead td {
|
|
31
|
-
padding: 0.25rem 0.125rem 0.5rem 0.5rem;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.programsSummary tr {
|
|
35
|
-
padding: 0.813rem 0 1rem 0.813rem;
|
|
36
|
-
border-bottom: 0.0625rem solid var(--omrs-color-bg-low-contrast);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.programTable td {
|
|
40
|
-
padding: 0.75rem 0 0.75rem 1rem;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.programTable tbody td:nth-child(2) {
|
|
44
|
-
font-family: "Work Sans";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.programTable tbody td:nth-child(3) {
|
|
48
|
-
font-family: "Work Sans";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
tr.inactive {
|
|
52
|
-
background: var(--omrs-color-bg-medium-contrast);
|
|
53
|
-
color: var(--omrs-color-ink-medium-contrast);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
tr.active {
|
|
57
|
-
background: var(--omrs-color-bg-high-contrast);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.emptyPrograms p {
|
|
61
|
-
text-align: left;
|
|
62
|
-
padding-left: 1rem;
|
|
63
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ProgramsDetailedSummary from "./programs-detailed-summary.component";
|
|
3
|
-
import { render, screen } from "@testing-library/react";
|
|
4
|
-
import { BrowserRouter } from "react-router-dom";
|
|
5
|
-
import { of } from "rxjs/internal/observable/of";
|
|
6
|
-
import { mockEnrolledProgramsResponse } from "../../../../__mocks__/programs.mock";
|
|
7
|
-
import { fetchEnrolledPrograms } from "./programs.resource";
|
|
8
|
-
|
|
9
|
-
const mockFetchEnrolledPrograms = fetchEnrolledPrograms as jest.Mock;
|
|
10
|
-
|
|
11
|
-
const renderProgramsDetailedSummary = () =>
|
|
12
|
-
render(
|
|
13
|
-
<BrowserRouter>
|
|
14
|
-
<ProgramsDetailedSummary />
|
|
15
|
-
</BrowserRouter>
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
jest.mock("./programs.resource", () => ({
|
|
19
|
-
fetchEnrolledPrograms: jest.fn(),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
describe("<ProgramsDetailedSummary />", () => {
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
mockFetchEnrolledPrograms.mockReset;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("displays a detailed summary of the patient's program enrollments", async () => {
|
|
28
|
-
mockFetchEnrolledPrograms.mockReturnValue(of(mockEnrolledProgramsResponse));
|
|
29
|
-
|
|
30
|
-
renderProgramsDetailedSummary();
|
|
31
|
-
|
|
32
|
-
await screen.findByRole("heading", { name: /Care Programs/i });
|
|
33
|
-
expect(screen.getByText(/Care Programs/i)).toBeInTheDocument();
|
|
34
|
-
|
|
35
|
-
expect(screen.getByText("Active Programs")).toBeInTheDocument();
|
|
36
|
-
expect(screen.getByText("Since")).toBeInTheDocument();
|
|
37
|
-
expect(screen.getByText("Status")).toBeInTheDocument();
|
|
38
|
-
expect(screen.getByText("HIV Care and Treatment")).toBeInTheDocument();
|
|
39
|
-
expect(screen.getByText("Jan-2020")).toBeInTheDocument();
|
|
40
|
-
expect(screen.getByText("Active")).toBeInTheDocument();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("renders an empty state view when program enrollment data is absent", async () => {
|
|
44
|
-
mockFetchEnrolledPrograms.mockReturnValue(of({}));
|
|
45
|
-
|
|
46
|
-
renderProgramsDetailedSummary();
|
|
47
|
-
|
|
48
|
-
await screen.findByRole("heading", { name: /Care Programs/i });
|
|
49
|
-
expect(screen.getByText(/Care Programs/i)).toBeInTheDocument();
|
|
50
|
-
|
|
51
|
-
expect(
|
|
52
|
-
screen.getByText(
|
|
53
|
-
/There are no program enrollments to display for this patient/
|
|
54
|
-
)
|
|
55
|
-
).toBeInTheDocument();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
:global(.omrs-breakpoint-gt-phone) .programsForm {
|
|
2
|
-
display: flex;
|
|
3
|
-
justify-content: center;
|
|
4
|
-
flex-wrap: wrap;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
:global(.omrs-breakpoint-lt-tablet) .programsForm {
|
|
8
|
-
padding: 0.25rem 0.5rem 0 0.5rem;
|
|
9
|
-
flex-direction: row;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
:global(.omrs-breakpoint-lt-tablet) .programsContainerWrapper {
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
flex-wrap: wrap;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.programsContainerWrapper {
|
|
19
|
-
display: flex;
|
|
20
|
-
margin: 0rem 0rem 0.25rem 0rem;
|
|
21
|
-
flex-wrap: wrap;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.programsContainer {
|
|
25
|
-
display: flex;
|
|
26
|
-
margin: 0rem 0rem 0.25rem 0rem;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.programsInputContainer {
|
|
30
|
-
display: flex;
|
|
31
|
-
flex-direction: column;
|
|
32
|
-
margin: 0.625rem;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.programsInputControl + svg {
|
|
36
|
-
padding-right: 0.125rem;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.programsInputContainer select {
|
|
40
|
-
font-size: 1rem;
|
|
41
|
-
height: 2.625rem;
|
|
42
|
-
color: var(--omrs-color-interaction);
|
|
43
|
-
padding: 0.5rem;
|
|
44
|
-
border: 0.0625rem solid var(--omrs-color-ink-lowest-contrast);
|
|
45
|
-
background-color: var(--omrs-color-ink-white);
|
|
46
|
-
min-width: 50%;
|
|
47
|
-
width: 100%;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.programsInputContainer label {
|
|
51
|
-
margin: 0.375rem 0rem;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.buttonStyles {
|
|
55
|
-
display: flex;
|
|
56
|
-
background: var(--omrs-color-ink-white);
|
|
57
|
-
bottom: 0;
|
|
58
|
-
justify-content: center;
|
|
59
|
-
width: 100%;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.buttonStyles button {
|
|
63
|
-
margin: 0.5rem 1rem;
|
|
64
|
-
cursor: pointer;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.buttonStyles button:disabled {
|
|
68
|
-
background: var(--omrs-color-ink-lowest-contrast);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.buttonStylesBorder {
|
|
72
|
-
border-top: 0.125rem solid var(--omrs-color-interaction);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.dateError {
|
|
76
|
-
flex-direction: row;
|
|
77
|
-
box-sizing: border-box;
|
|
78
|
-
display: flex;
|
|
79
|
-
padding-top: 0.5rem;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.dateError span {
|
|
83
|
-
color: var(--omrs-color-danger);
|
|
84
|
-
line-height: 1.25rem;
|
|
85
|
-
font-size: 0.875rem;
|
|
86
|
-
white-space: normal;
|
|
87
|
-
display: inline;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.dateError svg {
|
|
91
|
-
fill: var(--omrs-color-danger);
|
|
92
|
-
height: 0.8rem;
|
|
93
|
-
width: 1.5rem;
|
|
94
|
-
padding-right: 0.25rem;
|
|
95
|
-
}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import dayjs from "dayjs";
|
|
3
|
-
import ProgramsForm, { ProgramMatchProps } from "./programs-form.component";
|
|
4
|
-
import { render, screen, fireEvent } from "@testing-library/react";
|
|
5
|
-
import {
|
|
6
|
-
match,
|
|
7
|
-
useHistory,
|
|
8
|
-
useRouteMatch,
|
|
9
|
-
BrowserRouter,
|
|
10
|
-
} from "react-router-dom";
|
|
11
|
-
import { of } from "rxjs/internal/observable/of";
|
|
12
|
-
import {
|
|
13
|
-
createProgramEnrollment,
|
|
14
|
-
fetchPrograms,
|
|
15
|
-
fetchEnrolledPrograms,
|
|
16
|
-
fetchLocations,
|
|
17
|
-
getPatientProgramByUuid,
|
|
18
|
-
getSession,
|
|
19
|
-
updateProgramEnrollment,
|
|
20
|
-
} from "./programs.resource";
|
|
21
|
-
import {
|
|
22
|
-
mockCareProgramsResponse,
|
|
23
|
-
mockEnrolledProgramsResponse,
|
|
24
|
-
mockLocationsResponse,
|
|
25
|
-
mockOncProgramResponse,
|
|
26
|
-
} from "../../../../__mocks__/programs.mock";
|
|
27
|
-
import { mockSessionDataResponse } from "../../../../__mocks__/session.mock";
|
|
28
|
-
|
|
29
|
-
const mockCreateProgramEnrollment = createProgramEnrollment as jest.Mock;
|
|
30
|
-
const mockFetchLocations = fetchLocations as jest.Mock;
|
|
31
|
-
const mockFetchCarePrograms = fetchPrograms as jest.Mock;
|
|
32
|
-
const mockFetchEnrolledPrograms = fetchEnrolledPrograms as jest.Mock;
|
|
33
|
-
const mockGetProgramByUuid = getPatientProgramByUuid as jest.Mock;
|
|
34
|
-
const mockGetSession = getSession as jest.Mock;
|
|
35
|
-
const mockUseRouteMatch = useRouteMatch as jest.Mock;
|
|
36
|
-
const mockUseHistory = useHistory as jest.Mock;
|
|
37
|
-
const mockUpdateProgramEnrollment = updateProgramEnrollment as jest.Mock;
|
|
38
|
-
let testMatch: match<ProgramMatchProps>;
|
|
39
|
-
|
|
40
|
-
const renderProgramsForm = () =>
|
|
41
|
-
render(
|
|
42
|
-
<BrowserRouter>
|
|
43
|
-
<ProgramsForm match={testMatch} />
|
|
44
|
-
</BrowserRouter>
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
jest.mock("./programs.resource", () => ({
|
|
48
|
-
createProgramEnrollment: jest.fn(),
|
|
49
|
-
fetchEnrolledPrograms: jest.fn(),
|
|
50
|
-
fetchPrograms: jest.fn(),
|
|
51
|
-
fetchLocations: jest.fn(),
|
|
52
|
-
getPatientProgramByUuid: jest.fn(),
|
|
53
|
-
getSession: jest.fn(),
|
|
54
|
-
saveProgramEnrollment: jest.fn(),
|
|
55
|
-
updateProgramEnrollment: jest.fn(),
|
|
56
|
-
}));
|
|
57
|
-
|
|
58
|
-
jest.mock("react-router-dom", () => ({
|
|
59
|
-
...jest.requireActual("react-router-dom"),
|
|
60
|
-
useHistory: jest.fn(),
|
|
61
|
-
useRouteMatch: jest.fn(),
|
|
62
|
-
}));
|
|
63
|
-
|
|
64
|
-
const renderDate = (time: string) => dayjs(time).format("YYYY-MM-DD");
|
|
65
|
-
|
|
66
|
-
describe("<ProgramsForm />", () => {
|
|
67
|
-
beforeEach(() => {
|
|
68
|
-
mockUseRouteMatch.mockReset;
|
|
69
|
-
mockFetchLocations.mockReset;
|
|
70
|
-
mockFetchCarePrograms.mockReset;
|
|
71
|
-
mockFetchEnrolledPrograms.mockReset;
|
|
72
|
-
mockGetSession.mockReset;
|
|
73
|
-
mockGetProgramByUuid.mockReset;
|
|
74
|
-
mockUseHistory.mockReset;
|
|
75
|
-
|
|
76
|
-
mockGetSession.mockReturnValue(Promise.resolve(mockSessionDataResponse));
|
|
77
|
-
mockFetchCarePrograms.mockReturnValue(of(mockCareProgramsResponse));
|
|
78
|
-
mockFetchLocations.mockReturnValue(of(mockLocationsResponse));
|
|
79
|
-
mockGetProgramByUuid.mockReturnValue(of(mockOncProgramResponse));
|
|
80
|
-
|
|
81
|
-
testMatch = { params: {}, isExact: false, path: "/", url: "/" };
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
afterEach(() => jest.restoreAllMocks());
|
|
85
|
-
|
|
86
|
-
it("renders the add program form with all the appropriate fields and values", async () => {
|
|
87
|
-
mockUseRouteMatch.mockReturnValue(testMatch);
|
|
88
|
-
mockFetchEnrolledPrograms.mockReturnValue(of(mockEnrolledProgramsResponse));
|
|
89
|
-
mockCreateProgramEnrollment.mockReturnValue(
|
|
90
|
-
of({ status: 201, statusText: "Created" })
|
|
91
|
-
);
|
|
92
|
-
mockUseHistory.mockReturnValue({
|
|
93
|
-
push: jest.fn(),
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
renderProgramsForm();
|
|
97
|
-
|
|
98
|
-
await screen.findByRole("heading", { name: "Add a new program" });
|
|
99
|
-
expect(screen.getByText("Add a new program")).toBeInTheDocument();
|
|
100
|
-
expect(screen.getByLabelText("Program")).toBeInTheDocument();
|
|
101
|
-
expect(screen.getByText("Choose a program:")).toBeInTheDocument();
|
|
102
|
-
expect(
|
|
103
|
-
screen.getByText("Oncology Screening and Diagnosis").textContent
|
|
104
|
-
).toBeTruthy();
|
|
105
|
-
expect(
|
|
106
|
-
screen.getByText("HIV Differentiated Care").textContent
|
|
107
|
-
).toBeTruthy();
|
|
108
|
-
expect(screen.getByLabelText("Date enrolled")).toBeInTheDocument();
|
|
109
|
-
expect(screen.getByLabelText("Date completed")).toBeInTheDocument();
|
|
110
|
-
expect(screen.getByLabelText("Enrollment location")).toBeInTheDocument();
|
|
111
|
-
expect(screen.getByText("Choose a location:")).toBeInTheDocument();
|
|
112
|
-
expect(screen.getByText("Amani Hospital")).toBeInTheDocument();
|
|
113
|
-
expect(screen.getByText("Inpatient Ward")).toBeInTheDocument();
|
|
114
|
-
expect(screen.getByText("Isolation Ward")).toBeInTheDocument();
|
|
115
|
-
expect(screen.getByText("Laboratory")).toBeInTheDocument();
|
|
116
|
-
expect(screen.getByText("Mosoriot Pharmacy")).toBeInTheDocument();
|
|
117
|
-
expect(
|
|
118
|
-
screen.getByText("Mosoriot Subcounty Hospital").textContent
|
|
119
|
-
).toBeTruthy();
|
|
120
|
-
expect(screen.getByText("MTRH")).toBeInTheDocument();
|
|
121
|
-
expect(screen.getByText("MTRH Module 4")).toBeInTheDocument();
|
|
122
|
-
expect(screen.getByText("Outpatient Clinic")).toBeInTheDocument();
|
|
123
|
-
expect(screen.getByText("Pharmacy")).toBeInTheDocument();
|
|
124
|
-
expect(screen.getByText("Registration Desk")).toBeInTheDocument();
|
|
125
|
-
expect(screen.getByText("Unknown Location")).toBeInTheDocument();
|
|
126
|
-
const cancelBtn = screen.getByRole("button", { name: "Cancel" });
|
|
127
|
-
expect(cancelBtn).toBeInTheDocument();
|
|
128
|
-
expect(cancelBtn).not.toBeDisabled();
|
|
129
|
-
const enrollBtn = screen.getByRole("button", { name: "Enroll" });
|
|
130
|
-
expect(enrollBtn).toBeInTheDocument();
|
|
131
|
-
expect(enrollBtn).toBeDisabled();
|
|
132
|
-
|
|
133
|
-
// Select Oncology screening and diagnosis program
|
|
134
|
-
const oncologyScreeningProgramUuid = "11b129ca-a5e7-4025-84bf-b92a173e20de";
|
|
135
|
-
const chooseProgramInput = screen.getAllByRole("combobox", { name: "" })[0];
|
|
136
|
-
fireEvent.change(chooseProgramInput, {
|
|
137
|
-
target: { value: oncologyScreeningProgramUuid },
|
|
138
|
-
});
|
|
139
|
-
await screen.findByDisplayValue("Oncology Screening and Diagnosis");
|
|
140
|
-
|
|
141
|
-
// Select enrollment date
|
|
142
|
-
const enrollmentDateInput = screen.getByLabelText("Date enrolled");
|
|
143
|
-
fireEvent.change(enrollmentDateInput, { target: { value: "2020-05-05" } });
|
|
144
|
-
await screen.findByDisplayValue(renderDate("2020-05-05"));
|
|
145
|
-
|
|
146
|
-
// Select enrollment location
|
|
147
|
-
const inpatientWardUuid = "b1a8b05e-3542-4037-bbd3-998ee9c40574";
|
|
148
|
-
const chooseLocationInput = screen.getAllByRole("combobox", {
|
|
149
|
-
name: "",
|
|
150
|
-
})[1];
|
|
151
|
-
fireEvent.change(chooseLocationInput, {
|
|
152
|
-
target: { value: inpatientWardUuid },
|
|
153
|
-
});
|
|
154
|
-
await screen.findByDisplayValue("Inpatient Ward");
|
|
155
|
-
|
|
156
|
-
fireEvent.click(enrollBtn);
|
|
157
|
-
|
|
158
|
-
expect(mockCreateProgramEnrollment).toHaveBeenCalledTimes(1);
|
|
159
|
-
expect(mockCreateProgramEnrollment).toHaveBeenCalledWith(
|
|
160
|
-
{
|
|
161
|
-
dateCompleted: null,
|
|
162
|
-
dateEnrolled: "2020-05-05",
|
|
163
|
-
location: "b1a8b05e-3542-4037-bbd3-998ee9c40574",
|
|
164
|
-
patient: "8673ee4f-e2ab-4077-ba55-4980f408773e",
|
|
165
|
-
program: "11b129ca-a5e7-4025-84bf-b92a173e20de",
|
|
166
|
-
},
|
|
167
|
-
new AbortController()
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
// Should navigate away after successful POST
|
|
171
|
-
expect(mockUseHistory).toHaveBeenCalled();
|
|
172
|
-
|
|
173
|
-
window.confirm = jest.fn(() => true);
|
|
174
|
-
|
|
175
|
-
// clicking Cancel prompts user for confirmation
|
|
176
|
-
fireEvent.click(cancelBtn);
|
|
177
|
-
|
|
178
|
-
jest.spyOn(window, "confirm").mockImplementation(() => true);
|
|
179
|
-
|
|
180
|
-
expect(window.confirm).toHaveBeenCalled();
|
|
181
|
-
expect(window.confirm).toHaveBeenCalledWith(
|
|
182
|
-
"There is ongoing work, are you sure you want to close this tab?"
|
|
183
|
-
);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it("renders the edit program form when the edit button is clicked on an existing program", async () => {
|
|
187
|
-
testMatch = {
|
|
188
|
-
params: {
|
|
189
|
-
program: "Oncology Screening and Diagnosis",
|
|
190
|
-
programUuid: "46bd14b8-2357-42a2-8e16-262e8f0057d7",
|
|
191
|
-
enrollmentDate: "2020-01-25T00:00:00.000+0000",
|
|
192
|
-
completionDate: "2020-04-14T00:00:00.000+0000",
|
|
193
|
-
locationUuid: "58c57d25-8d39-41ab-8422-108a0c277d98",
|
|
194
|
-
},
|
|
195
|
-
isExact: false,
|
|
196
|
-
path: "/",
|
|
197
|
-
url: "/",
|
|
198
|
-
};
|
|
199
|
-
mockUseRouteMatch.mockReturnValue(testMatch);
|
|
200
|
-
mockUpdateProgramEnrollment.mockReturnValue(
|
|
201
|
-
of({ status: 200, statusText: "OK" })
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
renderProgramsForm();
|
|
205
|
-
|
|
206
|
-
await screen.findByRole("heading", { name: "Edit program" });
|
|
207
|
-
expect(screen.getByText("Edit program")).toBeInTheDocument();
|
|
208
|
-
expect(screen.getByLabelText("Program")).toBeInTheDocument();
|
|
209
|
-
expect(
|
|
210
|
-
screen.getByText("Oncology Screening and Diagnosis")
|
|
211
|
-
).toBeInTheDocument();
|
|
212
|
-
expect(screen.getByLabelText("Date enrolled")).toBeInTheDocument();
|
|
213
|
-
expect(
|
|
214
|
-
screen.getByDisplayValue(renderDate(testMatch.params.enrollmentDate))
|
|
215
|
-
).toBeInTheDocument();
|
|
216
|
-
expect(screen.getByLabelText("Date completed")).toBeInTheDocument();
|
|
217
|
-
expect(
|
|
218
|
-
screen.getByDisplayValue(renderDate(testMatch.params.completionDate))
|
|
219
|
-
).toBeInTheDocument();
|
|
220
|
-
expect(screen.getByLabelText("Enrollment location")).toBeInTheDocument();
|
|
221
|
-
const cancelBtn = screen.getByRole("button", { name: "Cancel" });
|
|
222
|
-
expect(cancelBtn).toBeInTheDocument();
|
|
223
|
-
expect(cancelBtn).not.toBeDisabled();
|
|
224
|
-
const saveBtn = screen.getByRole("button", { name: "Save" });
|
|
225
|
-
expect(saveBtn).toBeInTheDocument();
|
|
226
|
-
expect(saveBtn).toBeDisabled();
|
|
227
|
-
|
|
228
|
-
// unenroll from program
|
|
229
|
-
const completionDateInput = screen.getByLabelText("Date completed");
|
|
230
|
-
fireEvent.change(completionDateInput, { target: { value: "2020-06-01" } });
|
|
231
|
-
|
|
232
|
-
await screen.findByDisplayValue(renderDate("2020-06-01"));
|
|
233
|
-
|
|
234
|
-
fireEvent.click(saveBtn);
|
|
235
|
-
|
|
236
|
-
expect(mockUpdateProgramEnrollment).toHaveBeenCalledTimes(1);
|
|
237
|
-
expect(mockUpdateProgramEnrollment).toHaveBeenCalledWith(
|
|
238
|
-
{
|
|
239
|
-
dateCompleted: "2020-06-01",
|
|
240
|
-
dateEnrolled: "2020-01-25T00:00:00.000+0000",
|
|
241
|
-
location: "b1a8b05e-3542-4037-bbd3-998ee9c40574",
|
|
242
|
-
program: "46bd14b8-2357-42a2-8e16-262e8f0057d7",
|
|
243
|
-
},
|
|
244
|
-
new AbortController()
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
// clicking Cancel prompts user for confirmation
|
|
248
|
-
fireEvent.click(cancelBtn);
|
|
249
|
-
|
|
250
|
-
jest.spyOn(window, "confirm").mockImplementation(() => true);
|
|
251
|
-
|
|
252
|
-
expect(window.confirm).toHaveBeenCalled();
|
|
253
|
-
expect(window.confirm).toHaveBeenCalledWith(
|
|
254
|
-
"There is ongoing work, are you sure you want to close this tab?"
|
|
255
|
-
);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it("displays an error when an invalid enrollment date is selected", async () => {
|
|
259
|
-
mockUseRouteMatch.mockReturnValue(testMatch);
|
|
260
|
-
|
|
261
|
-
mockFetchEnrolledPrograms.mockReturnValue(of(mockEnrolledProgramsResponse));
|
|
262
|
-
|
|
263
|
-
renderProgramsForm();
|
|
264
|
-
|
|
265
|
-
const enrollmentDateInput = await screen.findByLabelText("Date enrolled");
|
|
266
|
-
expect(enrollmentDateInput).toBeInTheDocument();
|
|
267
|
-
|
|
268
|
-
fireEvent.change(enrollmentDateInput, { target: { value: "2030-05-05" } });
|
|
269
|
-
|
|
270
|
-
expect(enrollmentDateInput).toBeInvalid();
|
|
271
|
-
await screen.findByText(
|
|
272
|
-
"Please enter a date that is either on or before today."
|
|
273
|
-
);
|
|
274
|
-
expect(screen.getAllByRole("button")[1]).toBeDisabled();
|
|
275
|
-
});
|
|
276
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ProgramsForm from "./programs-form.component";
|
|
3
|
-
import ProgramsOverview from "./programs-overview.component";
|
|
4
|
-
import { of } from "rxjs/internal/observable/of";
|
|
5
|
-
import { BrowserRouter } from "react-router-dom";
|
|
6
|
-
import { render, screen, fireEvent } from "@testing-library/react";
|
|
7
|
-
import { mockEnrolledProgramsResponse } from "../../../../__mocks__/programs.mock";
|
|
8
|
-
import { fetchActiveEnrollments } from "./programs.resource";
|
|
9
|
-
|
|
10
|
-
const mockFetchActiveEnrollments = fetchActiveEnrollments as jest.Mock;
|
|
11
|
-
|
|
12
|
-
jest.mock("./programs.resource", () => ({
|
|
13
|
-
fetchActiveEnrollments: jest.fn(),
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
describe("<ProgramsOverview />", () => {
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
mockFetchActiveEnrollments.mockReset;
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should display the patient's program enrollments", async () => {
|
|
22
|
-
const mockOpenWorkspaceTab = jest.fn();
|
|
23
|
-
|
|
24
|
-
mockFetchActiveEnrollments.mockReturnValue(
|
|
25
|
-
of(mockEnrolledProgramsResponse)
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
render(
|
|
29
|
-
<BrowserRouter>
|
|
30
|
-
<ProgramsOverview basePath="/" />
|
|
31
|
-
</BrowserRouter>
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
await screen.findByRole("heading", { name: /Care Programs/i });
|
|
35
|
-
|
|
36
|
-
expect(screen.getByText(/Care Programs/i)).toBeInTheDocument();
|
|
37
|
-
const addBtn = screen.getByRole("button", { name: "Add" });
|
|
38
|
-
expect(addBtn).toBeInTheDocument();
|
|
39
|
-
expect(screen.getAllByText(/Active Programs/i)[0]).toBeInTheDocument();
|
|
40
|
-
expect(screen.getAllByText(/Date enrolled/i)[0]).toBeInTheDocument();
|
|
41
|
-
expect(
|
|
42
|
-
screen.getAllByText(/HIV Care and Treatment/i)[0]
|
|
43
|
-
).toBeInTheDocument();
|
|
44
|
-
|
|
45
|
-
// Clicking "Add" launches workspace tab
|
|
46
|
-
fireEvent.click(addBtn);
|
|
47
|
-
expect(mockOpenWorkspaceTab).toHaveBeenCalled();
|
|
48
|
-
expect(mockOpenWorkspaceTab).toHaveBeenCalledWith(
|
|
49
|
-
ProgramsForm,
|
|
50
|
-
"Programs form"
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("renders an empty state view when conditions data is absent", async () => {
|
|
55
|
-
mockFetchActiveEnrollments.mockReturnValue(of([]));
|
|
56
|
-
|
|
57
|
-
render(
|
|
58
|
-
<BrowserRouter>
|
|
59
|
-
<ProgramsOverview basePath="/" />
|
|
60
|
-
</BrowserRouter>
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
await screen.findByRole("heading", { name: /Care Programs/i });
|
|
64
|
-
|
|
65
|
-
expect(screen.getByText(/Care Programs/i)).toBeInTheDocument();
|
|
66
|
-
expect(
|
|
67
|
-
screen.getByText(
|
|
68
|
-
/There are no program enrollments to display for this patient/
|
|
69
|
-
)
|
|
70
|
-
).toBeInTheDocument();
|
|
71
|
-
expect(screen.getByText(/Record program enrollments/)).toBeInTheDocument();
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, screen } from "@testing-library/react";
|
|
3
|
-
import { BrowserRouter } from "react-router-dom";
|
|
4
|
-
import Programs from "./programs.component";
|
|
5
|
-
|
|
6
|
-
describe("<ProgramsComponent />", () => {
|
|
7
|
-
it("renders without dying", () => {
|
|
8
|
-
render(
|
|
9
|
-
<BrowserRouter>
|
|
10
|
-
<Programs />
|
|
11
|
-
</BrowserRouter>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
expect(
|
|
15
|
-
screen.getByRole("heading", { name: /Care Programs/i })
|
|
16
|
-
).toBeInTheDocument();
|
|
17
|
-
});
|
|
18
|
-
});
|
package/src/set-public-path.ts
DELETED