Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/components/chart/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const SettingsPopover = styled(Popover)`

const Settings = ({
chartPrefs,
copyAsTextMetadata,
data,
onClickRefresh,
onClickNoDataRefresh,
Expand Down Expand Up @@ -652,6 +653,9 @@ const Settings = ({
<PumpSettingsContainer
currentPatientInViewId={currentPatientInViewId}
copySettingsClicked={handleCopySettingsClicked}
copyAsTextMetadata={copyAsTextMetadata}
patient={patient}
metaData={_.get(data, 'metaData', {})}
bgUnits={_.get(data, 'bgPrefs.bgUnits', {})}
manufacturerKey={manufacturer}
toggleSettingsSection={toggleSettingsSection}
Expand Down Expand Up @@ -819,6 +823,7 @@ const Settings = ({

Settings.propTypes = {
chartPrefs: PropTypes.object.isRequired,
copyAsTextMetadata: PropTypes.object,
data: PropTypes.object.isRequired,
onClickRefresh: PropTypes.func.isRequired,
onClickNoDataRefresh: PropTypes.func.isRequired,
Expand Down
1 change: 1 addition & 0 deletions app/pages/patientdata/patientdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ export const PatientDataClass = createReactClass({
<div className="app-no-print">
<Settings
chartPrefs={this.state.chartPrefs}
copyAsTextMetadata={this.getCopyAsTextMetadata()}
currentPatientInViewId={this.props.currentPatientInViewId}
data={this.props.data}
patient={this.props.patient}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/user-event": "14.6.1",
"@tidepool/viz": "1.58.0",
"@tidepool/viz": "1.59.0-web-4389-devices-view-copy-text.1",
"@types/jest": "29.5.14",
"async": "2.6.4",
"autoprefixer": "10.4.16",
Expand Down
72 changes: 67 additions & 5 deletions test/unit/components/chart/settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ function renderWithCompat(ui, options = {}) {
};
}

function mockPumpSettingsContainer({
copySettingsClicked,
toggleSettingsSection,
view,
}) {
let pumpSettingsContainerProps = [];

function mockPumpSettingsContainer(props) {
pumpSettingsContainerProps.push(props);

const { copySettingsClicked, toggleSettingsSection, view } = props;

return (
<div className="pump-settings-container">
<button
Expand Down Expand Up @@ -285,6 +287,8 @@ describe('Settings', () => {
});

beforeEach(() => {
pumpSettingsContainerProps = [];

mockUseHistory.mockReturnValue({
location: { query: {}, pathname: '/settings' },
replace: sinon.stub(),
Expand Down Expand Up @@ -537,6 +541,64 @@ describe('Settings', () => {
});
});

describe('copy-as-text props forwarded to PumpSettingsContainer', () => {
const settingsData = {
data: {
combined: [
{
type: 'pumpSettings',
normalTime: '2023-01-01T00:00:00Z',
source: 'source1',
id: 'id1',
},
],
},
timePrefs: { timezoneName: 'UTC' },
};

const metaData = {
devices: [{ id: 'source1-id', deviceName: 'Tandem t:slim X2' }],
matchedDevices: { 'source1-id': true },
};

const containerProps = () => _.last(pumpSettingsContainerProps);

it('should pass copyAsTextMetadata through unchanged', () => {
const copyAsTextMetadata = {
diagnosisTypeLabel: 'Type 1 diabetes',
patientTags: [{ id: 'tag1', name: 'Tag 1' }],
sites: [{ id: 'site1', name: 'Site 1' }],
};

mountWrapper({ copyAsTextMetadata, data: settingsData });

expect(containerProps().copyAsTextMetadata).to.eql(copyAsTextMetadata);
});

it('should pass the patient prop through, including the merged mrn', () => {
const patientWithMrn = _.merge({}, patient, {
profile: { patient: { mrn: 'mrn123' } },
});

mountWrapper({ patient: patientWithMrn, data: settingsData });

expect(containerProps().patient).to.eql(patientWithMrn);
expect(containerProps().patient.profile.patient.mrn).to.equal('mrn123');
});

it('should map data.metaData onto the metaData prop', () => {
mountWrapper({ data: { ...settingsData, metaData } });

expect(containerProps().metaData).to.eql(metaData);
});

it('should pass an empty object as metaData when data carries none', () => {
mountWrapper({ data: settingsData });

expect(containerProps().metaData).to.eql({});
});
});

it('renders the chart when settings are selected', () => {
mountWrapper({
data: {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6211,9 +6211,9 @@ __metadata:
languageName: node
linkType: hard

"@tidepool/viz@npm:1.58.0":
version: 1.58.0
resolution: "@tidepool/viz@npm:1.58.0"
"@tidepool/viz@npm:1.59.0-web-4389-devices-view-copy-text.1":
version: 1.59.0-web-4389-devices-view-copy-text.1
resolution: "@tidepool/viz@npm:1.59.0-web-4389-devices-view-copy-text.1"
dependencies:
bluebird: 3.7.2
bows: 1.7.2
Expand Down Expand Up @@ -6274,7 +6274,7 @@ __metadata:
react-dom: 16.x
react-redux: 8.x
redux: 4.x
checksum: c51273e11c63b1dde6d4a77541df02299cb1890e73f54041a3a3d3a011360321e324e78c4b2a75f08cfeed1f3e20eaaa50e23315fb277a5dccf53bcfc6c7ba54
checksum: 6d0cce17725547894fdf27ad09e7abc0d51f634c47d6bc374e8760a81e32227c47b5bc457148fd3e30f1784907156e8435f2f1f9646d6466859e1ef574d98b8f
languageName: node
linkType: hard

Expand Down Expand Up @@ -8410,7 +8410,7 @@ __metadata:
"@testing-library/react": 12.1.5
"@testing-library/react-hooks": 8.0.1
"@testing-library/user-event": 14.6.1
"@tidepool/viz": 1.58.0
"@tidepool/viz": 1.59.0-web-4389-devices-view-copy-text.1
"@types/jest": 29.5.14
async: 2.6.4
autoprefixer: 10.4.16
Expand Down