Skip to content

Commit

Permalink
Merge pull request #154 from cqframework/order-sign-support
Browse files Browse the repository at this point in the history
Resolving test failures
  • Loading branch information
jmandel committed Sep 4, 2024
2 parents 213c1b3 + 901ae1b commit 5f8060c
Show file tree
Hide file tree
Showing 20 changed files with 1,896 additions and 4,308 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5,938 changes: 1,694 additions & 4,244 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@
"eslint-plugin-react-hooks": "^1.7.0",
"express": "^4.19.2",
"file-loader": "^6.0.0",
"jest": "^27.5.1",
"jest-environment-node": "^27.5.1",
"jest-environment-jsdom": "^27.5.1",
"jest-environment-jsdom-global": "^3.0.0",
"jest": "^24.9.0",
"jest-environment-jsdom": "^24.9.0",
"jest-environment-jsdom-global": "^1.0.3",
"mini-css-extract-plugin": "^1.6.1",
"node-sass": "^4.12.0",
"postcss": "^8.1.0",
Expand Down
9 changes: 9 additions & 0 deletions sandbox.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
2 changes: 1 addition & 1 deletion src/components/FhirServerEntry/fhir-server-entry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class FhirServerEntry extends Component {
/**
* Flag to determine if the component is open or closed
*/
isOpen: this.props.isOpen,
isOpen: Boolean(props.isOpen),
/**
* User input text tracked inside the input box for FHIR server URL entry
*/
Expand Down
1 change: 1 addition & 0 deletions src/components/RxView/rx-view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export class RxView extends Component {
labelAttrs={{ className: styles['condition-select'] }}
>
<Select
name="condition-input"
placeholder={this.state.conditionDisplay}
value={this.state.conditionDisplay}
options={this.createDropdownConditions()}
Expand Down
7 changes: 4 additions & 3 deletions tests/components/ConfigureServices/configure-services.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { mount, shallow } from 'enzyme';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import intlContexts from './intl-context-setup';

import ConnectedView, {ConfigureServices} from '../../../src/components/ConfigureServices/configure-services';

Expand Down Expand Up @@ -36,7 +37,7 @@ describe('ConfigureServices component', () => {
});

it('changes isOpen state property if props changes for the property', () => {
let component = mount(<ConfigureServices store={mockStore} isOpen={false} />);
let component = mount(<ConfigureServices store={mockStore} isOpen={false} />, intlContexts.mountContext);
expect(component.prop('isOpen')).toEqual(false);
component.setProps({ isOpen: true });
expect(component.prop('isOpen')).toEqual(true);
Expand All @@ -45,10 +46,10 @@ describe('ConfigureServices component', () => {
it('handles closing the modal in the component', async () => {
let component = shallow(<ConnectedView store={mockStore}
isOpen={true}
closePrompt={mockClosePrompt} /> );
closePrompt={mockClosePrompt} />, intlContexts.shallowContext);
let childComponent = component.find('ConfigureServices');
let shallowedComponent = childComponent.shallow();
await shallowedComponent.find('Dialog').dive().find('ContentContainer').dive().find('.right-align').find('Button').at(0).simulate('click');
expect(shallowedComponent.state('isOpen')).toEqual(false);
expect(mockClosePrompt).toHaveBeenCalled();
});
});
12 changes: 12 additions & 0 deletions tests/components/ConfigureServices/intl-context-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { IntlProvider, intlShape } from 'react-intl';

const locale = 'en-US';
const intlProvider = new IntlProvider({ locale }, {});
const { intl } = intlProvider.getChildContext();

const shallowContext = { context: { intl }, lifecycleExperimental: true };
const mountContext = { context: { intl }, childContextTypes: { intl: intlShape }, lifecycleExperimental: true };

const intlContexts = { shallowContext, mountContext };

export default intlContexts;
10 changes: 5 additions & 5 deletions tests/components/ContextView/context-view.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('ServiceContextView component', () => {

it('renders relevant child components', () => {
const shallowComponent = pureComponent.shallow();
expect(shallowComponent.find('SelectField')).toHaveLength(1);
expect(shallowComponent.find('Field')).toHaveLength(1);
expect(shallowComponent.find('ExchangePanel')).toHaveLength(2);
});

Expand All @@ -90,14 +90,14 @@ describe('ServiceContextView component', () => {
expect(wrapper.find('.context-open')).toHaveLength(0);
});

describe('SelectField', () => {
describe('Field', () => {
it('does not pre-select a service for the dropdown if there are no applicable services for the view', () => {
storeState.hookState.currentHook = 'view-with-no-services';
storeState.serviceExchangeState.selectedService = '';
mockStore = mockStoreWrapper(storeState);
let component = <ConnectedView store={mockStore}/>;
wrapper = mount(component);
const selectDropdown = wrapper.find('SelectField');
const selectDropdown = wrapper.find('Select');

expect(selectDropdown.prop('options')).toEqual([]);
expect(wrapper.prop('initialService')).toEqual(undefined);
Expand All @@ -106,7 +106,7 @@ describe('ServiceContextView component', () => {
it('preselects a service for the dropdown if there is at least one applicable service for the view', () => {
let component = <ConnectedView store={mockStore}/>;
wrapper = mount(component);
const selectDropdown = wrapper.find('SelectField');
const selectDropdown = wrapper.find('Select');
expect(selectDropdown.prop('value')).toEqual(patientServiceUrl);
});
});
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('ServiceContextView component', () => {
});

it('can dispatch an action via dispatch function passed in as a prop for selecting service', () => {
pureComponent.find('SelectField').simulate('change', { target: { value: patientServiceUrl }});
pureComponent.find('Field').children().simulate('change', { value: patientServiceUrl });
const expectedAction = { type: types.SELECT_SERVICE_CONTEXT, service: patientServiceUrl};
expect(mockStore.getActions()).toEqual([expectedAction]);
});
Expand Down
25 changes: 13 additions & 12 deletions tests/components/FhirServerEntry/fhir-server-entry.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { mount, shallow } from 'enzyme';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import intlContexts from './intl-context-setup';

describe('FhirServerEntry component', () => {
let storeState;
Expand All @@ -27,7 +27,7 @@ describe('FhirServerEntry component', () => {
FhirServerEntryView = require('../../../src/components/FhirServerEntry/fhir-server-entry')['FhirServerEntry'];
let component;
if (mockResolve && mockClosePrompt) {
component = <ConnectedView store={mockStore}
component = <ConnectedView store={mockStore}
resolve={mockResolve}
isOpen={true}
isEntryRequired={isEntryRequired}
Expand All @@ -37,7 +37,8 @@ describe('FhirServerEntry component', () => {
} else {
component = <ConnectedView store={mockStore}/>;
}
wrapper = shallow(component);
// wrapper = shallow(component);
wrapper = shallow(component, intlContexts.shallowContext);
pureComponent = wrapper.find(FhirServerEntryView);
}

Expand Down Expand Up @@ -66,29 +67,29 @@ describe('FhirServerEntry component', () => {

it('changes isOpen state property if props changes for the property', () => {
setup(storeState);
let component = mount(<FhirServerEntryView isOpen={false} />);
expect(component.prop('isOpen')).toEqual(false);
component.setProps({ isOpen: true });
expect(component.prop('isOpen')).toEqual(true);
// let component = mount(<FhirServerEntryView isOpen={false} />, { context: { intl }, childContextTypes: { intl: intlShape } });
let component = pureComponent.shallow();
expect(component.state('isOpen')).toEqual(true);
component.setProps({ isOpen: false });
expect(component.state('isOpen')).toEqual(false);
});

it('handles resetting the fhir server and closes the modal', async () => {
isEntryRequired = false;
setup(storeState);
let shallowedComponent = pureComponent.shallow();
await shallowedComponent.find('Dialog').dive().find('ContentContainer').dive().find('.right-align').find('Button').at(0).simulate('click');
expect(shallowedComponent.state('isOpen')).toEqual(false);
expect(mockClosePrompt).toHaveBeenCalled();
expect(mockResolve).toHaveBeenCalled();
expect(mockSpy).toHaveBeenCalled();
});

it('handles closing the modal in the component', async () => {
mockResolve = null;
mockClosePrompt = null;
isEntryRequired = false;
setup(storeState);
let shallowedComponent = pureComponent.shallow();
await shallowedComponent.find('Dialog').dive().find('ContentContainer').dive().find('.right-align').find('Button').at(2).simulate('click');
expect(shallowedComponent.state('isOpen')).toEqual(false);
expect(mockClosePrompt).toHaveBeenCalled();
});

describe('User input', () => {
Expand Down Expand Up @@ -134,7 +135,7 @@ describe('FhirServerEntry component', () => {
let shallowedComponent = pureComponent.shallow();
await enterInputAndSave(shallowedComponent, 'test');
expect(shallowedComponent.state('shouldDisplayError')).toEqual(false);
expect(shallowedComponent.state('isOpen')).toEqual(false);
expect(mockClosePrompt).toHaveBeenCalled();
expect(mockResolve).toHaveBeenCalled();
expect(mockClosePrompt).toHaveBeenCalled();
});
Expand Down
12 changes: 12 additions & 0 deletions tests/components/FhirServerEntry/intl-context-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { IntlProvider, intlShape } from 'react-intl';

const locale = 'en-US';
const intlProvider = new IntlProvider({ locale }, {});
const { intl } = intlProvider.getChildContext();

const shallowContext = { context: { intl }, lifecycleExperimental: true };
const mountContext = { context: { intl }, childContextTypes: { intl: intlShape }, lifecycleExperimental: true };

const intlContexts = { shallowContext, mountContext };

export default intlContexts;
12 changes: 12 additions & 0 deletions tests/components/PatientEntry/intl-context-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { IntlProvider, intlShape } from 'react-intl';

const locale = 'en-US';
const intlProvider = new IntlProvider({ locale }, {});
const { intl } = intlProvider.getChildContext();

const shallowContext = { context: { intl }, lifecycleExperimental: true };
const mountContext = { context: { intl }, childContextTypes: { intl: intlShape }, lifecycleExperimental: true };

const intlContexts = { shallowContext, mountContext };

export default intlContexts;
18 changes: 9 additions & 9 deletions tests/components/PatientEntry/patient-entry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { mount, shallow } from 'enzyme';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import intlContexts from './intl-context-setup';

describe('PatientEntry component', () => {
let storeState;
Expand Down Expand Up @@ -33,7 +34,7 @@ describe('PatientEntry component', () => {
} else {
component = <ConnectedView store={mockStore}/>;
}
wrapper = shallow(component);
wrapper = shallow(component, intlContexts.shallowContext);
pureComponent = wrapper.find(PatientEntryView);
}

Expand Down Expand Up @@ -62,19 +63,18 @@ describe('PatientEntry component', () => {

it('changes isOpen state property if props changes for the property', () => {
setup(storeState);
let component = mount(<PatientEntryView isOpen={false} />);
expect(component.prop('isOpen')).toEqual(false);
component.setProps({ isOpen: true });
expect(component.prop('isOpen')).toEqual(true);
let component = pureComponent.shallow();
expect(component.state('isOpen')).toEqual(true);
component.setProps({ isOpen: false });
expect(component.state('isOpen')).toEqual(false);
});

it('handles closing the modal in the component', async () => {
mockResolve = null;
mockClosePrompt = null;
isEntryRequired = false;
setup(storeState);
let shallowedComponent = pureComponent.shallow();
await shallowedComponent.find('Dialog').dive().find('ContentContainer').dive().find('.right-align').find('Button').at(1).simulate('click');
expect(shallowedComponent.state('isOpen')).toEqual(false);
expect(mockClosePrompt).toHaveBeenCalled();
});

it('does not have cancel options on the modal if a patient is required', async () => {
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('PatientEntry component', () => {
let shallowedComponent = pureComponent.shallow();
await enterInputAndSave(shallowedComponent, 'test');
expect(shallowedComponent.state('shouldDisplayError')).toEqual(false);
expect(shallowedComponent.state('isOpen')).toEqual(false);
expect(mockClosePrompt).toHaveBeenCalled();
expect(mockResolve).toHaveBeenCalled();
expect(mockClosePrompt).toHaveBeenCalled();
});
Expand Down
Loading

0 comments on commit 5f8060c

Please sign in to comment.