Skip to content

Commit

Permalink
(chore) Bump tooling (#54)
Browse files Browse the repository at this point in the history
* (chore) Bump tooling

This commit effects version bumps for the core tooling, framework, yarn and turbo.

* Fix tests
  • Loading branch information
denniskigen authored Aug 27, 2024
1 parent f489669 commit 80c0ed9
Show file tree
Hide file tree
Showing 21 changed files with 3,056 additions and 2,506 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
src/**/*.test.tsx
src/**/*.spec.tsx
**/*.d.tsx
**/node_modules/**/*
44 changes: 10 additions & 34 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,18 @@
## Requirements

- [ ] This PR has a title that briefly describes the work done, including the ticket number if there is a ticket.
- [ ] My work conforms to the [**OpenMRS 3.0 Styleguide**](https://om.rs/styleguide).
- [ ] I checked for feature overlap with [**existing widgets**](https://om.rs/directory).
# Requirements

- [ ] This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a [conventional commit](https://o3-docs.openmrs.org/docs/frontend-modules/contributing.en-US#contributing-guidelines) label. See existing PR titles for inspiration.
- [ ] My work conforms to the [OpenMRS 3.0 Styleguide](https://om.rs/styleguide) and [design documentation](https://om.rs/o3ui).
- [ ] My work includes tests or is validated by existing tests.

## Summary

<!--
Required.
Please describe what problems your PR addresses.
-->

<!-- Please describe what problems your PR addresses. -->

## Screenshots
<!-- Required if you are making UI changes. -->

*None.*
<!--
Optional.
If possible, please insert any screenshots/videos of your changes here.
Don't forget to remove the *None.* above if you do fill this section.
-->


## Issue

*None.*
<!--
Required if applicable.
If present, please link any related issue here, e.g. "https://issues.openmrs.org/browse/O3-123").
-->

## Related issue
<!-- Paste the link to the Jira ticket here if one exists. -->
<!-- https://issues.openmrs.org/browse/O3- -->

## Other

*None.*
<!--
Optional.
Anything else that isn't covered by one of the sections above.
Don't forget to remove the *None.* above if you do fill this section.
-->
<!-- Anything not covered above -->
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
run: yarn playwright test

- name: Stop dev server
if: "!cancelled()"
if: '!cancelled()'
run: docker stop $(docker ps -a -q)

- name: Upload Report
Expand Down
894 changes: 0 additions & 894 deletions .yarn/releases/yarn-4.2.2.cjs

This file was deleted.

925 changes: 925 additions & 0 deletions .yarn/releases/yarn-4.4.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.2.2.cjs
yarnPath: .yarn/releases/yarn-4.4.1.cjs
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');

/** @type {import('jest').Config} */
module.exports = {
clearMocks: true,
transform: {
'^.+\\.(j|t)sx?$': '@swc/jest',
},
Expand All @@ -11,14 +12,15 @@ module.exports = {
'@openmrs/esm-framework': '@openmrs/esm-framework/mock',
'^dexie$': require.resolve('dexie'),
'^lodash-es/(.*)$': 'lodash/$1',
'^lodash-es$': 'lodash',
'^react-i18next$': path.resolve(__dirname, '__mocks__', 'react-i18next.js'),
},
collectCoverageFrom: [
'**/src/**/*.component.tsx',
'!**/node_modules/**',
'!**/vendor/**',
'!**/src/**/*.test.*',
'!**/src/declarations.d.tsx',
'!**/src/declarations.d.ts',
'!**/e2e/**',
],
coverageThreshold: {
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
},
"devDependencies": {
"@openmrs/esm-framework": "next",
"@playwright/test": "^1.43.0",
"@playwright/test": "^1.46.1",
"@swc/cli": "^0.1.65",
"@swc/core": "^1.4.2",
"@swc/jest": "^0.2.36",
"@testing-library/dom": "^9.3.4",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"@testing-library/dom": "^10.1.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^25.2.3",
"@types/jest": "^29.5.12",
"@types/jsdom": "20.0.1",
"@types/lodash-es": "^4.17.12",
"@types/react": "^18.2.61",
Expand Down Expand Up @@ -59,7 +59,7 @@
"rxjs": "^6.6.7",
"sass": "^1.71.1",
"swc-loader": "^0.2.6",
"turbo": "^1.12.4",
"turbo": "^2.0.14",
"typescript": "^4.9.5",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4"
Expand All @@ -68,5 +68,5 @@
"*.{ts,tsx}": "eslint --cache --fix --max-warnings 0",
"*.{css,scss,ts,tsx}": "prettier --write --list-different"
},
"packageManager": "yarn@4.2.2"
"packageManager": "yarn@4.4.1"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
declare module '*.css';
declare module '*.scss';
declare module '@carbon/react';
declare type SideNavProps = {};
53 changes: 16 additions & 37 deletions packages/esm-admin-openconceptlab-app/src/import/import.test.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import { screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Import from './import.component';
import { openmrsFetch, showNotification } from '@openmrs/esm-framework';
import { screen, waitFor } from '@testing-library/react';
import { type FetchResponse, openmrsFetch, showNotification } from '@openmrs/esm-framework';
import { mockSubscription } from '../../../../__mocks__/openconceptlab.mock';
import { renderWithSwr } from '../../../../tools/test-helpers';
import { startImportWithSubscription } from './import.resource';
import { mockSubscription } from '../../../../__mocks__/openconceptlab.mock';
import Import from './import.component';

const mockOpenmrsFetch = openmrsFetch as jest.Mock;
const mockStartImportWithSubscription = startImportWithSubscription as jest.Mock;
const mockShowNotification = showNotification as jest.Mock;
const mockShowNotification = jest.mocked(showNotification);
const mockStartImportWithSubscription = jest.mocked(startImportWithSubscription);

jest.mock('./import.resource', () => {
const originalModule = jest.requireActual('./import.resource');
Expand All @@ -21,27 +21,10 @@ jest.mock('./import.resource', () => {
};
});

jest.mock('@openmrs/esm-framework', () => {
const originalModule = jest.requireActual('@openmrs/esm-framework');

return {
...originalModule,
showNotification: jest.fn(),
};
});

describe(`Import component`, () => {
afterEach(() => {
mockShowNotification.mockReset();
});

it(`renders without dying`, () => {
renderImportComponent();
});

it(`renders the form elements`, async () => {
describe('Import component', () => {
it('renders the form elements', async () => {
mockOpenmrsFetch.mockReturnValueOnce({ data: { results: [] } });
renderImportComponent();
renderWithSwr(<Import />);
await waitForLoadingToFinish();

expect(screen.getByText('Import Concepts')).toBeVisible();
Expand All @@ -52,30 +35,30 @@ describe(`Import component`, () => {
expect(screen.queryByText('File Added')).not.toBeInTheDocument();
});

it(`renders correctly when there is no subscription`, async () => {
it('renders correctly when there is no subscription', async () => {
mockOpenmrsFetch.mockReturnValueOnce({ data: { results: [] } });
renderImportComponent();
renderWithSwr(<Import />);
await waitForLoadingToFinish();

expect(screen.getByText('Import from Subscription')).toBeDisabled();
expect(screen.getByText('Import from file')).toBeEnabled();
});

it(`renders correctly when when a subscription exists`, async () => {
it('renders correctly when when a subscription exists', async () => {
mockOpenmrsFetch.mockReturnValueOnce({ data: { results: [mockSubscription] } });
renderImportComponent();
renderWithSwr(<Import />);
await waitForLoadingToFinish();

await waitFor(() => expect(screen.getByText('Import from Subscription')).toBeEnabled(), { timeout: 2000 });
expect(screen.getByText('Import from file')).toBeEnabled();
});

it(`allows starting an import using the subscription`, async () => {
it('allows starting an import using the subscription', async () => {
mockOpenmrsFetch.mockReturnValueOnce({ data: { results: [mockSubscription] } });
renderImportComponent();
renderWithSwr(<Import />);
await waitForLoadingToFinish();

mockStartImportWithSubscription.mockReturnValueOnce({ status: 201 });
mockStartImportWithSubscription.mockResolvedValue({ status: 201 } as unknown as FetchResponse);

await waitFor(() => userEvent.click(screen.getByText('Import from Subscription')));

Expand All @@ -92,10 +75,6 @@ describe(`Import component`, () => {
});
});

function renderImportComponent() {
renderWithSwr(<Import />);
}

function waitForLoadingToFinish() {
return waitFor(() => {
expect(screen.getByText('Import Concepts')).toBeVisible, { timeout: 2000 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { mockImportItems, mockPreviousImports } from '../../../../../__mocks__/o
import { getImportDetails } from './import-items.resource';
import ImportItems from './import-items.component';

const testProps = {
const defaultProps = {
importUuid: mockPreviousImports[1].uuid,
};

Expand All @@ -22,43 +22,29 @@ jest.mock('./import-items.resource', () => {
};
});

jest.mock('@openmrs/esm-framework', () => {
const originalModule = jest.requireActual('@openmrs/esm-framework');

return {
...originalModule,
usePagination: jest.fn(),
};
});

describe(`Import Items component`, () => {
afterEach(() => {
mockGetImportDetails.mockReset();
mockUsePagination.mockReset();
});

it(`renders the table`, async () => {
describe('Import items', () => {
it('renders a tabular overview', async () => {
mockGetImportDetails.mockReturnValue({ status: 200, ok: true, data: mockImportItems });
mockUsePagination.mockReturnValue({
currentPage: 1,
goTo: () => {},
results: mockImportItems,
});
renderImportItemsComponent();
renderWithSwr(<ImportItems {...defaultProps} />);
await waitForLoadingToFinish();

expect(screen.getByText('Concept/Mapping')).toBeVisible();
expect(screen.getByText('Message')).toBeVisible();
});

it(`renders the import items correctly`, async () => {
it('renders the import items correctly', async () => {
mockGetImportDetails.mockReturnValue({ status: 200, ok: true, data: mockImportItems });
mockUsePagination.mockReturnValue({
currentPage: 1,
goTo: () => {},
results: mockImportItems,
});
renderImportItemsComponent();
renderWithSwr(<ImportItems {...defaultProps} />);
await waitForLoadingToFinish();

expect(screen.getByText('Concept/Mapping')).toBeVisible();
Expand All @@ -71,10 +57,6 @@ describe(`Import Items component`, () => {
});
});

function renderImportItemsComponent() {
renderWithSwr(<ImportItems {...testProps} />);
}

function waitForLoadingToFinish() {
return waitFor(() => {
expect(screen.getByText('Concept/Mapping')).toBeVisible(), { timeout: 2000 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import { renderWithSwr } from '../../../../../tools/test-helpers';
import { mockPreviousImports } from '../../../../../__mocks__/openconceptlab.mock';
import ImportOverview from './import-overview.component';

describe(`Import Overview component`, () => {
it(`renders without dying`, () => {
renderImportOverviewComponent(mockPreviousImports[0]);
});

it(`renders the fields`, async () => {
describe('Import Overview component', () => {
it('renders the fields', async () => {
renderImportOverviewComponent(mockPreviousImports[0]);
await waitForLoadingToFinish();

Expand All @@ -20,7 +16,7 @@ describe(`Import Overview component`, () => {
expect(screen.getByText('Result:')).toBeVisible();
});

it(`renders the import details when no errored items`, async () => {
it('renders the import details when no errored items', async () => {
const selectedImport = mockPreviousImports[0];

renderImportOverviewComponent(selectedImport);
Expand All @@ -45,7 +41,7 @@ describe(`Import Overview component`, () => {
expect(screen.getByText(ignoredErrorsText)).toBeVisible();
});

it(`renders the import details when there are errored items`, async () => {
it('renders the import details when there are errored items', async () => {
const selectedImport = mockPreviousImports[1];

renderImportOverviewComponent(selectedImport);
Expand Down
Loading

0 comments on commit 80c0ed9

Please sign in to comment.