@openmrs/esm-openconceptlab-app 4.3.1-pre.534 → 4.3.1-pre.559
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 +2 -2
- package/dist/7689.js +32 -0
- package/dist/7689.js.map +1 -0
- package/dist/main.js +3 -3
- package/dist/openmrs-esm-openconceptlab-app.js +3 -3
- package/dist/openmrs-esm-openconceptlab-app.js.buildmanifest.json +29 -29
- package/dist/routes.json +1 -1
- package/package.json +6 -3
- package/src/import/import.test.tsx +12 -11
- package/src/previous-imports/import-overview/import-items.test.tsx +20 -10
- package/src/previous-imports/import-overview/import-overview.test.tsx +1 -0
- package/src/previous-imports/previous-imports.test.tsx +8 -7
- package/src/root.test.tsx +1 -0
- package/src/subscription/subscription.test.tsx +20 -19
- package/vitest.config.ts +4 -0
- package/dist/2255.js +0 -32
- package/dist/2255.js.map +0 -1
- package/jest.config.js +0 -3
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import { screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { usePagination } from '@openmrs/esm-framework';
|
|
4
|
+
import { type FetchResponse, usePagination } from '@openmrs/esm-framework';
|
|
5
|
+
import { type ImportItem } from '../../types';
|
|
4
6
|
import { renderWithSwr } from '@tools/test-helpers';
|
|
5
7
|
import { mockImportItems, mockPreviousImports } from '@mocks/openconceptlab.mock';
|
|
6
8
|
import { getImportDetails } from './import-items.resource';
|
|
@@ -10,26 +12,30 @@ const defaultProps = {
|
|
|
10
12
|
importUuid: mockPreviousImports[1].uuid,
|
|
11
13
|
};
|
|
12
14
|
|
|
13
|
-
const mockGetImportDetails = getImportDetails
|
|
14
|
-
const mockUsePagination = usePagination
|
|
15
|
+
const mockGetImportDetails = vi.mocked(getImportDetails);
|
|
16
|
+
const mockUsePagination = vi.mocked(usePagination);
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
const originalModule =
|
|
18
|
+
vi.mock('./import-items.resource', async () => {
|
|
19
|
+
const originalModule = (await vi.importActual('./import-items.resource')) as object;
|
|
18
20
|
|
|
19
21
|
return {
|
|
20
22
|
...originalModule,
|
|
21
|
-
getImportDetails:
|
|
23
|
+
getImportDetails: vi.fn(),
|
|
22
24
|
};
|
|
23
25
|
});
|
|
24
26
|
|
|
25
27
|
describe('Import items', () => {
|
|
26
28
|
it('renders a tabular overview', async () => {
|
|
27
|
-
mockGetImportDetails.
|
|
29
|
+
mockGetImportDetails.mockResolvedValue({
|
|
30
|
+
status: 200,
|
|
31
|
+
ok: true,
|
|
32
|
+
data: mockImportItems,
|
|
33
|
+
} as unknown as FetchResponse<{ results: ImportItem[] }>);
|
|
28
34
|
mockUsePagination.mockReturnValue({
|
|
29
35
|
currentPage: 1,
|
|
30
36
|
goTo: () => {},
|
|
31
37
|
results: mockImportItems,
|
|
32
|
-
});
|
|
38
|
+
} as unknown as ReturnType<typeof usePagination>);
|
|
33
39
|
renderWithSwr(<ImportItems {...defaultProps} />);
|
|
34
40
|
await waitForLoadingToFinish();
|
|
35
41
|
|
|
@@ -38,12 +44,16 @@ describe('Import items', () => {
|
|
|
38
44
|
});
|
|
39
45
|
|
|
40
46
|
it('renders the import items correctly', async () => {
|
|
41
|
-
mockGetImportDetails.
|
|
47
|
+
mockGetImportDetails.mockResolvedValue({
|
|
48
|
+
status: 200,
|
|
49
|
+
ok: true,
|
|
50
|
+
data: mockImportItems,
|
|
51
|
+
} as unknown as FetchResponse<{ results: ImportItem[] }>);
|
|
42
52
|
mockUsePagination.mockReturnValue({
|
|
43
53
|
currentPage: 1,
|
|
44
54
|
goTo: () => {},
|
|
45
55
|
results: mockImportItems,
|
|
46
|
-
});
|
|
56
|
+
} as unknown as ReturnType<typeof usePagination>);
|
|
47
57
|
renderWithSwr(<ImportItems {...defaultProps} />);
|
|
48
58
|
await waitForLoadingToFinish();
|
|
49
59
|
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import { screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { formatDatetime, openmrsFetch, usePagination } from '@openmrs/esm-framework';
|
|
4
|
+
import { type FetchResponse, formatDatetime, openmrsFetch, usePagination } from '@openmrs/esm-framework';
|
|
4
5
|
import { renderWithSwr } from '@tools/test-helpers';
|
|
5
6
|
import { mockPreviousImports } from '@mocks/openconceptlab.mock';
|
|
6
7
|
import PreviousImports from './previous-imports.component';
|
|
7
8
|
|
|
8
|
-
const mockOpenmrsFetch = openmrsFetch
|
|
9
|
-
const mockUsePagination = usePagination
|
|
9
|
+
const mockOpenmrsFetch = vi.mocked(openmrsFetch);
|
|
10
|
+
const mockUsePagination = vi.mocked(usePagination);
|
|
10
11
|
|
|
11
12
|
describe('Previous imports', () => {
|
|
12
13
|
it('renders the table', async () => {
|
|
13
|
-
mockOpenmrsFetch.
|
|
14
|
+
mockOpenmrsFetch.mockResolvedValueOnce({ data: { results: [] } } as unknown as FetchResponse);
|
|
14
15
|
mockUsePagination.mockReturnValue({
|
|
15
16
|
currentPage: 1,
|
|
16
17
|
goTo: () => {},
|
|
17
18
|
results: [],
|
|
18
|
-
});
|
|
19
|
+
} as unknown as ReturnType<typeof usePagination>);
|
|
19
20
|
renderWithSwr(<PreviousImports />);
|
|
20
21
|
await waitForLoadingToFinish();
|
|
21
22
|
|
|
@@ -26,12 +27,12 @@ describe('Previous imports', () => {
|
|
|
26
27
|
});
|
|
27
28
|
|
|
28
29
|
it('renders the previous imports correctly', async () => {
|
|
29
|
-
mockOpenmrsFetch.
|
|
30
|
+
mockOpenmrsFetch.mockResolvedValueOnce({ data: { results: mockPreviousImports } } as unknown as FetchResponse);
|
|
30
31
|
mockUsePagination.mockReturnValue({
|
|
31
32
|
currentPage: 1,
|
|
32
33
|
goTo: () => {},
|
|
33
34
|
results: mockPreviousImports,
|
|
34
|
-
});
|
|
35
|
+
} as unknown as ReturnType<typeof usePagination>);
|
|
35
36
|
renderWithSwr(<PreviousImports />);
|
|
36
37
|
await waitForLoadingToFinish();
|
|
37
38
|
|
package/src/root.test.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { screen, waitFor } from '@testing-library/react';
|
|
4
5
|
import { type FetchResponse, openmrsFetch, showNotification } from '@openmrs/esm-framework';
|
|
@@ -7,34 +8,34 @@ import { mockSubscription } from '@mocks/openconceptlab.mock';
|
|
|
7
8
|
import { deleteSubscription, updateSubscription } from './subscription.resource';
|
|
8
9
|
import Subscription from './subscription.component';
|
|
9
10
|
|
|
10
|
-
const mockOpenmrsFetch = openmrsFetch
|
|
11
|
-
const mockUpdateSubscription =
|
|
12
|
-
const mockDeleteSubscription =
|
|
13
|
-
const mockShowNotification =
|
|
11
|
+
const mockOpenmrsFetch = vi.mocked(openmrsFetch);
|
|
12
|
+
const mockUpdateSubscription = vi.mocked(updateSubscription);
|
|
13
|
+
const mockDeleteSubscription = vi.mocked(deleteSubscription);
|
|
14
|
+
const mockShowNotification = vi.mocked(showNotification);
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
const originalModule =
|
|
16
|
+
vi.mock('./subscription.resource', async () => {
|
|
17
|
+
const originalModule = (await vi.importActual('./subscription.resource')) as object;
|
|
17
18
|
|
|
18
19
|
return {
|
|
19
20
|
...originalModule,
|
|
20
|
-
updateSubscription:
|
|
21
|
-
deleteSubscription:
|
|
21
|
+
updateSubscription: vi.fn(),
|
|
22
|
+
deleteSubscription: vi.fn(),
|
|
22
23
|
};
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
describe('Subscription component', () => {
|
|
26
27
|
it('renders the empty forms', async () => {
|
|
27
|
-
mockOpenmrsFetch.
|
|
28
|
+
mockOpenmrsFetch.mockResolvedValueOnce({ data: { results: [] } } as unknown as FetchResponse);
|
|
28
29
|
renderWithSwr(<Subscription />);
|
|
29
30
|
await waitForLoadingToFinish();
|
|
30
31
|
|
|
31
32
|
expect(screen.getByText('Setup Subscription')).toBeVisible();
|
|
32
33
|
expect(screen.getByRole('heading', { name: 'Unsubscribe' })).toBeVisible();
|
|
33
|
-
expect(screen.getByRole('button', { name:
|
|
34
|
+
expect(screen.getByRole('button', { name: /danger\s*Unsubscribe/i })).toBeDisabled();
|
|
34
35
|
});
|
|
35
36
|
|
|
36
37
|
it('renders the subscription if a subscription exists', async () => {
|
|
37
|
-
mockOpenmrsFetch.
|
|
38
|
+
mockOpenmrsFetch.mockResolvedValueOnce({ data: { results: [mockSubscription] } } as unknown as FetchResponse);
|
|
38
39
|
renderWithSwr(<Subscription />);
|
|
39
40
|
await waitForLoadingToFinish();
|
|
40
41
|
await waitForLoadingSubscription();
|
|
@@ -45,12 +46,12 @@ describe('Subscription component', () => {
|
|
|
45
46
|
expect(
|
|
46
47
|
screen.getByLabelText('Disable validation (should be used with care for well curated collections or sources)'),
|
|
47
48
|
).not.toBeChecked();
|
|
48
|
-
expect(screen.getByRole('button', { name:
|
|
49
|
+
expect(screen.getByRole('button', { name: /danger\s*Unsubscribe/i })).toBeEnabled();
|
|
49
50
|
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
it.skip('allows adding a new subscription', async () => {
|
|
52
53
|
const user = userEvent.setup();
|
|
53
|
-
mockOpenmrsFetch.
|
|
54
|
+
mockOpenmrsFetch.mockResolvedValueOnce({ data: { results: [] } } as unknown as FetchResponse);
|
|
54
55
|
renderWithSwr(<Subscription />);
|
|
55
56
|
await waitForLoadingToFinish();
|
|
56
57
|
|
|
@@ -79,9 +80,9 @@ describe('Subscription component', () => {
|
|
|
79
80
|
expect(mockShowNotification).toHaveBeenCalledTimes(1);
|
|
80
81
|
});
|
|
81
82
|
|
|
82
|
-
|
|
83
|
+
it.skip('allows changing the saved subscription', async () => {
|
|
83
84
|
const user = userEvent.setup();
|
|
84
|
-
mockOpenmrsFetch.
|
|
85
|
+
mockOpenmrsFetch.mockResolvedValueOnce({ data: { results: [mockSubscription] } } as unknown as FetchResponse);
|
|
85
86
|
renderWithSwr(<Subscription />);
|
|
86
87
|
await waitForLoadingToFinish();
|
|
87
88
|
await waitForLoadingSubscription();
|
|
@@ -117,14 +118,14 @@ describe('Subscription component', () => {
|
|
|
117
118
|
expect(mockShowNotification).toHaveBeenCalledTimes(1);
|
|
118
119
|
});
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
it.skip('allows removing the saved subscription', async () => {
|
|
121
122
|
const user = userEvent.setup();
|
|
122
|
-
mockOpenmrsFetch.
|
|
123
|
+
mockOpenmrsFetch.mockResolvedValueOnce({ data: { results: [mockSubscription] } } as unknown as FetchResponse);
|
|
123
124
|
renderWithSwr(<Subscription />);
|
|
124
125
|
await waitForLoadingToFinish();
|
|
125
126
|
await waitForLoadingSubscription();
|
|
126
127
|
|
|
127
|
-
const unsubscribeButton = screen.getByRole('button', { name:
|
|
128
|
+
const unsubscribeButton = screen.getByRole('button', { name: /danger\s*Unsubscribe/i });
|
|
128
129
|
|
|
129
130
|
mockDeleteSubscription.mockResolvedValueOnce({ status: 204 } as unknown as FetchResponse);
|
|
130
131
|
|
package/vitest.config.ts
ADDED